Merge branch 'develop' into staging

This commit is contained in:
Mathieu Magnin 2017-02-20 14:54:52 +01:00
commit 44d716de11
9 changed files with 126 additions and 71 deletions

View file

@ -0,0 +1,21 @@
$default-spacer: 15px;
.m-1 {
margin: $default-spacer;
}
.mt-1 {
margin-top: $default-spacer;
}
.mr-1 {
margin-right: $default-spacer;
}
.mb-1 {
margin-bottom: $default-spacer;
}
.ml-1 {
margin-left: $default-spacer;
}

View file

@ -3,7 +3,6 @@ class Admin::ProceduresController < AdminController
helper SmartListing::Helper
before_action :retrieve_procedure, only: [:show, :edit]
before_action :procedure_locked?, only: [:edit]
def index
@procedures = smart_listing_create :procedures,
@ -61,7 +60,7 @@ class Admin::ProceduresController < AdminController
end
def create
@procedure = Procedure.new(create_procedure_params)
@procedure = Procedure.new(procedure_params)
@procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params) if @procedure.valid?
unless @procedure.save
@ -76,7 +75,7 @@ class Admin::ProceduresController < AdminController
def update
@procedure = current_administrateur.procedures.find(params[:id])
unless @procedure.update_attributes(create_procedure_params)
unless @procedure.update_attributes(procedure_params)
flash.now.alert = @procedure.errors.full_messages.join('<br />').html_safe
return render 'edit'
end
@ -192,8 +191,12 @@ class Admin::ProceduresController < AdminController
private
def create_procedure_params
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :lien_site_web, :lien_notice, :euro_flag, :logo, :cerfa_flag, :for_individual, :individual_with_siret, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
def procedure_params
if @procedure.try(:locked?)
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_site_web, :lien_notice, :euro_flag, :logo)
else
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_site_web, :lien_notice, :euro_flag, :logo, :lien_demarche, :cerfa_flag, :for_individual, :individual_with_siret, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
end
end
def create_module_api_carto_params

View file

@ -11,9 +11,17 @@ class ProcedureDecorator < Draper::Decorator
end
def logo_img
return h.image_url(LOGO_NAME) if logo.blank?
File.join(STORAGE_URL, File.basename(logo.path))
if logo.blank?
h.image_url(LOGO_NAME)
else
if Features.remote_storage
(RemoteDownloader.new logo.filename).url
else
(LocalDownloader.new logo.path, 'logo').url
end
end
end
def geographic_information
module_api_carto
end

View file

@ -23,9 +23,6 @@
%tr
%td.center
%b.text-success
= raw "--#{balise.first}--"
-# \--
-# = balise.first
-# \--
= "--#{balise.first}--"
%td
=balise.second[:description]

View file

@ -1,3 +1,8 @@
- if @procedure.locked?
.alert.alert-info
Cette procédure est publiée, certains éléments de la description ne sont plus modifiables
-{libelle: 'Libellé*', description: 'Description*', organisation: 'Organisation', direction: 'Direction', lien_site_web: 'Lien site internet', lien_notice: 'Lien notice'}.each do |key, value|
.form-group
%h4
@ -9,69 +14,69 @@
= f.text_field key, class: 'form-control', placeholder: value
.row
.col-xs-6
.col-md-6
%h4 Logo de la procédure
- unless @procedure.logo.blank?
= image_tag @procedure.decorate.logo_img, {style: 'height: 40px; display: inline; margin-right: 6px', id: 'preview_procedure_logo'}
= f.file_field(:logo, accept: 'image/png, image/jpg, image/jpeg', style: 'display:inline')
= f.file_field :logo, accept: 'image/png, image/jpg, image/jpeg', style: 'display:inline'
%div{style:'margin-top:5px'}
%i
Fichier accepté : JPG / JPEG / PNG
.col-xs-6
.col-md-6
%h4 Drapeau européen
.checkbox
%label
=f.check_box :euro_flag
Afficher le drapeau européen
.row
.col-xs-6
%h4 Cartographie
- unless @procedure.locked?
.row
.col-md-6
%h4 Cartographie
= f.fields_for :module_api_carto, @procedure.module_api_carto do |ff|
.checkbox
%label
=ff.check_box :use_api_carto, {id: :procedure_module_api_carto_use_api_carto}
Utilisation de la cartographie
%ul#modules_api_carto
%li
.checkbox
%label
= ff.check_box :quartiers_prioritaires
Quartiers Prioritaires
%li
.checkbox
%label
= ff.check_box :cadastre
Cadastre
.col-xs-6
- if @procedure.cerfa_flag
%h4 Formulaire de demande ou CERFA
.checkbox
%label
=f.check_box :cerfa_flag
Activer l'envoi de formulaire de demande ou CERFA
=f.text_field :lien_demarche, class: 'form-control', placeholder: 'URL vers le formulaire vierge (facultatif)'
.row
.col-xs-6
%h4 Particuliers
%ul.list-unstyled
%li
= f.fields_for :module_api_carto, @procedure.module_api_carto do |ff|
.checkbox
%label
=f.check_box :for_individual
Cette procédure s'adresse à un public qui
%b
ne possède pas (ou pas encore) de numéro SIRET,
qui doit donc s'identifier en tant que personne physique.
=ff.check_box :use_api_carto, id: :procedure_module_api_carto_use_api_carto
Utilisation de la cartographie
%ul.list-unstyled#individual_with_siret{style:'margin-left: 15px'}
%ul#modules_api_carto
%li
.checkbox
%label
=f.check_box :individual_with_siret
Donner la possibilité de renseigner un SIRET au cours de la construction du dossier.
= ff.check_box :quartiers_prioritaires
Quartiers Prioritaires
%li
.checkbox
%label
= ff.check_box :cadastre
Cadastre
.col-md-6
- if @procedure.cerfa_flag
%h4 Formulaire de demande ou CERFA
.checkbox
%label
= f.check_box :cerfa_flag
Activer l'envoi de formulaire de demande ou CERFA
%br
= f.text_field :lien_demarche, class: 'form-control', placeholder: 'URL vers le formulaire vierge (facultatif)'
.row
.col-md-6
%h4 Particuliers
.checkbox
%label
=f.check_box :for_individual
Cette procédure s'adresse à un public qui
%b
ne possède pas (ou pas encore) de numéro SIRET,
qui doivent donc s'identifier en tant que personne physique.
%ul#individual_with_siret
%li
.checkbox
%label
= f.check_box :individual_with_siret
Donner la possibilité de renseigner un SIRET au cours de la construction du dossier.

View file

@ -2,6 +2,5 @@
#procedure_new.section.section-label
= form_for @procedure, url: url_for({controller: 'admin/procedures', action: :update, id: @procedure.id}), multipart: true do |f|
= render partial: 'informations', locals: {f: f}
.text-right
= f.submit 'Editer', class: 'btn btn-success'
= f.submit 'Enregistrer', class: 'btn btn-success'

View file

@ -19,10 +19,9 @@
%div.procedure_list_element{class: ('active' if active == 'Accompagnateurs')}
=t('dynamics.admin.procedure.onglets.accompagnateurs')
- unless @procedure.locked?
%a{:href => "#{url_for edit_admin_procedure_path(@procedure)}", id: 'onglet-description'}
%div.procedure_list_element{class: ('active' if active == 'Description')}
Description
%a{:href => "#{url_for edit_admin_procedure_path(@procedure)}", id: 'onglet-description'}
%div.procedure_list_element{class: ('active' if active == 'Description')}
Description
- unless @procedure.locked?
%a{:href => "#{url_for admin_procedure_types_de_champ_path(@procedure)}", id: 'onglet-champs'}

View file

@ -13,6 +13,7 @@ describe Admin::ProceduresController, type: :controller do
let(:use_api_carto) { '0' }
let(:quartiers_prioritaires) { '0' }
let(:cadastre) { '0' }
let(:cerfa_flag) { true }
let(:procedure_params) {
{
@ -21,6 +22,7 @@ describe Admin::ProceduresController, type: :controller do
organisation: organisation,
direction: direction,
lien_demarche: lien_demarche,
cerfa_flag: cerfa_flag,
module_api_carto_attributes: {
use_api_carto: use_api_carto,
quartiers_prioritaires: quartiers_prioritaires,
@ -105,24 +107,24 @@ describe Admin::ProceduresController, type: :controller do
sign_out admin
end
it { expect(subject).to redirect_to new_user_session_path }
it { is_expected.to redirect_to new_user_session_path }
end
context 'when user is connected' do
context 'when procedure exist' do
let(:procedure_id) { procedure.id }
it { expect(subject).to have_http_status(:success) }
it { is_expected.to have_http_status(:success) }
end
context 'when procedure is published' do
let(:published) { true }
it { is_expected.to redirect_to admin_procedure_path id: procedure_id }
it { is_expected.to have_http_status(:success) }
end
context "when procedure doesn't exist" do
let(:procedure_id) { bad_procedure_id }
it { expect(subject).to have_http_status(404) }
it { is_expected.to have_http_status(404) }
end
end
end
@ -164,7 +166,7 @@ describe Admin::ProceduresController, type: :controller do
it { expect(subject.quartiers_prioritaires).to be_truthy }
end
it { expect(subject).to redirect_to(admin_procedure_types_de_champ_path(procedure_id: Procedure.last.id)) }
it { is_expected.to redirect_to(admin_procedure_types_de_champ_path(procedure_id: Procedure.last.id)) }
it { expect(flash[:notice]).to be_present }
end
@ -204,7 +206,7 @@ describe Admin::ProceduresController, type: :controller do
subject { put :update, params: {id: procedure.id} }
it { expect(subject).to redirect_to new_user_session_path }
it { is_expected.to redirect_to new_user_session_path }
end
context 'when administrateur is connected' do
@ -213,7 +215,7 @@ describe Admin::ProceduresController, type: :controller do
procedure.reload
end
context 'when all attributs are informated' do
context 'when all attributs are present' do
let(:libelle) { 'Blable' }
let(:description) { 'blabla' }
let(:organisation) { 'plop' }
@ -240,7 +242,7 @@ describe Admin::ProceduresController, type: :controller do
it { expect(subject.cadastre).to be_truthy }
end
it { expect(subject).to redirect_to(edit_admin_procedure_path id: procedure.id) }
it { is_expected.to redirect_to(edit_admin_procedure_path id: procedure.id) }
it { expect(flash[:notice]).to be_present }
end
@ -260,6 +262,26 @@ describe Admin::ProceduresController, type: :controller do
it { expect(subject.cadastre).to be_falsey }
end
end
context 'when procedure is published' do
let!(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, :published, administrateur: admin) }
describe 'only some properties can be updated' do
subject { procedure }
it { expect(subject.libelle).to eq procedure_params[:libelle] }
it { expect(subject.description).to eq procedure_params[:description] }
it { expect(subject.organisation).to eq procedure_params[:organisation] }
it { expect(subject.direction).to eq procedure_params[:direction] }
it { expect(subject.cerfa_flag).not_to eq procedure_params[:cerfa_flag] }
it { expect(subject.lien_demarche).not_to eq procedure_params[:lien_demarche] }
it { expect(subject.for_individual).not_to eq procedure_params[:for_individual] }
it { expect(subject.individual_with_siret).not_to eq procedure_params[:individual_with_siret] }
it { expect(subject.use_api_carto).not_to eq procedure_params[:module_api_carto_attributes][:use_api_carto] }
end
end
end
end

View file

@ -7,6 +7,7 @@ FactoryGirl.define do
organisation "Orga SGMAP"
direction "direction SGMAP"
published false
cerfa_flag false
administrateur { create(:administrateur) }
mail_templates { [create(:mail_template, :dossier_received)]}