add service to create procedure archive
This commit is contained in:
parent
fba0d78153
commit
07cc4fa97f
6 changed files with 182 additions and 1 deletions
|
@ -48,4 +48,12 @@ class Archive < ApplicationRecord
|
|||
def available?
|
||||
status == 'generated' && file.attached?
|
||||
end
|
||||
|
||||
def filename(procedure)
|
||||
if content_type == 'everything'
|
||||
"procedure-#{procedure.id}.zip"
|
||||
else
|
||||
"procedure-#{procedure.id}-mois-#{I18n.l(month, format: '%Y-%m')}.zip"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -172,7 +172,12 @@ class Dossier < ApplicationRecord
|
|||
scope :en_construction, -> { not_archived.state_en_construction }
|
||||
scope :en_instruction, -> { not_archived.state_en_instruction }
|
||||
scope :termine, -> { not_archived.state_termine }
|
||||
scope :downloadable_sorted, -> {
|
||||
scope :processed_in_month, -> (month) do
|
||||
state_termine
|
||||
.joins(:traitements)
|
||||
.where(traitements: { processed_at: month.beginning_of_month..month.end_of_month })
|
||||
end
|
||||
scope :downloadable_sorted, -> {
|
||||
state_not_brouillon
|
||||
.includes(
|
||||
:user,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue