Merge pull request #200 from coopdevs/fix-organization-statement-list

Adding Organization movements view same functionality like users movements view
This commit is contained in:
Saverio Trioni
2016-04-24 22:11:46 +02:00
7 changed files with 68 additions and 73 deletions

View File

@ -18,6 +18,12 @@ class OrganizationsController < ApplicationController
end
def show
@movements = @organization.
account.
movements.
order("created_at DESC").
page(params[:page]).
per(10)
end
def create

View File

@ -67,24 +67,5 @@
%a{href: give_time_organization_path(@organization)}
%span.glyphicon.glyphicon-time
= t "global.give_time"
.panel.user-profile
.panel-body
%h3
= t "global.movements"
.transactions
%table.table.table-condensed
%thead
%tr
%th= t "global.date"
%th= t "global.source_destination"
%th= t "global.announcements"
%th= t "global.reason"
%th= t "global.amount"
- @organization.account.movements.order("created_at DESC").limit(10).each do |mv|
%tr
%td= l mv.created_at, format: :long
%td= mv.other_side.account
%td= mv.transfer.post
%td= mv.transfer.reason
%td= seconds_to_hm(mv.amount)
- if current_user
= render "shared/movements"

View File

@ -0,0 +1,43 @@
.panel.user-profile
.panel-body
%h3
= t(".movements")
.transactions
%table.table.table-condensed
%thead
%tr
%th= t "global.date"
%th= t "global.source_destination"
%th= t "global.announcements"
%th= t "global.reason"
%th= t "global.amount"
- @movements.each do |mv|
%tr
%td= l mv.created_at.to_date, format: :long
%td
- mv.other_side.account.tap do |account|
- if account.accountable.present?
- if account.accountable_type == "Organization"
= link_to account,
organization_path(account.accountable)
- elsif account.accountable.active
= link_to account.accountable.display_name_with_uid,
user_path(account.accountable.user)
- else
= t(".inactive_user")
- else
= t(".deleted_user")
%td
- if mv.transfer.try(:post).try(:active?)
= link_to(mv.transfer.post, offer_path(mv.transfer.post))
- else
= mv.transfer.post
%td
= mv.transfer.reason
- if mv.transfer.reason.present? && admin?
- op = { method: :put, data: { confirm: t(".delete_reason") } }
= link_to(delete_reason_transfer_path(mv.transfer), op) do
%span.glyphicon.glyphicon-trash
%td= seconds_to_hm(mv.amount)
.paginate-align
= paginate @movements

View File

@ -107,48 +107,4 @@
= t(".balance")
= seconds_to_hm(@member.account.try(:balance) || mdash)
.panel.user-profile
.panel-body
%h3
=t(".movements")
.transactions
%table.table.table-condensed
%thead
%tr
%th
=t(".date")
%th
=t(".from_to")
%th
=t(".post")
%th
=t(".reason")
%th
=t(".quantity")
- @movements.each do |mv|
%tr
%td= l mv.created_at.to_date, format: :long
%td
- mv.other_side.account.tap do |account|
- if account.accountable.present?
- if account.accountable_type == "Organization"
= link_to account,
organization_path(account.accountable)
- elsif account.accountable.active
= link_to account.accountable.display_name_with_uid,
user_path(account.accountable.user)
- else
= t(".inactive_user")
- else
= t(".deleted_user")
%td
= mv.transfer.try(:post).try(:active?) ? link_to(mv.transfer.post, offer_path(mv.transfer.post)) : mv.transfer.post
%td
= mv.transfer.reason
- if mv.transfer.reason.present? && admin?
= link_to delete_reason_transfer_path(mv.transfer), method: :put, data: { confirm: t(".delete_reason") } do
%span.glyphicon.glyphicon-trash
%td= seconds_to_hm(mv.amount)
.paginate-align
= paginate @movements
= render "shared/movements"

View File

@ -175,13 +175,11 @@ ca:
created_at: "Alta:"
user_no: "núm. Usuari:"
balance: "Balanç:"
movements: "Moviments"
date: Data
from_to: Origen/Destí
post: Anunci
reason: Raó
quantity: Quantitat
delete_reason: Esteu segur d'esborrar aquest comentari?
inactive_user: L'usuari no està actiu
deleted_user: L'usuari ja no existeix
@ -369,3 +367,8 @@ ca:
previous: "&lsaquo; Anterior"
next: "Següent &rsaquo;"
truncate: "&hellip;"
shared:
movements:
delete_reason: Esteu segur d'esborrar aquest comentari?
movements: Moviments

View File

@ -175,13 +175,11 @@ en:
created_at: "Registered:"
user_no: "User #:"
balance: "Balance:"
movements: "Transactions"
date: Date
from_to: From/To
post: Post
reason: Reason
quantity: Quantity
delete_reason: Are you sure to delete this comment?
inactive_user: The user isn't active
deleted_user: The user no longer exists
@ -365,3 +363,8 @@ en:
edit_org: "Update %{organization}"
report:
report_title: "REPORT"
shared:
movements:
delete_reason: Are you sure to delete this comment?
movements: Movements

View File

@ -175,13 +175,11 @@ es:
created_at: "Alta:"
user_no: "Nº Usuario:"
balance: "Balance:"
movements: "Movimientos"
date: Fecha
from_to: Origen/Destino
post: Anuncio
reason: Razón
quantity: Cantidad
delete_reason: "¿Está seguro de borrar este comentario?"
inactive_user: El usuario no está activo
deleted_user: El usuario ya no existe
@ -287,7 +285,7 @@ es:
post: Anuncio
reason: Razón
quantity: Cantidad
delete_reason: "¿Está seguro de borrar este comentario?"
delete_reason: ¿Está seguro de borrar este comentario?
stats:
min_balance:
@ -374,3 +372,8 @@ es:
previous: "&lsaquo; Anterior"
next: "Siguiente &rsaquo;"
truncate: "&hellip;"
shared:
movements:
delete_reason: ¿Está seguro de borrar este comentario?
movements: Movimientos