Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devpf' into masterpf
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Apr 30, 2019
2 parents 7c4e406 + efe0638 commit 4fe35fa
Show file tree
Hide file tree
Showing 88 changed files with 1,128 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ storage/
yarn-debug.log*
.yarn-integrity
/.vscode
/.idea/
/.idea
/public/packs
/public/packs-test
/node_modules
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ ENV \
RAILS_SERVE_STATIC_FILES=true\
SECRET_KEY_BASE="05a2d479d8e412198dabd08ef0eee9d6e180f5cbb48661a35fd1cae287f0a93d40b5f1da08f06780d698bbd458a0ea97f730f83ee780de5d4e31f649a0130cf0"\
SENDINBLUE_ENABLED="disabled"\
SENTRY_CURRENT_ENV=""\
SENTRY_DSN_JS=""\
SENTRY_DSN_RAILS=""\
SENTRY_ENABLED="disabled"\
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Vous souhaitez y apporter des changements ou des améliorations ? Lisez notre [

- Chrome
- chromedriver :
* Mac : `brew install chromedriver`
* Mac : `brew cask install chromedriver`
* Linux : voir https://sites.google.com/a/chromium.org/chromedriver/downloads

### Création des rôles de la base de données
Expand Down Expand Up @@ -62,7 +62,7 @@ En local, un utilisateur de test est créé automatiquement, avec les identifian
### Programmation des jobs

AutoArchiveProcedureJob.set(cron: "* * * * *").perform_later
WeeklyOverviewJob.set(cron: "0 8 * * 0").perform_later
WeeklyOverviewJob.set(cron: "0 7 * * 1").perform_later
AutoReceiveDossiersForProcedureJob.set(cron: "* * * * *").perform_later(procedure_declaratoire_id, Dossier.states.fetch(:en_instruction))
SendinblueUpdateAdministrateursJob.set(cron: "0 10 * * *").perform_later
FindDubiousProceduresJob.set(cron: "0 0 * * *").perform_later
Expand Down
2 changes: 1 addition & 1 deletion app/assets/images/icons/sign-out.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/new_design/avis.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
margin-top: $default-padding;
}

.answer-body p:not(:last-of-type) {
margin-bottom: $default-padding;
}

.avis-icon {
margin-right: $default-spacer;
}
Expand Down
12 changes: 12 additions & 0 deletions app/assets/stylesheets/new_design/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@
margin-left: 0;
}
}

&.vertical {
label {
display: block;
margin-left: 0;
margin-bottom: 0;
}

input[type=radio] {
margin-bottom: 16px;
}
}
}

input[type=text]:not([data-address='true']),
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/admin/mail_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def edit
def update
mail_template = find_mail_template_by_slug(params[:id])
mail_template.update(update_params)
redirect_to admin_procedure_mail_templates_path
flash.notice = "Email mis à jour"
redirect_to edit_admin_procedure_mail_template_path(mail_template.procedure_id, params[:id])
end

private
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def publish
end

if procedure.publish_or_reopen!(current_administrateur, path)
AdministrationMailer.procedure_published(procedure).deliver_later
flash.notice = "Démarche publiée"
redirect_to admin_procedures_path
else
Expand Down
23 changes: 9 additions & 14 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,7 @@ def logged_user_roles
end

def set_raven_context
user = logged_user

context = {
ip_address: request.ip,
id: user&.id,
email: user&.email,
roles: logged_user_roles
}.compact

Raven.user_context(context)
Raven.user_context(sentry_user)
end

def append_info_to_payload(payload)
Expand Down Expand Up @@ -202,16 +193,20 @@ def sensitive_path
end
end

def sentry_user
user = logged_user
{ id: user ? "#{user.class.name}##{user.id}" : 'Guest' }
end

def sentry_config
sentry = Rails.application.secrets.sentry

{
key: sentry[:client_key],
enabled: sentry[:enabled],
user: {
id: current_user&.id,
email: current_email
}
environment: sentry[:environment],
browser: { modern: browser.modern? },
user: sentry_user
}
end

Expand Down
27 changes: 23 additions & 4 deletions app/controllers/manager/procedures_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module Manager
class ProceduresController < Manager::ApplicationController
def whitelist
procedure = Procedure.find(params[:id])
procedure.whitelist!
flash[:notice] = "Démarche whitelistée."
redirect_to manager_procedure_path(procedure)
end

def draft
procedure = Procedure.find(params[:id])
if procedure.dossiers.empty?
procedure.draft!
flash[:notice] = "La démarche a bien été passée en brouillon."
Expand All @@ -19,14 +17,12 @@ def draft
end

def hide
procedure = Procedure.find(params[:id])
procedure.hide!
flash[:notice] = "La démarche a bien été supprimée, en cas d'erreur contactez un développeur."
redirect_to manager_procedures_path
end

def add_administrateur
procedure = Procedure.find(params[:id])
administrateur = Administrateur.find_by(email: params[:email])
if administrateur
procedure.administrateurs << administrateur
Expand All @@ -36,5 +32,28 @@ def add_administrateur
end
redirect_to manager_procedure_path(procedure)
end

def change_piece_justificative_template
if type_de_champ.update(type_de_champ_params)
flash[:notice] = "Le modèle est mis à jour."
else
flash[:alert] = type_de_champ.errors.full_messages.join(', ')
end
redirect_to manager_procedure_path(procedure)
end

private

def procedure
Procedure.find(params[:id])
end

def type_de_champ
TypeDeChamp.find(params[:type_de_champ][:id])
end

def type_de_champ_params
params.require(:type_de_champ).permit(:piece_justificative_template)
end
end
end
35 changes: 35 additions & 0 deletions app/controllers/new_administrateur/mail_templates_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module NewAdministrateur
class MailTemplatesController < AdministrateurController
include ActionView::Helpers::SanitizeHelper

def preview
@procedure = procedure
@logo_url = procedure.logo.url
@service = procedure.service

mail_template = find_mail_template_by_slug(params[:id])

render(html: sanitize(mail_template.body), layout: 'mailers/notification')
end

private

def procedure
@procedure = current_administrateur.procedures.find(params[:procedure_id])
end

def mail_templates
[
@procedure.initiated_mail_template,
@procedure.received_mail_template,
@procedure.closed_mail_template,
@procedure.refused_mail_template,
@procedure.without_continuation_mail_template
]
end

def find_mail_template_by_slug(slug)
mail_templates.find { |template| template.class.const_get(:SLUG) == slug }
end
end
end
42 changes: 28 additions & 14 deletions app/controllers/users/commencer_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,39 @@ class CommencerController < ApplicationController

def commencer
@procedure = Procedure.publiees.find_by(path: params[:path])

if @procedure.blank?
flash.alert = "La démarche est inconnue, ou la création de nouveaux dossiers pour cette démarche est terminée."
return redirect_to root_path
end
return procedure_not_found if @procedure.blank?

render 'commencer/show'
end

def commencer_test
@procedure = Procedure.brouillons.find_by(path: params[:path])

if @procedure.blank?
flash.alert = "La démarche est inconnue, ou cette démarche n’est maintenant plus en test."
return redirect_to root_path
end
return procedure_not_found if @procedure.blank?

render 'commencer/show'
end

def sign_in
store_user_location!
@procedure = Procedure.find_by(path: params[:path])
return procedure_not_found if @procedure.blank?

store_user_location!(@procedure)
redirect_to new_user_session_path
end

def sign_up
store_user_location!
@procedure = Procedure.find_by(path: params[:path])
return procedure_not_found if @procedure.blank?

store_user_location!(@procedure)
redirect_to new_user_registration_path
end

def france_connect
store_user_location!
@procedure = Procedure.find_by(path: params[:path])
return procedure_not_found if @procedure.blank?

store_user_location!(@procedure)
redirect_to france_connect_particulier_path
end

Expand All @@ -45,8 +46,21 @@ def procedure_for_help

private

def store_user_location!
def procedure_not_found
procedure = Procedure.find_by(path: params[:path])

if procedure&.archivee?
flash.alert = t('errors.messages.procedure_archived')
elsif procedure&.publiee?
flash.alert = t('errors.messages.procedure_not_draft')
else
flash.alert = t('errors.messages.procedure_not_found')
end

return redirect_to root_path
end

def store_user_location!(procedure)
store_location_for(:user, helpers.procedure_lien(procedure))
end
end
Expand Down
8 changes: 7 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ def remove_element(selector, timeout: 0, inner: false)
script = "(function() {";
script << "var el = document.querySelector('#{selector}');"
method = (inner ? "el.innerHTML = ''" : "el.parentNode.removeChild(el)")
script << "setTimeout(function() { #{method}; }, #{timeout});";
script << "if (el) { setTimeout(function() { #{method}; }, #{timeout}); }";
script << "})();"
# rubocop:disable Rails/OutputSafety
raw(script);
# rubocop:enable Rails/OutputSafety
end

def show_element(selector)
# rubocop:disable Rails/OutputSafety
raw("document.querySelector('#{selector}').classList.remove('hidden');")
# rubocop:enable Rails/OutputSafety
end

def disable_element(selector)
# rubocop:disable Rails/OutputSafety
raw("document.querySelector('#{selector}').disabled = true;")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';

function TypeDeChampDropDownOptions({ isVisible, value, handler }) {
function TypeDeChampDropDownOptions({ isVisible, handler }) {
if (isVisible) {
return (
<div className="cell">
<label htmlFor={handler.id}>Liste déroulante</label>
<textarea
id={handler.id}
name={handler.name}
value={value}
value={handler.value}
onChange={handler.onChange}
rows={3}
cols={40}
Expand Down
1 change: 1 addition & 0 deletions app/javascript/new_design/state-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { show, hide } from '@utils';

export function showMotivation(event, state) {
event.preventDefault();
motivationCancel();
show(document.querySelector(`.motivation.${state}`));
hide(document.querySelector('.dropdown-items'));
}
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/shared/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
// required by the browsers we support will be included.
import '@babel/polyfill';
import 'dom4';
import './polyfills/insertAdjacentElement';
import './polyfills/dataset';
Loading

0 comments on commit 4fe35fa

Please sign in to comment.