commit
12d94b04d7
10 changed files with 42 additions and 24 deletions
|
@ -173,8 +173,6 @@ module Instructeurs
|
|||
if @commentaire.save
|
||||
@commentaire.dossier.update!(last_commentaire_updated_at: Time.zone.now)
|
||||
current_instructeur.follow(dossier)
|
||||
# FIXME
|
||||
mark_messagerie_as_read
|
||||
flash.notice = "Message envoyé"
|
||||
redirect_to messagerie_instructeur_dossier_path(procedure, dossier)
|
||||
else
|
||||
|
|
|
@ -169,6 +169,11 @@ module Instructeurs
|
|||
|
||||
export = Export.find_or_create_export(export_format, groupe_instructeurs)
|
||||
|
||||
if export.ready? && export.old? && params[:force_export]
|
||||
export.destroy
|
||||
export = Export.find_or_create_export(export_format, groupe_instructeurs)
|
||||
end
|
||||
|
||||
if export.ready?
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
# procedure_id :integer
|
||||
#
|
||||
class AssignTo < ApplicationRecord
|
||||
self.ignored_columns = [:procedure_id]
|
||||
|
||||
belongs_to :instructeur, optional: false
|
||||
belongs_to :groupe_instructeur, optional: false
|
||||
has_one :procedure_presentation, dependent: :destroy
|
||||
|
|
|
@ -9,13 +9,11 @@
|
|||
# email :string
|
||||
# introduction :text
|
||||
# revoked_at :datetime
|
||||
# tmp_expert_migrated :boolean default(FALSE)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# claimant_id :integer not null
|
||||
# dossier_id :integer
|
||||
# experts_procedure_id :bigint
|
||||
# instructeur_id :integer
|
||||
#
|
||||
class Avis < ApplicationRecord
|
||||
include EmailSanitizableConcern
|
||||
|
|
|
@ -489,8 +489,7 @@ class Dossier < ApplicationRecord
|
|||
else
|
||||
avis
|
||||
.where(confidentiel: false)
|
||||
.or(avis.where(claimant_id: instructeur.id, claimant_type: 'Instructeur'))
|
||||
.or(avis.where(instructeur: instructeur))
|
||||
.or(avis.where(claimant: instructeur))
|
||||
.order(created_at: :asc)
|
||||
end
|
||||
end
|
||||
|
@ -499,11 +498,9 @@ class Dossier < ApplicationRecord
|
|||
if expert.dossiers.include?(self)
|
||||
avis.order(created_at: :asc)
|
||||
else
|
||||
instructeur = expert.user.instructeur.id if expert.user.instructeur
|
||||
avis
|
||||
.where(confidentiel: false)
|
||||
.or(avis.where(claimant_id: expert.id, claimant_type: 'Expert', tmp_expert_migrated: true))
|
||||
.or(avis.where(claimant_id: instructeur, claimant_type: 'Instructeur', tmp_expert_migrated: false))
|
||||
.or(avis.where(claimant: expert))
|
||||
.order(created_at: :asc)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# updated_at :datetime not null
|
||||
#
|
||||
class Export < ApplicationRecord
|
||||
MAX_DUREE_CONSERVATION_EXPORT = 1.hour
|
||||
MAX_DUREE_CONSERVATION_EXPORT = 3.hours
|
||||
|
||||
enum format: {
|
||||
csv: 'csv',
|
||||
|
@ -45,6 +45,10 @@ class Export < ApplicationRecord
|
|||
file.attached?
|
||||
end
|
||||
|
||||
def old?
|
||||
updated_at < 20.minutes.ago
|
||||
end
|
||||
|
||||
def self.find_or_create_export(format, groupe_instructeurs)
|
||||
create_with(groupe_instructeurs: groupe_instructeurs)
|
||||
.create_or_find_by(format: format, key: generate_cache_key(groupe_instructeurs))
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
- [[xlsx_export, :xlsx], [ods_export, :ods], [csv_export, :csv]].each do |(export, format)|
|
||||
%li
|
||||
- if export.nil?
|
||||
- export_text = "Demander un export au format .#{format}"
|
||||
- if format == :csv
|
||||
- export_text = "Demander un export au format .#{format}<br/>(uniquement les dossiers, sans les champs répétables)".html_safe
|
||||
= link_to export_text, download_export_instructeur_procedure_path(procedure, export_format: format), remote: true
|
||||
= link_to t("#{format}_html", scope: [:instructeurs, :procedure, :export_stale]), download_export_instructeur_procedure_path(procedure, export_format: format), remote: true
|
||||
- elsif export.ready?
|
||||
= link_to "Télécharger l'export au format .#{format}", export.file.service_url, target: "_blank", rel: "noopener"
|
||||
= link_to t(:export_ready_html, export_time: time_ago_in_words(export.updated_at), export_format: ".#{format}", scope: [:instructeurs, :procedure]), export.file.service_url, target: "_blank", rel: "noopener"
|
||||
- if export.old?
|
||||
= button_to download_export_instructeur_procedure_path(procedure, export_format: format, force_export: true), class: "button small", style: "padding-right: 2px", title: t(:short, export_format: ".#{format}", scope: [:instructeurs, :procedure, :export_stale]), remote: true, method: :get, params: { export_format: format, force_export: true } do
|
||||
.icon.retry
|
||||
- else
|
||||
%span{ 'data-export-poll-url': download_export_instructeur_procedure_path(procedure, export_format: format, no_progress_notification: true) }
|
||||
= t(:export_pending_html, export_time: time_ago_in_words(export.created_at), export_format: ".#{format}", scope: [:instructeurs, :procedure])
|
||||
|
|
10
config/locales/views/instructeurs/fr.yml
Normal file
10
config/locales/views/instructeurs/fr.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
fr:
|
||||
instructeurs:
|
||||
procedure:
|
||||
export_stale:
|
||||
short: Demander un export au format %{export_format}
|
||||
csv_html: Demander un export au format .csv<br>(uniquement les dossiers, sans les champs répétables)
|
||||
xlsx_html: Demander un export au format .xlsx
|
||||
ods_html: Demander un export au format .ods
|
||||
export_ready_html: Télécharger l’export au format %{export_format}<br>(généré il y a %{export_time})
|
||||
export_pending_html: Un export au format %{export_format} est en train d’être généré<br>(demandé il y a %{export_time})
|
11
db/migrate/20210407174523_drop_unused_columns.rb
Normal file
11
db/migrate/20210407174523_drop_unused_columns.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class DropUnusedColumns < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
remove_column :avis, :instructeur_id
|
||||
remove_column :avis, :tmp_expert_migrated
|
||||
remove_column :etablissements, :entreprise_id
|
||||
remove_column :procedures, :archived_at
|
||||
remove_column :procedures, :csv_export_queued
|
||||
remove_column :procedures, :xlsx_export_queued
|
||||
remove_column :procedures, :ods_export_queued
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_04_02_163003) do
|
||||
ActiveRecord::Schema.define(version: 2021_04_07_174523) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -121,7 +121,6 @@ ActiveRecord::Schema.define(version: 2021_04_02_163003) do
|
|||
t.string "email"
|
||||
t.text "introduction"
|
||||
t.text "answer"
|
||||
t.integer "instructeur_id"
|
||||
t.integer "dossier_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
|
@ -130,11 +129,9 @@ ActiveRecord::Schema.define(version: 2021_04_02_163003) do
|
|||
t.datetime "revoked_at"
|
||||
t.bigint "experts_procedure_id"
|
||||
t.string "claimant_type"
|
||||
t.boolean "tmp_expert_migrated", default: false
|
||||
t.index ["claimant_id"], name: "index_avis_on_claimant_id"
|
||||
t.index ["dossier_id"], name: "index_avis_on_dossier_id"
|
||||
t.index ["experts_procedure_id"], name: "index_avis_on_experts_procedure_id"
|
||||
t.index ["instructeur_id"], name: "index_avis_on_instructeur_id"
|
||||
end
|
||||
|
||||
create_table "bill_signatures", force: :cascade do |t|
|
||||
|
@ -291,7 +288,6 @@ ActiveRecord::Schema.define(version: 2021_04_02_163003) do
|
|||
t.string "localite"
|
||||
t.string "code_insee_localite"
|
||||
t.integer "dossier_id"
|
||||
t.integer "entreprise_id"
|
||||
t.string "entreprise_siren"
|
||||
t.bigint "entreprise_capital_social"
|
||||
t.string "entreprise_numero_tva_intracommunautaire"
|
||||
|
@ -532,7 +528,6 @@ ActiveRecord::Schema.define(version: 2021_04_02_163003) do
|
|||
t.date "auto_archive_on"
|
||||
t.datetime "published_at"
|
||||
t.datetime "hidden_at"
|
||||
t.datetime "archived_at"
|
||||
t.datetime "whitelisted_at"
|
||||
t.boolean "ask_birthday", default: false, null: false
|
||||
t.string "web_hook_url"
|
||||
|
@ -550,9 +545,6 @@ ActiveRecord::Schema.define(version: 2021_04_02_163003) do
|
|||
t.string "declarative_with_state"
|
||||
t.text "monavis_embed"
|
||||
t.text "routing_criteria_name", default: "Votre ville"
|
||||
t.boolean "csv_export_queued"
|
||||
t.boolean "xlsx_export_queued"
|
||||
t.boolean "ods_export_queued"
|
||||
t.datetime "closed_at"
|
||||
t.datetime "unpublished_at"
|
||||
t.bigint "canonical_procedure_id"
|
||||
|
|
Loading…
Reference in a new issue