Merge branch 'dev'
This commit is contained in:
commit
0ee0f135f7
10 changed files with 30 additions and 8 deletions
Binary file not shown.
Before Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB |
|
@ -13,7 +13,7 @@ class API::V1::DossiersController < APIController
|
||||||
error code: 404, desc: "Procédure inconnue"
|
error code: 404, desc: "Procédure inconnue"
|
||||||
|
|
||||||
def index
|
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)
|
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
|
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"
|
error code: 404, desc: "Procédure ou dossier inconnu"
|
||||||
|
|
||||||
def show
|
def show
|
||||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
procedure = administrateur.procedures.find(params[:procedure_id])
|
||||||
dossier = procedure.dossiers.find(params[:id])
|
dossier = procedure.dossiers.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class API::V1::ProceduresController < APIController
|
||||||
error code: 404, desc: "Procédure inconnue"
|
error code: 404, desc: "Procédure inconnue"
|
||||||
|
|
||||||
def show
|
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 }
|
render json: { procedure: ProcedureSerializer.new(procedure).as_json }
|
||||||
rescue ActiveRecord::RecordNotFound => e
|
rescue ActiveRecord::RecordNotFound => e
|
||||||
|
|
|
@ -19,10 +19,10 @@ class APIController < ApplicationController
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def valid_token?
|
def valid_token?
|
||||||
current_administrateur.present?
|
administrateur.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_administrateur
|
def administrateur
|
||||||
@administrateur ||= (authenticate_with_bearer_token || authenticate_with_param_token)
|
@administrateur ||= (authenticate_with_bearer_token || authenticate_with_param_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ module NewGestionnaire
|
||||||
|
|
||||||
def download_dossiers
|
def download_dossiers
|
||||||
export = procedure.generate_export
|
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|
|
respond_to do |format|
|
||||||
format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: "#{filename}.csv") }
|
format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: "#{filename}.csv") }
|
||||||
|
|
|
@ -157,6 +157,11 @@ class Procedure < ApplicationRecord
|
||||||
self.dossiers.state_not_brouillon.size
|
self.dossiers.state_not_brouillon.size
|
||||||
end
|
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
|
def generate_export
|
||||||
exportable_dossiers = dossiers.downloadable_sorted
|
exportable_dossiers = dossiers.downloadable_sorted
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Un nouvel administrateur a été créé sur demarches-simplifiees.fr.
|
Un nouvel administrateur a été créé sur demarches-simplifiees.fr.
|
||||||
|
|
||||||
Plateforme : <%= TPS::Application::URL %>
|
Plateforme : <%= root_url %>
|
||||||
|
|
||||||
Login : <%= @admin.email %>
|
Login : <%= @admin.email %>
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,6 @@ set :shared_paths, [
|
||||||
'config/initializers/features.yml',
|
'config/initializers/features.yml',
|
||||||
"config/environments/#{rails_env}.rb",
|
"config/environments/#{rails_env}.rb",
|
||||||
"config/initializers/token.rb",
|
"config/initializers/token.rb",
|
||||||
"config/initializers/super_admin.rb",
|
|
||||||
"config/unicorn.rb",
|
"config/unicorn.rb",
|
||||||
"config/initializers/raven.rb",
|
"config/initializers/raven.rb",
|
||||||
'config/france_connect.yml',
|
'config/france_connect.yml',
|
||||||
|
|
|
@ -494,4 +494,22 @@ describe Procedure do
|
||||||
describe ".default_sort" do
|
describe ".default_sort" do
|
||||||
it { expect(Procedure.default_sort).to eq("{\"table\":\"self\",\"column\":\"id\",\"order\":\"desc\"}") }
|
it { expect(Procedure.default_sort).to eq("{\"table\":\"self\",\"column\":\"id\",\"order\":\"desc\"}") }
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue