diff --git a/app/assets/images/franceconnect_logo.png b/app/assets/images/franceconnect_logo.png deleted file mode 100644 index c1a8ce071..000000000 Binary files a/app/assets/images/franceconnect_logo.png and /dev/null differ diff --git a/app/assets/images/logo_FC_02_small.png b/app/assets/images/logo_FC_02_small.png deleted file mode 100644 index 944de73ce..000000000 Binary files a/app/assets/images/logo_FC_02_small.png and /dev/null differ diff --git a/app/controllers/api/v1/dossiers_controller.rb b/app/controllers/api/v1/dossiers_controller.rb index b275f41b2..a446570da 100644 --- a/app/controllers/api/v1/dossiers_controller.rb +++ b/app/controllers/api/v1/dossiers_controller.rb @@ -13,7 +13,7 @@ class API::V1::DossiersController < APIController error code: 404, desc: "Procédure inconnue" def index - procedure = current_administrateur.procedures.find(params[:procedure_id]) + procedure = administrateur.procedures.find(params[:procedure_id]) dossiers = procedure.dossiers.state_not_brouillon.page(params[:page]).per(per_page) render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200 @@ -28,7 +28,7 @@ class API::V1::DossiersController < APIController error code: 404, desc: "Procédure ou dossier inconnu" def show - procedure = current_administrateur.procedures.find(params[:procedure_id]) + procedure = administrateur.procedures.find(params[:procedure_id]) dossier = procedure.dossiers.find(params[:id]) respond_to do |format| diff --git a/app/controllers/api/v1/procedures_controller.rb b/app/controllers/api/v1/procedures_controller.rb index f983b9d21..54cf5c94c 100644 --- a/app/controllers/api/v1/procedures_controller.rb +++ b/app/controllers/api/v1/procedures_controller.rb @@ -9,7 +9,7 @@ class API::V1::ProceduresController < APIController error code: 404, desc: "Procédure inconnue" def show - procedure = current_administrateur.procedures.find(params[:id]).decorate + procedure = administrateur.procedures.find(params[:id]).decorate render json: { procedure: ProcedureSerializer.new(procedure).as_json } rescue ActiveRecord::RecordNotFound => e diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index d1ab966a5..e387c3b69 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -19,10 +19,10 @@ class APIController < ApplicationController protected def valid_token? - current_administrateur.present? + administrateur.present? end - def current_administrateur + def administrateur @administrateur ||= (authenticate_with_bearer_token || authenticate_with_param_token) end diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index aefe3fa26..dad304e23 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -175,7 +175,7 @@ module NewGestionnaire def download_dossiers export = procedure.generate_export - filename = "dossiers_#{procedure.procedure_path.path}_#{Time.now.strftime('%Y-%m-%d_%H-%M')}" + filename = procedure.export_filename respond_to do |format| format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: "#{filename}.csv") } diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 436a43a7c..daddb0ab7 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -157,6 +157,11 @@ class Procedure < ApplicationRecord self.dossiers.state_not_brouillon.size end + def export_filename + procedure_identifier = procedure_path&.path || "procedure-#{id}" + "dossiers_#{procedure_identifier}_#{Time.now.strftime('%Y-%m-%d_%H-%M')}" + end + def generate_export exportable_dossiers = dossiers.downloadable_sorted diff --git a/app/views/administration_mailer/new_admin_email.text.erb b/app/views/administration_mailer/new_admin_email.text.erb index fc244079a..0cac8ecfd 100644 --- a/app/views/administration_mailer/new_admin_email.text.erb +++ b/app/views/administration_mailer/new_admin_email.text.erb @@ -1,6 +1,6 @@ Un nouvel administrateur a été créé sur demarches-simplifiees.fr. -Plateforme : <%= TPS::Application::URL %> +Plateforme : <%= root_url %> Login : <%= @admin.email %> diff --git a/config/deploy.rb b/config/deploy.rb index fdd424f79..63920ad5b 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -61,7 +61,6 @@ set :shared_paths, [ 'config/initializers/features.yml', "config/environments/#{rails_env}.rb", "config/initializers/token.rb", - "config/initializers/super_admin.rb", "config/unicorn.rb", "config/initializers/raven.rb", 'config/france_connect.yml', diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 72bfbe1c7..26605cdda 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -494,4 +494,22 @@ describe Procedure do describe ".default_sort" do it { expect(Procedure.default_sort).to eq("{\"table\":\"self\",\"column\":\"id\",\"order\":\"desc\"}") } end + + describe ".export_filename" do + before { Timecop.freeze(Time.new(2018, 1, 2, 23, 11, 14)) } + + subject { procedure.export_filename } + + context "with a path" do + let(:procedure) { create(:procedure, :published) } + + it { is_expected.to eq("dossiers_#{procedure.procedure_path.path}_2018-01-02_23-11") } + end + + context "without a path" do + let(:procedure) { create(:procedure) } + + it { is_expected.to eq("dossiers_procedure-#{procedure.id}_2018-01-02_23-11") } + end + end end