Ajout des tableaux séparés et des états de chaque dossier dans le backoffice
This commit is contained in:
parent
2a2147a7bb
commit
be5a7f2fd2
5 changed files with 159 additions and 81 deletions
|
@ -30,81 +30,93 @@ class Dossier < ActiveRecord::Base
|
|||
validates :date_previsionnelle, presence: true, allow_blank: false, unless: Proc.new { description.nil? }
|
||||
validates :user, presence: true
|
||||
|
||||
def retrieve_piece_justificative_by_type(type)
|
||||
pieces_justificatives.where(type_de_piece_justificative_id: type).last
|
||||
end
|
||||
def retrieve_piece_justificative_by_type(type)
|
||||
pieces_justificatives.where(type_de_piece_justificative_id: type).last
|
||||
end
|
||||
|
||||
def build_default_pieces_justificatives
|
||||
procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
|
||||
PieceJustificative.create(type_de_piece_justificative_id: type_de_piece_justificative.id, dossier_id: id)
|
||||
end
|
||||
end
|
||||
def build_default_pieces_justificatives
|
||||
procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
|
||||
PieceJustificative.create(type_de_piece_justificative_id: type_de_piece_justificative.id, dossier_id: id)
|
||||
end
|
||||
end
|
||||
|
||||
def sous_domaine
|
||||
if Rails.env.production?
|
||||
'tps'
|
||||
else
|
||||
'tps-dev'
|
||||
end
|
||||
end
|
||||
def sous_domaine
|
||||
if Rails.env.production?
|
||||
'tps'
|
||||
else
|
||||
'tps-dev'
|
||||
end
|
||||
end
|
||||
|
||||
def next_step! role, action
|
||||
unless ['propose', 'reply', 'update', 'comment', 'confirme', 'depose', 'process'].include?(action)
|
||||
fail 'action is not valid'
|
||||
end
|
||||
def next_step! role, action
|
||||
unless ['propose', 'reply', 'update', 'comment', 'confirme', 'depose', 'process'].include?(action)
|
||||
fail 'action is not valid'
|
||||
end
|
||||
|
||||
unless ['user', 'gestionnaire'].include?(role)
|
||||
fail 'role is not valid'
|
||||
end
|
||||
unless ['user', 'gestionnaire'].include?(role)
|
||||
fail 'role is not valid'
|
||||
end
|
||||
|
||||
if role == 'user'
|
||||
case action
|
||||
when 'propose'
|
||||
if draft?
|
||||
proposed!
|
||||
end
|
||||
when 'depose'
|
||||
if confirmed?
|
||||
deposited!
|
||||
end
|
||||
when 'update'
|
||||
if reply?
|
||||
updated!
|
||||
end
|
||||
when 'comment'
|
||||
if reply?
|
||||
updated!
|
||||
end
|
||||
end
|
||||
elsif role == 'gestionnaire'
|
||||
case action
|
||||
when 'comment'
|
||||
if updated?
|
||||
reply!
|
||||
elsif proposed?
|
||||
reply!
|
||||
end
|
||||
when 'confirme'
|
||||
if updated?
|
||||
confirmed!
|
||||
elsif reply?
|
||||
confirmed!
|
||||
elsif proposed?
|
||||
confirmed!
|
||||
end
|
||||
when 'process'
|
||||
if deposited?
|
||||
processed!
|
||||
end
|
||||
end
|
||||
end
|
||||
state
|
||||
end
|
||||
if role == 'user'
|
||||
case action
|
||||
when 'propose'
|
||||
if draft?
|
||||
proposed!
|
||||
end
|
||||
when 'depose'
|
||||
if confirmed?
|
||||
deposited!
|
||||
end
|
||||
when 'update'
|
||||
if reply?
|
||||
updated!
|
||||
end
|
||||
when 'comment'
|
||||
if reply?
|
||||
updated!
|
||||
end
|
||||
end
|
||||
elsif role == 'gestionnaire'
|
||||
case action
|
||||
when 'comment'
|
||||
if updated?
|
||||
reply!
|
||||
elsif proposed?
|
||||
reply!
|
||||
end
|
||||
when 'confirme'
|
||||
if updated?
|
||||
confirmed!
|
||||
elsif reply?
|
||||
confirmed!
|
||||
elsif proposed?
|
||||
confirmed!
|
||||
end
|
||||
when 'process'
|
||||
if deposited?
|
||||
processed!
|
||||
end
|
||||
end
|
||||
end
|
||||
state
|
||||
end
|
||||
|
||||
private
|
||||
def self.a_traiter
|
||||
Dossier.where("state='proposed' OR state='updated' OR state='deposited'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
def build_default_cerfa
|
||||
build_cerfa
|
||||
true
|
||||
end
|
||||
def self.en_attente
|
||||
Dossier.where("state='reply' OR state='confirmed'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.termine
|
||||
Dossier.where("state='processed'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_default_cerfa
|
||||
build_cerfa
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue