commit
9d174cdc3d
24 changed files with 221 additions and 25 deletions
1
app/assets/images/icons/new-folder.svg
Normal file
1
app/assets/images/icons/new-folder.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><g fill="none" fill-rule="evenodd"><path d="M11 6L9 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-6" stroke="#0069cc" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M0 0h24v24H0z"/></g><g transform="translate(8 -8)" fill="#0069cc"><rect ry="1" y="12" x="6" height="2" width="10"/><rect width="2" height="10" x="10" y="8" ry="1"/></g></svg>
|
After Width: | Height: | Size: 446 B |
|
@ -137,6 +137,8 @@
|
|||
position: relative;
|
||||
|
||||
.dropdown-button {
|
||||
white-space: nowrap;
|
||||
|
||||
&::after {
|
||||
content: "▾";
|
||||
margin-left: $default-spacer;
|
||||
|
@ -199,7 +201,7 @@
|
|||
.dropdown-items {
|
||||
li {
|
||||
display: flex;
|
||||
padding: 2 * $default-spacer;
|
||||
padding: $default-padding;
|
||||
color: $grey;
|
||||
border-bottom: 1px solid $border-grey;
|
||||
font-size: 12px;
|
||||
|
@ -219,15 +221,37 @@
|
|||
background: $light-grey;
|
||||
}
|
||||
|
||||
&.danger {
|
||||
&:hover {
|
||||
background-color: $medium-red;
|
||||
|
||||
&,
|
||||
a {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
.icon {
|
||||
filter: contrast(0) brightness(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
a {
|
||||
display: flex;
|
||||
color: $grey;
|
||||
}
|
||||
|
||||
// Make child links fill the whole clickable area
|
||||
> a {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
margin: -$default-padding;
|
||||
padding: $default-padding;
|
||||
}
|
||||
|
||||
.icon {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
|
|
@ -79,8 +79,4 @@
|
|||
.follow-col {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.delete-col {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
background-image: image-url("icons/folder.svg");
|
||||
}
|
||||
|
||||
&.new-folder {
|
||||
background-image: image-url("icons/new-folder.svg");
|
||||
}
|
||||
|
||||
&.accept {
|
||||
background-image: image-url("icons/accept.svg");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
.user-dossier-actions {
|
||||
.dropdown-description {
|
||||
font-size: 14px;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
|
@ -269,7 +269,7 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def procedure_params
|
||||
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :euro_flag, :logo, :auto_archive_on]
|
||||
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :expects_multiple_submissions, :web_hook_url, :euro_flag, :logo, :auto_archive_on]
|
||||
if @procedure&.locked?
|
||||
params.require(:procedure).permit(*editable_params)
|
||||
else
|
||||
|
|
|
@ -134,7 +134,7 @@ module Gestionnaires
|
|||
end
|
||||
|
||||
def avis_params
|
||||
params.require(:avis).permit(:answer)
|
||||
params.require(:avis).permit(:answer, :piece_justificative_file)
|
||||
end
|
||||
|
||||
def commentaire_params
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
class Avis < ApplicationRecord
|
||||
include EmailSanitizableConcern
|
||||
include VirusScanConcern
|
||||
|
||||
belongs_to :dossier, touch: true
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :claimant, class_name: 'Gestionnaire'
|
||||
|
||||
has_one_attached :piece_justificative_file
|
||||
|
||||
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
|
||||
validates :claimant, presence: true
|
||||
|
||||
|
@ -19,6 +22,9 @@ class Avis < ApplicationRecord
|
|||
scope :by_latest, -> { order(updated_at: :desc) }
|
||||
scope :updated_since?, -> (date) { where('avis.updated_at > ?', date) }
|
||||
|
||||
after_commit :create_avis_virus_scan
|
||||
after_initialize { add_virus_scan_on(self.piece_justificative_file) }
|
||||
|
||||
# The form allows subtmitting avis requests to several emails at once,
|
||||
# hence this virtual attribute.
|
||||
attr_accessor :emails
|
||||
|
@ -48,4 +54,8 @@ class Avis < ApplicationRecord
|
|||
self.email = nil
|
||||
end
|
||||
end
|
||||
|
||||
def create_avis_virus_scan
|
||||
create_virus_scan(self.piece_justificative_file)
|
||||
end
|
||||
end
|
||||
|
|
21
app/models/concerns/virus_scan_concern.rb
Normal file
21
app/models/concerns/virus_scan_concern.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module VirusScanConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
attr_reader :attachment_attribute
|
||||
|
||||
def add_virus_scan_on(piece_justificative)
|
||||
@attachment_attribute = piece_justificative
|
||||
end
|
||||
|
||||
def virus_scan
|
||||
VirusScan.find_by(blob_key: self.attachment_attribute.blob.key)
|
||||
end
|
||||
|
||||
def create_virus_scan(piece_justificative)
|
||||
if piece_justificative&.attachment&.blob.present?
|
||||
VirusScan.find_or_create_by!(blob_key: piece_justificative.blob.key) do |virus_scan|
|
||||
virus_scan.status = VirusScan.statuses.fetch(:pending)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -123,6 +123,10 @@ class Procedure < ApplicationRecord
|
|||
publiee_ou_archivee?
|
||||
end
|
||||
|
||||
def accepts_new_dossiers?
|
||||
!archivee?
|
||||
end
|
||||
|
||||
# This method is needed for transition. Eventually this will be the same as brouillon?.
|
||||
def brouillon_avec_lien?
|
||||
brouillon? && path.present?
|
||||
|
|
|
@ -17,6 +17,11 @@ class CarrierwaveActiveStorageMigrationService
|
|||
def active_storage_openstack_client!
|
||||
service = ActiveStorage::Blob.service
|
||||
|
||||
if defined?(ActiveStorage::Service::DsProxyService) &&
|
||||
service.is_a?(ActiveStorage::Service::DsProxyService)
|
||||
service = service.wrapped
|
||||
end
|
||||
|
||||
if !defined?(ActiveStorage::Service::OpenStackService) ||
|
||||
!service.is_a?(ActiveStorage::Service::OpenStackService)
|
||||
raise StandardError, 'ActiveStorage must be backed by OpenStack'
|
||||
|
|
|
@ -116,6 +116,15 @@
|
|||
.col-md-6
|
||||
%h4 Options avancées
|
||||
|
||||
= f.label :expects_multiple_submissions do
|
||||
= f.check_box :expects_multiple_submissions
|
||||
Ajuster pour le dépôt récurrent de dossiers
|
||||
%p.help-block
|
||||
%i.fa.fa-info-circle
|
||||
Si cette démarche est conçue pour qu’une même personne y dépose régulièrement plusieurs
|
||||
dossiers, l’interface est ajustée pour rendre plus facile la création de plusieurs dossiers
|
||||
à la suite.
|
||||
|
||||
- if Flipflop.web_hook?
|
||||
%label{ for: :web_hook_url } Lien de rappel HTTP (webhook)
|
||||
= f.text_field :web_hook_url, class: 'form-control', placeholder: 'https://callback.exemple.fr/'
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
= form_for @avis, url: gestionnaire_avis_path(@avis), html: { class: 'form' } do |f|
|
||||
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
||||
= render partial: "shared/piece_jointe/pj_upload_field", locals: { pj: @avis.piece_justificative_file, object: @avis, form: f }
|
||||
|
||||
.flex.justify-between.align-baseline
|
||||
%p.confidentiel.flex
|
||||
- if @avis.confidentiel?
|
||||
|
|
|
@ -28,4 +28,5 @@
|
|||
Réponse donnée le #{l(avis.updated_at, format: '%d/%m/%y à %H:%M')}
|
||||
- else
|
||||
%span.waiting En attente de réponse
|
||||
= render partial: 'shared/piece_jointe/pj_link', locals: { object: avis, pj: avis.piece_justificative_file }
|
||||
%p= avis.answer
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
%span.icon.archive
|
||||
%span.icon.unarchive
|
||||
%span.icon.folder
|
||||
%span.icon.new-folder
|
||||
%span.icon.accept
|
||||
%span.icon.refuse
|
||||
%span.icon.without-continuation
|
||||
|
|
20
app/views/shared/piece_jointe/_pj_link.html.haml
Normal file
20
app/views/shared/piece_jointe/_pj_link.html.haml
Normal file
|
@ -0,0 +1,20 @@
|
|||
- if pj.attached?
|
||||
.pj-link
|
||||
- if object.virus_scan.blank? || object.virus_scan.safe?
|
||||
= link_to url_for(pj), target: '_blank', title: "Télécharger la pièce jointe" do
|
||||
%span.icon.attachment
|
||||
= pj.filename.to_s
|
||||
- if object.virus_scan.blank?
|
||||
(ce fichier n’a pas été analysé par notre antivirus, téléchargez-le avec précaution)
|
||||
|
||||
- else
|
||||
= pj.filename.to_s
|
||||
- if object.virus_scan.pending?
|
||||
(analyse antivirus en cours
|
||||
= link_to "rafraichir", request.path
|
||||
)
|
||||
- elsif object.virus_scan.infected?
|
||||
- if user_can_upload
|
||||
(virus détecté, merci d’envoyer un autre fichier)
|
||||
- else
|
||||
(virus détecté, le téléchargement de ce fichier est bloqué)
|
12
app/views/shared/piece_jointe/_pj_upload_field.haml
Normal file
12
app/views/shared/piece_jointe/_pj_upload_field.haml
Normal file
|
@ -0,0 +1,12 @@
|
|||
.piece-justificative
|
||||
- if pj.attached?
|
||||
.piece-justificative-actions{ id: "piece_justificative_#{object.id}" }
|
||||
.piece-justificative-action
|
||||
= render partial: "shared/piece_jointe/pj_link", locals: { object: object, pj: object.piece_justificative_file, user_can_upload: true }
|
||||
.piece-justificative-action
|
||||
= button_tag 'Remplacer', type: 'button', class: 'button small', data: { 'toggle-target': "#champs_#{object.id}" }
|
||||
|
||||
= form.file_field :piece_justificative_file,
|
||||
id: "champs_#{object.id}",
|
||||
class: "piece-justificative-input #{'hidden' if pj.attached?}",
|
||||
direct_upload: true
|
24
app/views/users/dossiers/_dossier_actions.html.haml
Normal file
24
app/views/users/dossiers/_dossier_actions.html.haml
Normal file
|
@ -0,0 +1,24 @@
|
|||
- has_delete_action = dossier.can_be_deleted_by_user?
|
||||
- has_new_dossier_action = dossier.procedure.expects_multiple_submissions? && dossier.procedure.accepts_new_dossiers?
|
||||
|
||||
- has_actions = has_delete_action || has_new_dossier_action
|
||||
|
||||
- if has_actions
|
||||
%span.dropdown.user-dossier-actions
|
||||
%button.button.dropdown-button
|
||||
Actions
|
||||
.dropdown-content.fade-in-down
|
||||
%ul.dropdown-items
|
||||
- if has_new_dossier_action
|
||||
%li
|
||||
= link_to procedure_lien(dossier.procedure) do
|
||||
%span.icon.new-folder
|
||||
.dropdown-description
|
||||
Commencer un autre dossier
|
||||
|
||||
- if has_delete_action
|
||||
%li.danger
|
||||
= link_to ask_deletion_dossier_path(dossier), method: :post, data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" } do
|
||||
%span.icon.delete
|
||||
.dropdown-description
|
||||
Supprimer le dossier
|
|
@ -32,7 +32,7 @@
|
|||
%th
|
||||
%tbody
|
||||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
%tr{ data: { 'dossier-id': dossier.id } }
|
||||
%td.folder-col
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
%span.icon.folder
|
||||
|
@ -48,11 +48,8 @@
|
|||
%td.updated-at-col
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
= dossier.updated_at.strftime("%d/%m/%Y")
|
||||
%td.action-col.delete-col
|
||||
- if dossier.can_be_deleted_by_user?
|
||||
= link_to(ask_deletion_dossier_path(dossier), method: :post, class: 'button danger', data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" }) do
|
||||
%span.icon.delete
|
||||
Supprimer
|
||||
%td.action-col.action-col
|
||||
= render partial: 'dossier_actions', locals: { dossier: dossier }
|
||||
= paginate(@dossiers)
|
||||
|
||||
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddExpectsMultipleSubmissionsColumnToProcedure < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :procedures, :expects_multiple_submissions, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_03_18_154812) do
|
||||
ActiveRecord::Schema.define(version: 2019_03_27_102357) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -478,6 +478,7 @@ ActiveRecord::Schema.define(version: 2019_03_18_154812) do
|
|||
t.boolean "juridique_required", default: true
|
||||
t.boolean "durees_conservation_required", default: true
|
||||
t.string "path"
|
||||
t.boolean "expects_multiple_submissions", default: false, null: false
|
||||
t.index ["hidden_at"], name: "index_procedures_on_hidden_at"
|
||||
t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id"
|
||||
t.index ["service_id"], name: "index_procedures_on_service_id"
|
||||
|
|
|
@ -53,6 +53,7 @@ describe Gestionnaires::AvisController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#update' do
|
||||
describe 'without attachment' do
|
||||
before do
|
||||
patch :update, params: { id: avis_without_answer.id, avis: { answer: 'answer' } }
|
||||
avis_without_answer.reload
|
||||
|
@ -60,8 +61,23 @@ describe Gestionnaires::AvisController, type: :controller do
|
|||
|
||||
it { expect(response).to redirect_to(instruction_gestionnaire_avis_path(avis_without_answer)) }
|
||||
it { expect(avis_without_answer.answer).to eq('answer') }
|
||||
it { expect(avis_without_answer.piece_justificative_file).to_not be_attached }
|
||||
it { expect(flash.notice).to eq('Votre réponse est enregistrée.') }
|
||||
end
|
||||
describe 'with attachment' do
|
||||
let(:file) { Rack::Test::UploadedFile.new("./spec/fixtures/files/piece_justificative_0.pdf", 'application/pdf') }
|
||||
|
||||
before do
|
||||
post :update, params: { id: avis_without_answer.id, avis: { answer: 'answer', piece_justificative_file: file } }
|
||||
avis_without_answer.reload
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(instruction_gestionnaire_avis_path(avis_without_answer)) }
|
||||
it { expect(avis_without_answer.answer).to eq('answer') }
|
||||
it { expect(avis_without_answer.piece_justificative_file).to be_attached }
|
||||
it { expect(flash.notice).to eq('Votre réponse est enregistrée.') }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create_commentaire' do
|
||||
let(:file) { nil }
|
||||
|
|
|
@ -71,11 +71,15 @@ describe 'user access to the list of their dossiers' do
|
|||
|
||||
context 'when user clicks on delete button', js: true do
|
||||
scenario 'the dossier is deleted' do
|
||||
within(:css, "tr[data-dossier-id=\"#{dossier_brouillon.id}\"]") do
|
||||
click_on 'Actions'
|
||||
page.accept_alert('Confirmer la suppression ?') do
|
||||
find(:xpath, "//a[@href='#{ask_deletion_dossier_path(dossier_brouillon)}']").click
|
||||
click_on 'Supprimer le dossier'
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_content('Votre dossier a bien été supprimé.')
|
||||
expect(page).not_to have_content(dossier_brouillon.procedure.libelle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
33
spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb
Normal file
33
spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
describe 'users/dossiers/dossier_actions.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: true) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
subject { render 'users/dossiers/dossier_actions.html.haml', dossier: dossier }
|
||||
|
||||
it { is_expected.to have_link('Commencer un autre dossier', href: commencer_url(path: procedure.path)) }
|
||||
it { is_expected.to have_link('Supprimer le dossier', href: ask_deletion_dossier_path(dossier)) }
|
||||
|
||||
context 'when the dossier cannot be deleted' do
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
it { is_expected.not_to have_link('Supprimer le dossier') }
|
||||
end
|
||||
|
||||
context 'when the procedure doesn’t expect multiple submissions' do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: false) }
|
||||
it { is_expected.not_to have_link('Commencer un autre dossier') }
|
||||
end
|
||||
|
||||
context 'when the procedure is closed' do
|
||||
let(:procedure) { create(:procedure, :archived, expects_multiple_submissions: true) }
|
||||
it { is_expected.not_to have_link('Commencer un autre dossier') }
|
||||
end
|
||||
|
||||
context 'when there are no actions to display' do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: false) }
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
it 'doesn’t render the menu at all' do
|
||||
expect(subject).not_to have_selector('.dropdown')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue