modify controller
This commit is contained in:
parent
905c442d3f
commit
006eac4240
1 changed files with 15 additions and 7 deletions
|
@ -5,7 +5,7 @@ module Users
|
|||
layout 'procedure_context', only: [:identite, :update_identite, :siret, :update_siret]
|
||||
|
||||
ACTIONS_ALLOWED_TO_ANY_USER = [:index, :recherche, :new, :transferer_all]
|
||||
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire]
|
||||
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire, :restore]
|
||||
|
||||
before_action :ensure_ownership!, except: ACTIONS_ALLOWED_TO_ANY_USER + ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
||||
before_action :ensure_ownership_or_invitation!, only: ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
||||
|
@ -16,17 +16,18 @@ module Users
|
|||
before_action :store_user_location!, only: :new
|
||||
|
||||
def index
|
||||
@user_dossiers = current_user.dossiers.includes(:procedure).state_not_termine.order_by_updated_at.page(page)
|
||||
@dossiers_traites = current_user.dossiers.includes(:procedure).state_termine.not_hidden_by_user.order_by_updated_at.page(page)
|
||||
@user_dossiers = current_user.dossiers.includes(:procedure).state_not_termine.visible_by_user.order_by_updated_at.page(page)
|
||||
@dossiers_traites = current_user.dossiers.includes(:procedure).state_termine.visible_by_user.order_by_updated_at.page(page)
|
||||
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
|
||||
@dossiers_supprimes = current_user.deleted_dossiers.order_by_updated_at.page(page)
|
||||
@dossiers_supprimes_recemment = current_user.dossiers.hidden_by_user.order_by_updated_at.page(page)
|
||||
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.order_by_updated_at.page(page)
|
||||
@dossier_transfers = DossierTransfer
|
||||
.includes(dossiers: :user)
|
||||
.with_dossiers
|
||||
.where(email: current_user.email)
|
||||
.page(page)
|
||||
@dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.page(page)
|
||||
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
|
||||
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -287,17 +288,24 @@ module Users
|
|||
@transfer = DossierTransfer.new(dossiers: current_user.dossiers)
|
||||
end
|
||||
|
||||
def restore
|
||||
dossier.restore(current_user)
|
||||
flash.notice = t('users.dossiers.restore')
|
||||
redirect_to dossiers_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# if the status tab is filled, then this tab
|
||||
# else first filled tab
|
||||
# else en-cours
|
||||
def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes, dossier_transfers, dossiers_close_to_expiration, params_statut)
|
||||
def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes_recemment, dossiers_supprimes_definitivement, dossier_transfers, dossiers_close_to_expiration, params_statut)
|
||||
tabs = {
|
||||
'en-cours' => mes_dossiers.present?,
|
||||
'traites' => dossiers_traites.present?,
|
||||
'dossiers-invites' => dossiers_invites.present?,
|
||||
'dossiers-supprimes' => dossiers_supprimes.present?,
|
||||
'dossiers-supprimes-recemment' => dossiers_supprimes_recemment.present?,
|
||||
'dossiers-supprimes-definitivement' => dossiers_supprimes_definitivement.present?,
|
||||
'dossiers-transferes' => dossier_transfers.present?,
|
||||
'dossiers-expirant' => dossiers_close_to_expiration.present?
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue