Merge branch 'staging'

This commit is contained in:
Guillaume Lazzara 2016-02-09 17:22:09 +01:00
commit 016295291d
93 changed files with 1347 additions and 333 deletions

View file

@ -505,4 +505,4 @@ DEPENDENCIES
will_paginate-bootstrap will_paginate-bootstrap
BUNDLED WITH BUNDLED WITH
1.10.6 1.11.2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 KiB

After

Width:  |  Height:  |  Size: 771 KiB

View file

@ -0,0 +1,14 @@
$(document).on('page:load', destroy_action);
$(document).ready(destroy_action);
function destroy_action(){
$("#destroy").on('click', function(){
$("#destroy").hide();
$("#confirm").show();
});
$("#confirm #cancel").on('click', function(){
$("#destroy").show();
$("#confirm").hide();
});
}

View file

@ -28,11 +28,18 @@
//= require turf //= require turf
//= require franceconnect //= require franceconnect
$(document).ready(function() {
$('.js-scrollTo').on('click', function() { // Au clic sur un élément $(document).on('page:load', scroll_to);
$(document).ready(scroll_to);
function scroll_to() {
$('.js-scrollTo').on('click', function () { // Au clic sur un élément
var page = $(this).attr('cible'); // Page cible var page = $(this).attr('cible'); // Page cible
var speed = 600; // Durée de l'animation (en ms) var speed = 600; // Durée de l'animation (en ms)
$('html, body').animate( { scrollTop: $(page).offset().top-100 }, speed ); // Go $('html, body').animate({scrollTop: $(page).offset().top - 100}, speed); // Go
return false; return false;
}); });
}); }

View file

@ -23,21 +23,27 @@
@import "bootstrap"; @import "bootstrap";
body { body {
background-color: rgb(255, 255, 255) background-color: rgb(255, 255, 255);
} }
html, body { html, body {
height: 100%; height: 100%;
} }
body {
padding-top: 50px;
}
#wrap { #wrap {
min-height: 100%; min-height: 100%;
margin-bottom: -50px; margin-bottom: -50px;
} }
#wrap:after { #wrap:after {
content: ""; content: "";
display: block; display: block;
} }
#footer, #wrap:after { #footer, #wrap:after {
height: 40px; height: 40px;
} }
@ -46,6 +52,11 @@ html, body {
background-color: rgb(240, 240, 240) background-color: rgb(240, 240, 240)
} }
.main_div {
margin-left: 10rem;
margin-right: 10rem;
}
.logo { .logo {
margin-left: 10px; margin-left: 10px;
padding-top: 5px; padding-top: 5px;
@ -85,14 +96,26 @@ html, body {
margin-right: 105px; margin-right: 105px;
} }
.alert.alert-success,
.alert.alert-danger { #header {
margin-top: -20px top: 0;
left: -3px;
position: fixed;
width: 100%;
z-index: 10;
} }
.navbar { .navbar {
height: 35px; height: 35px;
background-color: rgb(235, 235, 235) background-color: rgba(235, 235, 235, 0.95);
.sign_in_FC {
margin-top: -18px;
height: 70px;
}
} }
.btn { .btn {
@ -161,6 +184,7 @@ div.pagination {
height: 52px; height: 52px;
width: 100%; width: 100%;
margin-top: 0px; margin-top: 0px;
z-index: 10;
} }
@ -212,7 +236,6 @@ div.pagination {
margin-top: -4px; margin-top: -4px;
} }
#fconnect-access { #fconnect-access {
right: 50px; right: 50px;
} }

View file

@ -1,15 +1,13 @@
#wrap {
}
.max-size { .max-size {
margin-left: -13%; margin-left: -10rem;
margin-right: -13%; margin-right: -10rem;
} }
#landing { #landing {
margin-top: -20px;
background-image: image-url('landing_background.jpg'); background-image: image-url('landing_background.jpg');
background-attachment: fixed;
background-position: top center;
background-repeat: no-repeat; background-repeat: no-repeat;
#title { #title {
@ -20,30 +18,28 @@
font-size: 35px; font-size: 35px;
} }
.btn {
text-shadow: none;
}
color: white; color: white;
padding-top: 6%; padding-top: 6%;
padding-bottom: 9%; padding-bottom: 7%;
text-shadow: 3px 3px 4px rgba(0, 0, 0, .6); text-shadow: 0px 0px 10px rgb(0, 0, 0);
} }
.logo img { .logo img {
width: 70px; width: 70px;
} }
#buttons {
margin-top: 5%;
button {
margin-left: 30px;
margin-right: 30px;
}
}
} }
#suite { #suite {
.row{
width: 100%;
margin-left: 0;
margin-right: 0;
}
.word { .word {
border-bottom: solid darkgrey 1px; border-bottom: solid darkgrey 1px;
//height: 300px;
img { img {
padding-top: 50px; padding-top: 50px;
@ -53,22 +49,49 @@
} }
} }
.simplifier {
ul {
margin-top: 16%;
}
}
.securiser { .securiser {
img { img {
width: 300px; width: 300px;
} }
ul {
margin-top: 11%;
}
} }
.echanger { .echanger {
ul { ul {
margin-top: 6%; margin-top: 4%;
} }
} }
.profiter { .profiter {
border-bottom: none; //border-bottom: none;
ul { ul {
margin-top: 9%; margin-top: 11%;
} }
} }
.open_admin_compte {
border-bottom: none;
padding-top: 25px;
padding-bottom: 25px;
ol {
margin-top: 1%;
}
.btn-lg {
font-size: 20px;
padding: 12px 18px;
margin-top: 16%;
}
}
} }

View file

@ -1,13 +1,11 @@
.dynamic_ul { .dynamic_ul {
list-style-type: none;
margin-left: 20px; margin-left: 20px;
margin-top: 13%; margin-top: 13%;
li { li {
font: 200 20px/1.5 Helvetica, Verdana, sans-serif; font: 200 20px/1.5 Helvetica, Verdana, sans-serif;
border-bottom: 1px solid #ccc; margin-top: 15px;
margin-top: 9px; margin-bottom: 15px;
margin-bottom: 9px;
} }
li:last-child { li:last-child {

View file

@ -0,0 +1,41 @@
class Admin::GestionnairesController < AdminController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
def index
@gestionnaires = smart_listing_create :gestionnaires,
current_administrateur.gestionnaires,
partial: "admin/gestionnaires/list",
array: true
@gestionnaire ||= Gestionnaire.new
end
def create
gestionnaire_params = create_gestionnaire_params
@gestionnaire = Gestionnaire.create(gestionnaire_params)
if @gestionnaire.errors.messages.empty?
flash.notice = 'Gestionnaire ajouté'
GestionnaireMailer.new_gestionnaire(gestionnaire_params[:email], gestionnaire_params[:password]).deliver_now!
else
flash.alert = @gestionnaire.errors.full_messages.join('<br />').html_safe
end
redirect_to admin_gestionnaires_path
end
def destroy
Gestionnaire.find(params[:id]).destroy
redirect_to admin_gestionnaires_path
end
def create_gestionnaire_params
params.require(:gestionnaire).permit(:email)
.merge(administrateur_id: current_administrateur.id)
.merge(password: SecureRandom.hex(5))
end
end

View file

@ -86,7 +86,7 @@ class Admin::ProceduresController < AdminController
private private
def create_procedure_params def create_procedure_params
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :euro_flag, :logo, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :euro_flag, :logo, :cerfa_flag, 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 def create_module_api_carto_params

View file

@ -2,7 +2,7 @@ class API::V1::DossiersController < APIController
def index def index
procedure = current_administrateur.procedures.find(params[:procedure_id]) procedure = current_administrateur.procedures.find(params[:procedure_id])
dossiers = procedure.dossiers.paginate(page: params[:page]) dossiers = procedure.dossiers.where.not(state: :draft).paginate(page: params[:page])
render json: dossiers, each_serializer: DossiersSerializer, meta: pagination(dossiers), meta_key: 'pagination', status: 200 render json: dossiers, each_serializer: DossiersSerializer, meta: pagination(dossiers), meta_key: 'pagination', status: 200
rescue ActiveRecord::RecordNotFound => e rescue ActiveRecord::RecordNotFound => e
render json: {}, status: 404 render json: {}, status: 404
@ -18,9 +18,9 @@ class API::V1::DossiersController < APIController
def pagination(dossiers) def pagination(dossiers)
{ {
page: dossiers.current_page, page: dossiers.current_page,
resultats_par_page: dossiers.per_page, resultats_par_page: dossiers.per_page,
nombre_de_page: dossiers.total_pages nombre_de_page: dossiers.total_pages
} }
end end
end end

View file

@ -1,6 +1,5 @@
class API::V1::ProceduresController < APIController class API::V1::ProceduresController < APIController
def show def show
@procedure = current_administrateur.procedures.find(params[:id]).decorate @procedure = current_administrateur.procedures.find(params[:id]).decorate
render json: @procedure render json: @procedure

View file

@ -4,5 +4,4 @@ class Backoffice::CommentairesController < CommentairesController
def is_gestionnaire? def is_gestionnaire?
true true
end end
end end

View file

@ -6,9 +6,9 @@ class CommentairesController < ApplicationController
if is_gestionnaire? if is_gestionnaire?
@commentaire.email = current_gestionnaire.email @commentaire.email = current_gestionnaire.email
@commentaire.dossier.next_step! 'gestionnaire', 'comment' @commentaire.dossier.next_step! 'gestionnaire', 'comment'
else #is_user else
@commentaire.email = current_user.email @commentaire.email = current_user.email
@commentaire.dossier.next_step! 'user', 'comment' @commentaire.dossier.next_step! 'user', 'comment' if current_user.email == @commentaire.dossier.user.email
end end
@commentaire.body = params['texte_commentaire'] @commentaire.body = params['texte_commentaire']
@ -17,6 +17,9 @@ class CommentairesController < ApplicationController
if is_gestionnaire? if is_gestionnaire?
NotificationMailer.new_answer(@commentaire.dossier).deliver_now! NotificationMailer.new_answer(@commentaire.dossier).deliver_now!
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id']) redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
elsif current_user.email != @commentaire.dossier.user.email
invite = Invite.find_by_email current_user.email
redirect_to url_for(controller: 'users/dossiers/invites', action: :show, id: invite.id)
else else
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params['dossier_id']) redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params['dossier_id'])
end end

View file

@ -0,0 +1,23 @@
class InvitesController < ApplicationController
def create
email_sender = current_gestionnaire.email
user = User.find_by_email(params[:email])
invite = Invite.create(dossier_id: params[:dossier_id], user: user, email: params[:email], email_sender: email_sender)
if invite.valid?
InviteMailer.invite_user(invite).deliver_now! unless invite.user.nil?
InviteMailer.invite_guest(invite).deliver_now! if invite.user.nil?
flash.notice = "Invitation envoyée (#{invite.email})"
else
flash.alert = invite.errors.full_messages.join('<br />').html_safe
end
if gestionnaire_signed_in?
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
# else
# redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params['dossier_id'])
end
end
end

View file

@ -11,7 +11,7 @@ class RootController < ApplicationController
redirect_to admin_procedures_path redirect_to admin_procedures_path
else else
redirect_to new_user_session_path render 'landing'
end end
end end
end end

View file

@ -23,6 +23,8 @@ class Users::DescriptionController < UsersController
def create def create
@dossier = current_user_dossier @dossier = current_user_dossier
@procedure = @dossier.procedure
unless @dossier.update_attributes(create_params) unless @dossier.update_attributes(create_params)
@dossier = @dossier.decorate @dossier = @dossier.decorate
@procedure = @dossier.procedure @procedure = @dossier.procedure
@ -30,10 +32,13 @@ class Users::DescriptionController < UsersController
flash.now.alert = @dossier.errors.full_messages.join('<br />').html_safe flash.now.alert = @dossier.errors.full_messages.join('<br />').html_safe
return render 'show' return render 'show'
end end
unless params[:cerfa_pdf].nil?
cerfa = @dossier.cerfa if @procedure.cerfa_flag?
cerfa.content = params[:cerfa_pdf] unless params[:cerfa_pdf].nil?
cerfa.save cerfa = @dossier.cerfa
cerfa.content = params[:cerfa_pdf]
cerfa.save
end
end end
unless params[:champs].nil? unless params[:champs].nil?

View file

@ -0,0 +1,3 @@
class Users::Dossiers::CommentairesController < CommentairesController
before_action :authenticate_user!
end

View file

@ -0,0 +1,10 @@
class Users::Dossiers::InvitesController < UsersController
def show
@facade = InviteDossierFacades.new params[:id], current_user.email
render 'users/recapitulatif/show'
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for users_dossiers_path
end
end

View file

@ -107,7 +107,8 @@ class Users::DossiersController < UsersController
def dossiers_to_display def dossiers_to_display
{'a_traiter' => waiting_for_user, {'a_traiter' => waiting_for_user,
'en_attente' => waiting_for_gestionnaire, 'en_attente' => waiting_for_gestionnaire,
'termine' => termine}[@liste] 'termine' => termine,
'invite' => invite}[@liste]
end end
def waiting_for_user def waiting_for_user
@ -125,10 +126,16 @@ class Users::DossiersController < UsersController
@termine ||= current_user.dossiers.termine 'DESC' @termine ||= current_user.dossiers.termine 'DESC'
end end
def invite
@invite_class = (@liste == 'invite' ? 'active' : '')
@invite ||= current_user.invites
end
def total_dossiers_per_state def total_dossiers_per_state
@dossiers_a_traiter_total = waiting_for_user.count @dossiers_a_traiter_total = waiting_for_user.count
@dossiers_en_attente_total = waiting_for_gestionnaire.count @dossiers_en_attente_total = waiting_for_gestionnaire.count
@dossiers_termine_total = termine.count @dossiers_termine_total = termine.count
@dossiers_invite_total = invite.count
end end
def check_siret def check_siret

View file

@ -3,7 +3,9 @@ class Users::RegistrationsController < Devise::RegistrationsController
# before_filter :configure_account_update_params, only: [:update] # before_filter :configure_account_update_params, only: [:update]
def after_sign_up_path_for(resource_or_scope) def after_sign_up_path_for(resource_or_scope)
WelcomeMailer.welcome_email(User.last).deliver_now! WelcomeMailer.welcome_email(resource_or_scope).deliver_now!
check_invite! resource_or_scope
super super
end end
@ -62,4 +64,11 @@ class Users::RegistrationsController < Devise::RegistrationsController
# def after_inactive_sign_up_path_for(resource) # def after_inactive_sign_up_path_for(resource)
# super(resource) # super(resource)
# end # end
private
def check_invite! user
Invite.where(email: user.email)
.each { |invite| invite.update_attribute(:user, user) }
end
end end

View file

@ -1,6 +1,10 @@
class UsersController < ApplicationController class UsersController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
def index
redirect_to root_path
end
def current_user_dossier dossier_id=nil def current_user_dossier dossier_id=nil
dossier_id ||= params[:dossier_id] || params[:id] dossier_id ||= params[:dossier_id] || params[:id]

View file

@ -37,4 +37,8 @@ class DossierFacades
def procedure def procedure
@dossier.procedure @dossier.procedure
end end
def invites
@dossier.invites
end
end end

View file

@ -0,0 +1,9 @@
class InviteDossierFacades < DossierFacades
#TODO rechercher en fonction de la personne/email
def initialize dossier_id, email
@dossier = (Invite.where(email: email).find(dossier_id)).dossier
@email = email
end
end

View file

@ -0,0 +1,20 @@
class GestionnaireMailer < ApplicationMailer
def new_gestionnaire email, password
send_mail email, password, "Vous avez été nommé accompagnateur sur la plateforme TPS"
end
private
def vars_mailer email, password
@password = password
@email = email
end
def send_mail email, password, subject
vars_mailer email, password
mail(from: "tps@apientreprise.fr", to: email,
subject: subject)
end
end

View file

@ -0,0 +1,25 @@
class InviteMailer < ApplicationMailer
def invite_user invite
vars_mailer invite
send_mail invite.email, "TPS - Participez à l'élaboration d'un dossier" unless invite.user.nil?
end
def invite_guest invite
vars_mailer invite
send_mail invite.email, "Invitation - #{invite.email_sender} vous invite à consulter un dossier sur la plateforme TPS"
end
private
def vars_mailer invite
@invite = invite
end
def send_mail email, subject
mail(from: "tps@apientreprise.fr", to: email,
subject: subject)
end
end

View file

@ -16,6 +16,7 @@ class Dossier < ActiveRecord::Base
has_many :quartier_prioritaires, dependent: :destroy has_many :quartier_prioritaires, dependent: :destroy
has_many :cadastres, dependent: :destroy has_many :cadastres, dependent: :destroy
has_many :commentaires, dependent: :destroy has_many :commentaires, dependent: :destroy
has_many :invites, dependent: :destroy
belongs_to :procedure belongs_to :procedure
belongs_to :user belongs_to :user
@ -25,8 +26,7 @@ class Dossier < ActiveRecord::Base
delegate :types_de_piece_justificative, to: :procedure delegate :types_de_piece_justificative, to: :procedure
delegate :types_de_champ, to: :procedure delegate :types_de_champ, to: :procedure
before_create :build_default_cerfa after_save :build_default_cerfa, if: Proc.new { procedure.cerfa_flag? && procedure_id_changed? }
after_save :build_default_pieces_justificatives, if: Proc.new { procedure_id_changed? } after_save :build_default_pieces_justificatives, if: Proc.new { procedure_id_changed? }
after_save :build_default_champs, if: Proc.new { procedure_id_changed? } after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
@ -188,10 +188,15 @@ class Dossier < ActiveRecord::Base
return composed_scope, dossier return composed_scope, dossier
end end
def cerfa_available?
procedure.cerfa_flag? && !cerfa.empty?
end
private private
def build_default_cerfa def build_default_cerfa
build_cerfa create_cerfa
true true
end end
end end

10
app/models/invite.rb Normal file
View file

@ -0,0 +1,10 @@
class Invite < ActiveRecord::Base
belongs_to :dossier
belongs_to :user
validates_presence_of :email
validates_uniqueness_of :email, :scope => :dossier_id
validates :email, email_format: true
end

View file

@ -8,6 +8,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
has_many :dossiers, dependent: :destroy has_many :dossiers, dependent: :destroy
has_many :invites, dependent: :destroy
has_one :france_connect_information, dependent: :destroy has_one :france_connect_information, dependent: :destroy
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information

View file

@ -0,0 +1,11 @@
class EmailFormatValidator < ActiveModel::Validator
def email_regex
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
end
def validate(record)
return if record.email.blank?
record.errors[:base] << "Email invalide" unless email_regex.match(record.email)
end
end

View file

@ -0,0 +1,5 @@
-{email: 'Email*'}.each do |key, value|
.form-group{class: ('has-error' if @gestionnaire.errors.messages[key])}
%h4
=value
=f.text_field key, class: 'form-control', placeholder: value

View file

@ -0,0 +1,25 @@
- unless smart_listing.empty?
%table.table
%thead
%th#libelle= smart_listing.sortable 'Email', 'email'
- @gestionnaires.each do |gestionnaire|
%tr
%td= gestionnaire.email
%td{ style: 'text-align:right' }
%span#destroy{ class: "fa fa-times" }
#confirm
=link_to(admin_gestionnaire_path(id: gestionnaire.id), method: :delete) do
%span#valid{ class: "fa fa-check btn-success" }
%span#valid
Valider
%span
|
%span#cancel{ class: "fa fa-minus btn-danger" }
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%h4.center
Aucun gestionnaire

View file

@ -0,0 +1,19 @@
%h1 Gestion des gestionnaires
%br
.row
.col-md-4.col-lg-4
= smart_listing_render :gestionnaires
.col-md-1.col-lg-1
&nbsp;
.col-md-6.col-lg-6
%h3 Ajouter un gestionnaire
#procedure_new.section.section-label
= form_for @gestionnaire, url: {controller: 'admin/gestionnaires', action: :create} do |f|
.row
.col-md-5.col-lg-5
=render partial: 'informations', locals: {f: f}
.col-md-2.col-lg-2
%br
%br
=f.submit 'Valider', class: 'btn btn-info', style: 'float:left'

View file

@ -0,0 +1 @@
<%= smart_listing_update :gestionnaires %>

View file

@ -21,22 +21,28 @@
=f.check_box :euro_flag =f.check_box :euro_flag
Afficher le drapeau européen Afficher le drapeau européen
%br %br
%h4 Cartographie .row
.col-md-6.col-lg-6
%h4 Cartographie
= f.fields_for :module_api_carto, @procedure.module_api_carto do |ff| = f.fields_for :module_api_carto, @procedure.module_api_carto do |ff|
%label %label
=ff.check_box :use_api_carto, {id: :procedure_module_api_carto_use_api_carto} =ff.check_box :use_api_carto, {id: :procedure_module_api_carto_use_api_carto}
Utilisation de la cartographie Utilisation de la cartographie
%ul#modules_api_carto %ul#modules_api_carto
%li %li
%label %label
= ff.check_box :quartiers_prioritaires = ff.check_box :quartiers_prioritaires
Quartiers Prioritaires Quartiers Prioritaires
%li %li
%label %label
= ff.check_box :cadastre = ff.check_box :cadastre
Cadastre Cadastre
.col-md-6.col-lg-6
%h4 Formulaire / CERFA
%label
=f.check_box :cerfa_flag
Activer l'envoi de formulaire / CERFA

View file

@ -10,11 +10,15 @@
= link_to(admin_procedures_path, id: :menu_item_procedure) do = link_to(admin_procedures_path, id: :menu_item_procedure) do
%i.fa.fa-list{ style: "background-size: 10px;"} %i.fa.fa-list{ style: "background-size: 10px;"}
&nbsp;Procédures &nbsp;Procédures
%li
= link_to(admin_gestionnaires_path) do
%i.fa.fa-user
&nbsp;Gestionnaires
%li.divider{ role: :separator}
%li %li
= link_to(admin_profile_path, id: :profile) do = link_to(admin_profile_path, id: :profile) do
%i.fa.fa-user %i.fa.fa-user
&nbsp;Profile &nbsp;Profile
%li.divider{ role: :separator}
%li %li
= link_to('/administrateurs/sign_out',id: :admin_sign_out, method: :delete) do = link_to('/administrateurs/sign_out',id: :admin_sign_out, method: :delete) do
%i.fa.fa-power-off %i.fa.fa-power-off

View file

@ -2,20 +2,31 @@
%h1#dossier_id.text-info{ :style => 'text-align:right'} %h1#dossier_id.text-info{ :style => 'text-align:right'}
= "Dossier n°#{@facade.dossier.id}" = "Dossier n°#{@facade.dossier.id}"
%h3{:class => 'text-success', :style => 'text-align:right'} %div{:style => 'text-align:right'}
= @facade.dossier.display_state %h3{:class => 'text-success'}
= @facade.dossier.display_state
= render partial: '/dossiers/infos_entreprise' = render partial: '/dossiers/infos_entreprise'
%br
= render partial: '/dossiers/infos_dossier' = render partial: '/dossiers/infos_dossier'
%br %br
%br
= render partial: '/users/recapitulatif/commentaires_flux' %div
%br %ul{class: "nav nav-tabs", role: "tablist"}
%br %li{role: "presentation", class: "active"}
%a{href: "#commentaires", 'aria-controls' => "commentaires", role: "tab", 'data-toggle' => "tab"}
Commentaires
%li{role: "presentation"}
%a{href: "#invites", 'aria-controls' => "invites", role: "tab", 'data-toggle' => "tab"}
Invités
-#%script{type: 'text/javascript'} %div{class: "tab-content"}
-# ="url_carte = '#{@facade.dossier.id}/'" %div{role: "tabpanel", class: "tab-pane fade in active", id:"commentaires"}
-# ="ref_dossier = '#{@facade.dossier.ref_dossier_carto}'" %h3 Flux de commentaires
%br
= render partial: '/users/recapitulatif/commentaires_flux'
%div{role: "tabpanel", class: "tab-pane fade", id:"invites"}
= render partial: '/dossiers/invites'
%br
%br

View file

@ -1,4 +1,3 @@
#infos_dossier #infos_dossier
%div.row %div.row
.col-lg-6.col-md-6 .col-lg-6.col-md-6
@ -51,8 +50,8 @@
=render partial: '/dossiers/pieces_justificatives' =render partial: '/dossiers/pieces_justificatives'
%br %br
%div.row{style: 'text-align:right'} .row{style: 'text-align:right'}
-unless gestionnaire_signed_in? -if user_signed_in? && (current_user.email == @facade.dossier.user.email)
-if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed? -if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
-if @facade.dossier.procedure.module_api_carto.use_api_carto -if @facade.dossier.procedure.module_api_carto.use_api_carto
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"} %a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"}
@ -60,7 +59,7 @@
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@facade.dossier.id}/description"} %a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@facade.dossier.id}/description"}
= 'Editer mon dossier' = 'Editer mon dossier'
-unless user_signed_in? -if gestionnaire_signed_in?
-if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed? -if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do = form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success %button#action_button.btn.btn-success

View file

@ -0,0 +1,18 @@
%h3 Personnes invitées à voir ce dossier
%br
.row
.col-md-4.col-lg-4
- if @facade.invites.size > 0
%ul
- @facade.invites.each do |invite|
%li
= invite.email
- else
Aucune personne invité
.col-md-3.col-lg-3
=form_tag backoffice_dossier_invites_path(dossier_id: @facade.dossier.id), method: :post, class: 'form-inline' do
=text_field_tag :email, '', class: 'form-control', placeholder: 'Envoyer une invitation'
=submit_tag 'Ajouter', class: 'btn btn-success'

View file

@ -8,7 +8,7 @@
%th{class:'col-lg-6'} %th{class:'col-lg-6'}
='Formulaire' ='Formulaire'
%td.col-lg-6.col-md-6 %td.col-lg-6.col-md-6
- if !@facade.dossier.cerfa.empty? - if @facade.dossier.cerfa_available?
- if user_signed_in? - if user_signed_in?
= 'Pièce fournie' = 'Pièce fournie'
- elsif gestionnaire_signed_in? - elsif gestionnaire_signed_in?

View file

@ -0,0 +1,12 @@
Bienvenue sur la plateforme TPS
Vous venez d'être nommé accompagnateur sur la plateforme TPS. Pour mémoire, voici quelques informations utiles :
URL : https://tps.apientreprise.fr/gestionnaires/sign_in
Login : <%= @email %>
Mot de passe : <%= @password %>
Bonne journée,
---
L'équipe TPS - tps@apientreprise.fr

View file

@ -0,0 +1,12 @@
Bonjour <%= @invite.email %>
L'utilisateur <%= @invite.email_sender %> souhaite que vous participiez à l'élaboration d'un dossier sur la plateforme TPS.
Cette plateforme permet à ses utilisateurs d'établir des dossiers 100% en ligne et de dialoguer avec plusieurs interlocuteurs privilégiés avant d'instruire un dépot.
Afin de répondre à cette invitation, merci de vous inscrit avec l'adresse email <%= @invite.email %> sur <%= users_dossiers_invite_url(@invite.id) %>.
Bonne journée.
---
L'équide TPS - tps@apientreprise.fr

View file

@ -0,0 +1,11 @@
Bonjour <%= @invite.email %>
L'utilisateur <%= @invite.email_sender %> souhaite que vous participiez à l'élaboration d'un dossier sur la plateforme TPS.
Ce dossier se nomme : <%= @invite.dossier.nom_projet %>
Pour le consulter, merci de suivre ce lien : <%= users_dossiers_invite_url(@invite.id) %>
Bonne journée.
---
L'équide TPS - tps@apientreprise.fr

View file

@ -9,10 +9,11 @@
= javascript_include_tag 'application', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags = csrf_meta_tags
%body %body
#beta
Beta
%div#wrap %div#wrap
%div.navbar %div#header.navbar
#beta
Beta
= image_tag('marianne_small.png', class: 'logo') = image_tag('marianne_small.png', class: 'logo')
%a{href: '/'} %a{href: '/'}
= image_tag('logo-tps.png', class: 'logo') = image_tag('logo-tps.png', class: 'logo')
@ -38,6 +39,10 @@
= current_user.email = current_user.email
= link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md' = link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
- else
= link_to "Utilisateur", '/users/sign_in', method: :get, :class => 'btn btn-md'
= link_to "Accompagnateur", '/gestionnaires/sign_in', method: :get, :class => 'btn btn-md'
= link_to "Administrateur", '/administrateurs/sign_in', method: :get, :class => 'btn btn-md'
#flash_message.center #flash_message.center
- if flash.notice - if flash.notice
@ -47,7 +52,7 @@
.alert.alert-danger .alert.alert-danger
= flash.alert = flash.alert
%div{:style => 'margin-left:10%; margin-right:10%;'} %div.main_div
= yield = yield
%br %br
@ -60,7 +65,7 @@
=link_to 'SGMAP', "http://etatplateforme.modernisation.gouv.fr" =link_to 'SGMAP', "http://etatplateforme.modernisation.gouv.fr"
2016. All Rights Reserved 2016 - Tous droits réservés
=link_to 'contact@tps.apientreprise.fr', "mailto:contact@tps.apientreprise.fr" =link_to 'contact@tps.apientreprise.fr', "mailto:contact@tps.apientreprise.fr"

View file

@ -7,19 +7,14 @@
%br %br
%h3.center %h3.center
Simplifié toutes vos démarches pour les rendre 100% en ligne. Simplifiez toutes vos démarches pour les rendre 100% en ligne.
%br
%br
.center
%button.js-scrollTo.btn.btn-lg.btn-success{cible: '.open_admin_compte'}
Ouvrir un compte TPS
#buttons.center
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.simplifier'}
Simplifier
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.securiser'}
Sécuriser
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.echanger'}
Échanger
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.faciliter'}
Faciliter
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.profiter'}
Profiter
#suite.max-size #suite.max-size
.row.word.simplifier .row.word.simplifier
@ -28,11 +23,9 @@
.col-md-6.col-lg-6 .col-md-6.col-lg-6
%ul.dynamic_ul %ul.dynamic_ul
%li %li
%a Générateur simplifiée de démarches en ligne %a Générateur simplifiée de démarches en ligne pour les administrations
%li %li
%a Ne demander que les informations strictement nécessaires %a Ne demander que les informations strictement nécessaires
%li
%a Gérer les procédures, publication, suspension, en un clic.
.row.word.securiser .row.word.securiser
.col-md-6.col-lg-6 .col-md-6.col-lg-6
@ -58,23 +51,31 @@
%li %li
Vérifier les pièces au fur et à mesure Vérifier les pièces au fur et à mesure
.row.word.faciliter
.col-md-6.col-lg-6
%ul.dynamic_ul
%li
Construire la démarche en plusieurs fois
%li
Gagner du temps sur linstruction
.col-md-6.col-lg-6
= image_tag image_url('keywords/faciliter.png')
.row.word.profiter .row.word.profiter
.col-md-6.col-lg-6
= image_tag image_url('keywords/profiter.png')
.col-md-6.col-lg-6 .col-md-6.col-lg-6
%ul.dynamic_ul %ul.dynamic_ul
%li %li
Récupérer des informations officielles collectées directement auprès des administrations Profiter des ressources cartographiques directement mobilisées, si nécessaire
%li %li
Profiter des ressources cartographiques directement mobilisées, si nécessaire Récupérer des informations officielles collectées directement auprès des administrations
.col-md-6.col-lg-6
= image_tag image_url('keywords/profiter.png')
.row.word.open_admin_compte
.col-md-6.col-lg-6
.center
=link_to 'Ouvrir un compte TPS', 'https://tps.apientreprise.fr/users/dossiers/new?procedure_id=31', {class: 'btn btn-lg btn-success', target: '_blank'}
.col-md-6.col-lg-6
%h3 Envie d'essayer ? Rien de plus simple
%br
%ol.dynamic_ul
%li
Cliquez sur le bouton vert à gauche
%li
Inscrivez-vous avec votre email professionnel
%li
Entrez le SIRET de votre organisme
%li
Composez un dossier en trois clics et VOILÀ !
%br
%h4 Après, nos équipes prendrons rapidement contact avec vous via la plateforme.

View file

@ -37,10 +37,11 @@
'data-provide' => ('datepicker' if champ.type_champ == 'datetime'), 'data-provide' => ('datepicker' if champ.type_champ == 'datetime'),
'data-date-format' => ('dd/mm/yyyy' if champ.type_champ == 'datetime')} 'data-date-format' => ('dd/mm/yyyy' if champ.type_champ == 'datetime')}
%br -if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.pieces_justificatives.size > 1
%h3 Documents administratifs %br
%h3 Documents administratifs
-if @procedure.lien_demarche != nil -unless @procedure.lien_demarche.blank?
%p %p
Formulaire / documentation de la démarche : Formulaire / documentation de la démarche :
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Accéder %a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Accéder
@ -49,17 +50,18 @@
%br %br
//TODO a refactorer //TODO a refactorer
%table{class:'table', style:'width:55%; margin-left:5%'} %table{class:'table', style:'width:55%; margin-left:5%'}
%tr - if @procedure.cerfa_flag
%th{class:'col-lg-6'} %tr
='Formulaire (.pdf / .doc)' %th{class:'col-lg-6'}
='Formulaire (.pdf / .doc)'
%td{class:'col-lg-5'} %td{class:'col-lg-5'}
-if !@dossier.cerfa.empty? -if @dossier.cerfa_available?
%span.btn.btn-sm.btn-file.btn-success %span.btn.btn-sm.btn-file.btn-success
Modifier Modifier
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
-else
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"} %input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
-else
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
- @dossier.pieces_justificatives.each do |piece_justificative| - @dossier.pieces_justificatives.each do |piece_justificative|
%tr %tr
@ -75,6 +77,7 @@
%span.btn.btn-sm.btn-file.btn-success %span.btn.btn-sm.btn-file.btn-success
Modifier Modifier
= file_field_tag "piece_justificative_#{piece_justificative.type}", accept: '.pdf' = file_field_tag "piece_justificative_#{piece_justificative.type}", accept: '.pdf'
%div{style: 'text-align:right'} %div{style: 'text-align:right'}
%h6 Tous les champs portant un * sont obligatoires. %h6 Tous les champs portant un * sont obligatoires.

View file

@ -6,12 +6,18 @@
%th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state' %th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at' %th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
- @dossiers.each do |dossier| - @dossiers.each do |dossier|
- dossier = dossier.decorate - if dossier.class == Invite
-invite = dossier
-dossier = dossier.dossier.decorate
- else
- dossier = dossier.decorate
%tr %tr
%td %td
= dossier.procedure.libelle = dossier.procedure.libelle
%td %td
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier)) = link_to(dossier.nom_projet, users_dossiers_invite_path(id: invite.id)) unless invite.nil?
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier)) if invite.nil?
%td{id: "dossier_#{dossier.id}_state"}= dossier.display_state %td{id: "dossier_#{dossier.id}_state"}= dossier.display_state
%td= dossier.last_update %td= dossier.last_update

View file

@ -23,4 +23,11 @@
= "Terminé" = "Terminé"
.badge.progress-bar-success .badge.progress-bar-success
= @dossiers_termine_total = @dossiers_termine_total
%li{ class: @invite_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'invite')}"}
%h5{style: 'color: #696969'}
= "Invitation"
.badge{style: 'background-color: #696969'}
= @dossiers_invite_total
%br %br

View file

@ -1,22 +0,0 @@
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "users/shared/links" %>

View file

@ -0,0 +1,59 @@
-#<h2>Sign up</h2>
-#
-#<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
-# <%= devise_error_messages! %>
-#
-# <div class="field">
-# <%= f.label :email %><br />
-# <%= f.email_field :email, autofocus: true %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password %>
-# <% if @validatable %>
-# <em>(<%= @minimum_password_length %> characters minimum)</em>
-# <% end %><br />
-# <%= f.password_field :password, autocomplete: "off" %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password_confirmation %><br />
-# <%= f.password_field :password_confirmation, autocomplete: "off" %>
-# </div>
-#
-# <div class="actions">
-# <%= f.submit "Sign up" %>
-# </div>
-#<% end %>
= devise_error_messages!
#form_login
= image_tag('logo-tps.png')
%br
%h2#gestionnaire_login Changement de mot de passe
%br
%br
#new_user
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
= f.hidden_field :reset_password_token
%h4
= f.label 'Nouveau mot de passe'
.input-group
.input-group-addon
%span.glyphicon.glyphicon-asterisk
= f.password_field :password, autofocus: true, autocomplete: "off", class: 'form-control'
%br
%h4
= f.label 'Retaper le mot de passe'
.input-group
.input-group-addon
%span.glyphicon.glyphicon-asterisk
= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control'
%br
%br
.actions
= f.submit "Changer", class:'btn btn-primary'
%br

View file

@ -1,16 +0,0 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "users/shared/links" %>

View file

@ -0,0 +1,50 @@
-#<h2>Sign up</h2>
-#
-#<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
-# <%= devise_error_messages! %>
-#
-# <div class="field">
-# <%= f.label :email %><br />
-# <%= f.email_field :email, autofocus: true %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password %>
-# <% if @validatable %>
-# <em>(<%= @minimum_password_length %> characters minimum)</em>
-# <% end %><br />
-# <%= f.password_field :password, autocomplete: "off" %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password_confirmation %><br />
-# <%= f.password_field :password_confirmation, autocomplete: "off" %>
-# </div>
-#
-# <div class="actions">
-# <%= f.submit "Sign up" %>
-# </div>
-#<% end %>
= devise_error_messages!
#form_login
= image_tag('logo-tps.png')
%br
%h2#gestionnaire_login Mot de passe oublié
%br
%br
#new_user
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
%h4
= f.label :email
.input-group
.input-group-addon
%span.glyphicon.glyphicon-user
= f.email_field :email, class: 'form-control', placeholder: 'Email'
%br
%br
.actions
= f.submit "Renvoyer", class:'btn btn-primary'
%br

View file

@ -1,7 +1,7 @@
.content#commentaires_flux{style:'width:100%;'} .content#commentaires_flux{style:'width:100%;'}
%div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'} %div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'}
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @facade.dossier.id }), class: 'form-inline', method: 'POST') do = form_tag(url_for({ controller: 'commentaires', action: :create, dossier_id: @facade.dossier.id }), class: 'form-inline', method: 'POST') do
%textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."} %textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."}
%input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'} %input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'}
%br %br
%br %br

View file

@ -4,17 +4,18 @@
.col-md-6.col-lg-6 .col-md-6.col-lg-6
%h2 Récapitulatif %h2 Récapitulatif
.col-md-6.col-lg-6 .col-md-6.col-lg-6
= form_tag "/users/dossiers/#{@facade.dossier.id}/archive", style:'margin-top:21px', action: :archive, method: :put do - if current_user.email == @facade.dossier.user.email
%button#archive.btn.btn-sm.btn-default.text-info{type: :button} = form_tag "/users/dossiers/#{@facade.dossier.id}/archive", style:'margin-top:21px', action: :archive, method: :put do
%i.fa.fa-eraser %button#archive.btn.btn-sm.btn-default.text-info{type: :button}
Archiver %i.fa.fa-eraser
#confirm Archiver
%button#cancel.btn.btn-sm.btn-danger{type: :button} #confirm
%i.fa.fa-remove %button#cancel.btn.btn-sm.btn-danger{type: :button}
Annuler %i.fa.fa-remove
%button#valid.btn.btn-sm.btn-success{type: :submit} Annuler
%i.fa.fa-check %button#valid.btn.btn-sm.btn-success{type: :submit}
Valider %i.fa.fa-check
Valider
.col-md-5.col-lg-5 .col-md-5.col-lg-5
@ -22,7 +23,7 @@
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'} %h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
= "Dossier n°#{@facade.dossier.id}" = "Dossier n°#{@facade.dossier.id}"
- unless gestionnaire_signed_in? - if user_signed_in? && current_user.email == @facade.dossier.user.email
-if @facade.dossier.validated? -if @facade.dossier.validated?
%br %br
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @facade.dossier.id}), method: 'POST') do = form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @facade.dossier.id}), method: 'POST') do
@ -36,4 +37,4 @@
= render partial: '/dossiers/infos_dossier' = render partial: '/dossiers/infos_dossier'
%br %br
= render partial: 'commentaires_flux' = render partial: '/users/recapitulatif/commentaires_flux'

View file

@ -1,39 +0,0 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>

View file

@ -3,16 +3,14 @@
%br %br
%h2#login_user Connexion %h2#login_user Connexion
-#%a.btn_fc#btn_fcp{href: '/france_connect/particulier'} %a.btn_fc#btn_fcp{href: '/france_connect/particulier'}
-# = image_tag 'franceconnect_logo.png' = image_tag 'franceconnect_logo.png'
-#
-#%br
-#%a.text-info{href: 'https://fcp.integ01.dev-franceconnect.fr/a-propos', target: '_blank'}
-# Quest-ce que FranceConnect ?
-#
-#%hr
%br %br
%a.text-info{href: 'https://fcp.integ01.dev-franceconnect.fr/a-propos', target: '_blank'}
Quest-ce que FranceConnect ?
%hr
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
%h4 %h4
= f.label :email = f.label :email
@ -32,19 +30,18 @@
.actions .actions
= f.submit "Se connecter", class:'btn btn-primary' = f.submit "Se connecter", class:'btn btn-primary'
%br %br
= render "users/shared/links" = render "users/shared/links"
%br
%div{style:'text-align:center'} %div{style:'text-align:center'}
\- -#\-
%br -#%br
%a{href: '/gestionnaires/sign_in'} -#%a{href: '/gestionnaires/sign_in'}
= 'Accompagnateur' -# = 'Accompagnateur'
%br -#%br
%a{href: '/administrateurs/sign_in'} -#%a{href: '/administrateurs/sign_in'}
= 'Administrateur' -# = 'Administrateur'
%br
\- \-
%br %br
%a{href: 'https://github.com/sgmap/tps/releases', target: '_blank'} %a{href: 'https://github.com/sgmap/tps/releases', target: '_blank'}

View file

@ -1,3 +1,6 @@
<%- if devise_mapping.registerable? && controller_name != 'registrations' %> <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "S'inscrire", new_registration_path(resource_name) %><br /> <%= link_to "S'inscrire", new_registration_path(resource_name), {class: 'btn btn-sm btn-success'} %><br />
<% end -%> <% end -%>
<br>
<%= link_to "Mot de passe oublié ?", new_password_path(resource_name) %><br />

View file

@ -52,7 +52,19 @@ fr:
blank: ': Le mot de passe est vide' blank: ': Le mot de passe est vide'
password_confirmation: password_confirmation:
confirmation: ': Les deux mots de passe ne correspondent pas' confirmation: ': Les deux mots de passe ne correspondent pas'
invite:
attributes:
email:
blank: est vide
taken: ': Invitation déjà envoyée'
gestionnaire:
attributes:
email:
invalid: invalide
taken: déjà utilisé
blank: est vide
password:
blank: ': Le mot de passe est vide'
devise: devise:
confirmations: confirmations:

View file

@ -10,7 +10,8 @@ Rails.application.routes.draw do
devise_for :users, controllers: { devise_for :users, controllers: {
sessions: 'users/sessions', sessions: 'users/sessions',
registrations: 'users/registrations' registrations: 'users/registrations',
passwords: 'users/passwords'
} }
root 'root#index' root 'root#index'
@ -25,8 +26,15 @@ Rails.application.routes.draw do
end end
get 'demo' => 'demo#index' get 'demo' => 'demo#index'
get 'users' => 'users#index'
namespace :users do namespace :users do
namespace :dossiers do
resources :invites, only: [:index, :show]
post '/commentaire' => 'commentaires#create'
end
resources :dossiers do resources :dossiers do
get '/description' => 'description#show' get '/description' => 'description#show'
get '/description/error' => 'description#error' get '/description/error' => 'description#error'
@ -66,6 +74,7 @@ Rails.application.routes.draw do
resource :pieces_justificatives, only: [:show, :update] resource :pieces_justificatives, only: [:show, :update]
resources :pieces_justificatives, only: :destroy resources :pieces_justificatives, only: :destroy
end end
resources :gestionnaires, only: [:index, :create, :destroy]
end end
get 'backoffice' => 'backoffice#index' get 'backoffice' => 'backoffice#index'
@ -78,6 +87,8 @@ Rails.application.routes.draw do
resources :dossiers do resources :dossiers do
post 'valid' => 'dossiers#valid' post 'valid' => 'dossiers#valid'
post 'close' => 'dossiers#close' post 'close' => 'dossiers#close'
post 'invites' => '/invites#create'
end end
resources :commentaires, only: [:create] resources :commentaires, only: [:create]

View file

@ -0,0 +1,5 @@
class AddCerfaFlagToProcedure < ActiveRecord::Migration
def change
add_column :procedures, :cerfa_flag, :boolean, :default => false
end
end

View file

@ -0,0 +1,11 @@
class CreateInvites < ActiveRecord::Migration
def change
create_table :invites do |t|
t.string :email
t.string :email_sender
end
add_reference :invites, :dossier, references: :dossiers
add_reference :invites, :user, references: :users
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160127170437) do ActiveRecord::Schema.define(version: 20160204155519) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -159,6 +159,13 @@ ActiveRecord::Schema.define(version: 20160127170437) do
add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree
add_index "gestionnaires", ["reset_password_token"], name: "index_gestionnaires_on_reset_password_token", unique: true, using: :btree add_index "gestionnaires", ["reset_password_token"], name: "index_gestionnaires_on_reset_password_token", unique: true, using: :btree
create_table "invites", force: :cascade do |t|
t.string "email"
t.string "email_sender"
t.integer "dossier_id"
t.integer "user_id"
end
create_table "module_api_cartos", force: :cascade do |t| create_table "module_api_cartos", force: :cascade do |t|
t.integer "procedure_id" t.integer "procedure_id"
t.boolean "use_api_carto", default: false t.boolean "use_api_carto", default: false
@ -189,6 +196,7 @@ ActiveRecord::Schema.define(version: 20160127170437) do
t.boolean "archived", default: false t.boolean "archived", default: false
t.boolean "euro_flag", default: false t.boolean "euro_flag", default: false
t.string "logo" t.string "logo"
t.boolean "cerfa_flag", default: false
end end
create_table "quartier_prioritaires", force: :cascade do |t| create_table "quartier_prioritaires", force: :cascade do |t|

38
lib/tasks/dev.rake Normal file
View file

@ -0,0 +1,38 @@
namespace :dev do
desc 'Initialise dev environment'
task :init do
puts 'start initialisation'
Rake::Task['dev:generate_token_file'].invoke
Rake::Task['dev:generate_franceconnect_file'].invoke
puts 'end initialisation'
end
task :generate_token_file do
puts 'creating token.rb file'
res = `rake secret`.gsub("\n", '')
file = File.new('config/initializers/token.rb', 'w+')
comment = <<EOF
EOF
file.write(comment)
file.write("TPS::Application.config.SIADETOKEN = '#{res}'")
file.close
end
task :generate_franceconnect_file do
file = File.new('config/france_connect.yml', 'w+')
comment = <<EOF
particulier_identifier: plop
particulier_secret: plip
particulier_redirect_uri: 'http://localhost:3000/france_connect/particulier/callback'
particulier_authorization_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize'
particulier_token_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/token'
particulier_userinfo_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/userinfo'
particulier_logout_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/logout'
EOF
file.write(comment)
file.close
end
end

View file

@ -0,0 +1,106 @@
require 'spec_helper'
describe Admin::GestionnairesController, type: :controller do
let(:admin) { create(:administrateur) }
before do
sign_in admin
end
describe 'GET #index' do
subject { get :index }
it { expect(subject.status).to eq(200) }
end
describe 'POST #create' do
let(:email) { 'test@plop.com' }
subject { post :create, gestionnaire: { email: email } }
context 'When email is valid' do
before do
subject
end
it { expect(response.status).to eq(302) }
it { expect(response).to redirect_to admin_gestionnaires_path }
describe 'Gestionnaire attributs in database' do
let(:gestionnaire) { Gestionnaire.last }
it { expect(gestionnaire.email).to eq(email) }
it { expect(gestionnaire.administrateur_id).to eq(admin.id) }
end
end
context 'when email is not valid' do
before do
subject
end
let(:email) { 'piou' }
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
end
context 'when email is empty' do
before do
subject
end
let(:email) { '' }
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
it 'Notification email is not send' do
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
end
end
context ' when email already exists' do
let(:email) { 'test@plop.com' }
before do
subject
post :create, gestionnaire: { email: email }
end
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
end
context 'Email notification' do
it 'Notification email is sent when email is valid' do
expect(GestionnaireMailer).to receive(:new_gestionnaire).and_return(GestionnaireMailer)
expect(GestionnaireMailer).to receive(:deliver_now!)
subject
end
context 'is not sent when email is not valid' do
let(:email) { 'testplop.com' }
it {
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
subject
}
end
it 'is not sent when email already exists' do
subject
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
subject
end
end
end
describe 'DELETE #destroy' do
let(:email) { 'test@plop.com' }
before do
post :create, gestionnaire: { email: email }
end
let(:gestionnaire) { Gestionnaire.last }
let(:response) { delete :destroy, id: gestionnaire.id }
it { expect(response.status).to eq(302) }
it { expect(response).to redirect_to admin_gestionnaires_path }
it { expect{response}.to change(Gestionnaire, :count).by(-1) }
end
end

View file

@ -6,10 +6,11 @@ describe API::V1::DossiersController do
let(:wrong_procedure) { create(:procedure) } let(:wrong_procedure) { create(:procedure) }
it { expect(described_class).to be < APIController } it { expect(described_class).to be < APIController }
describe 'GET index' do describe 'GET index' do
let(:response) { get :index, token: admin.api_token, procedure_id: procedure_id } let(:response) { get :index, token: admin.api_token, procedure_id: procedure_id }
subject { response }
subject { response }
context 'when procedure is not found' do context 'when procedure is not found' do
let(:procedure_id) { 99_999_999 } let(:procedure_id) { 99_999_999 }
@ -24,10 +25,13 @@ describe API::V1::DossiersController do
context 'when procedure is found and belongs to admin' do context 'when procedure is found and belongs to admin' do
let(:procedure_id) { procedure.id } let(:procedure_id) { procedure.id }
let(:date_creation) { Time.local(2008, 9, 1, 10, 5, 0) } let(:date_creation) { Time.local(2008, 9, 1, 10, 5, 0) }
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } } let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } }
let(:body) { JSON.parse(response.body, symbolize_names: true) } let(:body) { JSON.parse(response.body, symbolize_names: true) }
it { expect(response.code).to eq('200') } it { expect(response.code).to eq('200') }
it { expect(body).to have_key :pagination } it { expect(body).to have_key :pagination }
it { expect(body).to have_key :dossiers } it { expect(body).to have_key :dossiers }
describe 'pagination' do describe 'pagination' do
@ -54,14 +58,17 @@ describe API::V1::DossiersController do
context 'when there are multiple pages' do context 'when there are multiple pages' do
let(:response) { get :index, token: admin.api_token, procedure_id: procedure_id, page: 2 } let(:response) { get :index, token: admin.api_token, procedure_id: procedure_id, page: 2 }
let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure) }
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure) } let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
before do before do
allow(Dossier).to receive(:per_page).and_return(1) allow(Dossier).to receive(:per_page).and_return(1)
end end
describe 'pagination' do describe 'pagination' do
subject { body[:pagination] } subject { body[:pagination] }
it { expect(subject[:page]).to eq(2) } it { expect(subject[:page]).to eq(2) }
it { expect(subject[:resultats_par_page]).to eq(1) } it { expect(subject[:resultats_par_page]).to eq(1) }
it { expect(subject[:nombre_de_page]).to eq(3) } it { expect(subject[:nombre_de_page]).to eq(3) }

View file

@ -43,5 +43,20 @@ describe Users::CommentairesController, type: :controller do
end end
end end
end end
context 'when invite is connected' do
let(:invite) { create(:invite, :with_user, dossier: dossier) }
before do
sign_in invite.user
dossier.replied!
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
dossier.reload
end
it { is_expected.to redirect_to users_dossiers_invite_path(invite.id) }
it { expect(dossier.state).to eq 'replied' }
end
end end
end end

View file

@ -0,0 +1,87 @@
require 'spec_helper'
describe InvitesController, type: :controller do
let(:dossier) { create(:dossier) }
let(:email) { 'plop@octo.com' }
describe '#POST create' do
let(:invite) { Invite.last }
before do
sign_in create(:gestionnaire)
end
subject { post :create, dossier_id: dossier.id, email: email }
it { expect { subject }.to change(Invite, :count).by(1) }
context 'when email is assign to an user' do
let! (:user) { create(:user, email: email) }
before do
subject
end
it { expect(invite.user).to eq user }
it { expect(flash[:notice]).to be_present }
end
context 'when email is not assign to an user' do
before do
subject
end
it { expect(invite.user).to be_nil }
it { expect(flash[:notice]).to be_present }
end
describe 'not an email' do
context 'when email is not valid' do
let(:email) { 'plip.com' }
before do
subject
end
it { expect { subject }.not_to change(Invite, :count) }
it { expect(flash[:alert]).to be_present }
end
context 'when email is already used' do
let!(:invite) { create(:invite, dossier: dossier) }
before do
subject
end
it { expect { subject }.not_to change(Invite, :count) }
it { expect(flash[:alert]).to be_present }
end
end
describe 'send invitation email' do
context 'when user does not exist' do
it 'send email' do
expect(InviteMailer).to receive(:invite_guest).and_return(InviteMailer)
expect(InviteMailer).to receive(:deliver_now!)
subject
end
end
context 'when user exist' do
before do
create :user, email: email
end
it 'send email' do
expect(InviteMailer).to receive(:invite_user).and_return(InviteMailer)
expect(InviteMailer).to receive(:deliver_now!)
subject
end
end
end
end
end

View file

@ -29,6 +29,12 @@ describe RootController, type: :controller do
end end
context 'when nobody is connected' do context 'when nobody is connected' do
it { expect(subject).to redirect_to(new_user_session_path) } render_views
before do
subject
end
it { expect(response.body).to have_css('#landing') }
end end
end end

View file

@ -7,7 +7,7 @@ RSpec.describe Users::CarteController, type: :controller do
let(:procedure) { create(:procedure, module_api_carto: module_api_carto) } let(:procedure) { create(:procedure, module_api_carto: module_api_carto) }
let(:dossier) { create(:dossier, procedure: procedure) } let(:dossier) { create(:dossier, procedure: procedure) }
let(:dossier_with_no_carto) { create(:dossier, :with_procedure) } let(:dossier_with_no_carto) { create(:dossier) }
let!(:entreprise) { create(:entreprise, dossier: dossier) } let!(:entreprise) { create(:entreprise, dossier: dossier) }
let!(:etablissement) { create(:etablissement, dossier: dossier) } let!(:etablissement) { create(:etablissement, dossier: dossier) }
let(:bad_dossier_id) { Dossier.count + 1000 } let(:bad_dossier_id) { Dossier.count + 1000 }
@ -34,7 +34,7 @@ RSpec.describe Users::CarteController, type: :controller do
end end
context 'when dossiers procedure does not have api carto actived' do context 'when dossiers procedure does not have api carto actived' do
let(:dossier) { create(:dossier, :with_procedure) } let(:dossier) { create(:dossier) }
before do before do
get :show, dossier_id: dossier.id get :show, dossier_id: dossier.id
@ -86,7 +86,7 @@ RSpec.describe Users::CarteController, type: :controller do
end end
context 'En train de modifier la localisation' do context 'En train de modifier la localisation' do
let(:dossier) { create(:dossier, :with_procedure, state: 'initiated') } let(:dossier) { create(:dossier, state: 'initiated') }
before do before do
post :save, dossier_id: dossier.id, json_latlngs: '' post :save, dossier_id: dossier.id, json_latlngs: ''
end end
@ -109,7 +109,7 @@ RSpec.describe Users::CarteController, type: :controller do
context 'when json_latlngs params is empty' do context 'when json_latlngs params is empty' do
context 'when dossier have quartier prioritaire in database' do context 'when dossier have quartier prioritaire in database' do
let!(:dossier) { create(:dossier, :with_procedure, :with_two_quartier_prioritaires) } let!(:dossier) { create(:dossier, :with_two_quartier_prioritaires) }
before do before do
dossier.reload dossier.reload
@ -156,7 +156,7 @@ RSpec.describe Users::CarteController, type: :controller do
context 'when json_latlngs params is empty' do context 'when json_latlngs params is empty' do
context 'when dossier have cadastres in database' do context 'when dossier have cadastres in database' do
let!(:dossier) { create(:dossier, :with_procedure, :with_two_cadastres) } let!(:dossier) { create(:dossier, :with_two_cadastres) }
before do before do
dossier.reload dossier.reload
@ -200,7 +200,7 @@ RSpec.describe Users::CarteController, type: :controller do
describe '#get_position' do describe '#get_position' do
context 'Geocodeur renvoie les positions par defaut' do context 'Geocodeur renvoie les positions par defaut' do
let(:etablissement) { create(:etablissement, adresse: bad_adresse, numero_voie: 'dzj', type_voie: 'fzjfk', nom_voie: 'hdidjkz', complement_adresse: 'fjef', code_postal: 'fjeiefk', localite: 'zjfkfz') } let(:etablissement) { create(:etablissement, adresse: bad_adresse, numero_voie: 'dzj', type_voie: 'fzjfk', nom_voie: 'hdidjkz', complement_adresse: 'fjef', code_postal: 'fjeiefk', localite: 'zjfkfz') }
let(:dossier) { create(:dossier, :with_procedure, etablissement: etablissement) } let(:dossier) { create(:dossier, etablissement: etablissement) }
before do before do
stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/) stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/)

View file

@ -2,9 +2,12 @@ require 'spec_helper'
describe Users::DescriptionController, type: :controller do describe Users::DescriptionController, type: :controller do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) }
let!(:dossier) { create(:dossier, procedure: procedure, user: user) }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
let(:bad_dossier_id) { Dossier.count + 10 } let(:bad_dossier_id) { Dossier.count + 10000 }
before do before do
sign_in dossier.user sign_in dossier.user
@ -117,44 +120,68 @@ describe Users::DescriptionController, type: :controller do
it { is_expected.to render_template(:show) } it { is_expected.to render_template(:show) }
it { expect(flash[:alert]).to be_present } it { expect(flash[:alert]).to be_present }
end end
end end
context 'Sauvegarde du CERFA PDF' do context 'Quand la procédure accepte les CERFA' do
before do context 'Sauvegarde du CERFA PDF' do
post :create, dossier_id: dossier_id, before do
nom_projet: nom_projet, post :create, dossier_id: dossier_id,
description: description, nom_projet: nom_projet,
cerfa_pdf: cerfa_pdf description: description,
dossier.reload cerfa_pdf: cerfa_pdf
end dossier.reload
context 'un CERFA PDF est envoyé' do
subject { dossier.cerfa }
it 'content' do
expect(subject['content']).to eq(name_piece_justificative)
end end
it 'dossier_id' do context 'un CERFA PDF est envoyé' do
expect(subject.dossier_id).to eq(dossier_id) subject { dossier.cerfa }
it 'content' do
expect(subject['content']).to eq(name_piece_justificative)
end
it 'dossier_id' do
expect(subject.dossier_id).to eq(dossier_id)
end
end
context 'les anciens CERFA PDF sont écrasées à chaque fois' do
let(:cerfas) { Cerfa.find_by_dossier_id(dossier_id) }
before do
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, cerfa_pdf: cerfa_pdf
end
it 'il n\'y a qu\'un CERFA PDF par dossier' do
expect(cerfas.class).to eq Cerfa
end
end
context 'pas de CERFA PDF' do
# TODO à écrire
end end
end end
end
context 'les anciens CERFA PDF sont écrasées à chaque fois' do context 'Quand la procédure n\'accepte pas les CERFA' do
it 'il n\'y a qu\'un CERFA PDF par dossier' do context 'Sauvegarde du CERFA PDF' do
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, cerfa_pdf: cerfa_pdf let!(:procedure) { create(:procedure) }
cerfa = PieceJustificative.where(type_de_piece_justificative_id: '0', dossier_id: dossier_id) before do
expect(cerfa.many?).to eq(false) post :create, dossier_id: dossier_id,
nom_projet: nom_projet,
description: description,
cerfa_pdf: cerfa_pdf
dossier.reload
end end
end
context 'pas de CERFA PDF' do context 'un CERFA PDF est envoyé' do
# TODO à écrire it { expect(dossier.cerfa_available?).to be_falsey }
end
end end
end end
context 'Sauvegarde des champs' do context 'Sauvegarde des champs' do
let(:champs_dossier) { dossier.champs } let(:champs_dossier) { dossier.champs }
let(:dossier_champs_first) { 'test value' } let(:dossier_champs_first) { 'test value' }
before do before do
post :create, {dossier_id: dossier_id, post :create, {dossier_id: dossier_id,
nom_projet: nom_projet, nom_projet: nom_projet,

View file

@ -345,4 +345,17 @@ describe Users::DossiersController, type: :controller do
end end
end end
end end
describe 'GET #invite' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, liste: :invite
expect(response).to have_http_status(200)
end
end
end
end end

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe Users::RecapitulatifController, type: :controller do describe Users::RecapitulatifController, type: :controller do
let(:dossier) { create(:dossier, :with_procedure, state:'initiated') } let(:dossier) { create(:dossier, state:'initiated') }
let(:bad_dossier_id) { Dossier.count + 100000 } let(:bad_dossier_id) { Dossier.count + 100000 }
before do before do

View file

@ -23,6 +23,19 @@ describe Users::RegistrationsController, type: :controller do
subject subject
end end
describe '#check_invite!' do
let!(:invite) { create :invite, email: email }
let!(:invite2) { create :invite, email: email }
before do
subject
end
it 'the new user is connect at his two invite' do
expect(User.last.invites.size).to eq 2
end
end
end end
context 'when user is not correct' do context 'when user is not correct' do

View file

@ -3,7 +3,14 @@ FactoryGirl.define do
nom_projet "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger" nom_projet "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger"
description "Ma super description" description "Ma super description"
state 'draft' state 'draft'
association :user, factory:[:user] association :user, factory: [:user]
before(:create) do |dossier, _evaluator|
unless dossier.procedure
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ)
dossier.procedure = procedure
end
end
trait :with_entreprise do trait :with_entreprise do
after(:build) do |dossier, _evaluator| after(:build) do |dossier, _evaluator|
@ -14,13 +21,6 @@ FactoryGirl.define do
end end
end end
trait :with_procedure do
after(:build) do |dossier, _evaluator|
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ)
dossier.procedure = procedure
end
end
trait :with_two_quartier_prioritaires do trait :with_two_quartier_prioritaires do
after(:build) do |dossier, _evaluator| after(:build) do |dossier, _evaluator|

20
spec/factories/invite.rb Normal file
View file

@ -0,0 +1,20 @@
FactoryGirl.define do
factory :invite do
email 'plop@octo.com'
after(:build) do |invite, _evaluator|
if invite.dossier.nil?
invite.dossier = create(:dossier)
end
end
trait :with_user do
after(:build) do |invite, _evaluator|
if invite.user.nil?
invite.user = create(:user)
invite.email = invite.user.email
end
end
end
end
end

View file

@ -32,7 +32,7 @@ feature 'Administrator connection' do
page.find_by_id('admin_sign_out').click page.find_by_id('admin_sign_out').click
end end
scenario 'admin is redireted to home page' do scenario 'admin is redireted to home page' do
expect(page).to have_css('#login_user') expect(page).to have_css('#landing')
end end
end end
context 'when clicking on profile' do context 'when clicking on profile' do

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
feature 'add commentaire on backoffice' do feature 'add commentaire on backoffice' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) } let(:dossier) { create(:dossier, :with_entreprise) }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') } let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') }
let(:email_commentaire) { 'test@test.com' } let(:email_commentaire) { 'test@test.com' }

View file

@ -1,7 +1,8 @@
require 'spec_helper' require 'spec_helper'
feature 'user is on description page' do feature 'user is on description page' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) } let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, cerfa_flag: true) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) }
before do before do
visit users_dossier_description_path dossier visit users_dossier_description_path dossier

View file

@ -3,13 +3,13 @@ require 'spec_helper'
feature 'user access to the list of his dossier' do feature 'user access to the list of his dossier' do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:last_updated_dossier) { create(:dossier, :with_procedure, user: user, state: 'replied')} let!(:last_updated_dossier) { create(:dossier, user: user, state: 'replied')}
let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier', state: 'replied') } let!(:dossier1) { create(:dossier, user: user, nom_projet: 'mon permier dossier', state: 'replied') }
let!(:dossier2) { create(:dossier, nom_projet: 'mon deuxième dossier') } let!(:dossier2) { create(:dossier, nom_projet: 'mon deuxième dossier') }
before do before do
last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie') last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie')
visit root_path visit new_user_session_path
within('#new_user') do within('#new_user') do
page.find_by_id('user_email').set user.email page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password page.find_by_id('user_password').set user.password

View file

@ -3,7 +3,7 @@ require "rails_helper"
RSpec.describe NotificationMailer, type: :mailer do RSpec.describe NotificationMailer, type: :mailer do
describe ".new_answer" do describe ".new_answer" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) } let(:dossier) { create(:dossier, user: user) }
subject(:subject) { described_class.new_answer(dossier) } subject(:subject) { described_class.new_answer(dossier) }
@ -14,7 +14,7 @@ RSpec.describe NotificationMailer, type: :mailer do
describe ".dossier_validated" do describe ".dossier_validated" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) } let(:dossier) { create(:dossier, user: user) }
subject(:subject) { described_class.dossier_validated(dossier) } subject(:subject) { described_class.dossier_validated(dossier) }
@ -25,7 +25,7 @@ RSpec.describe NotificationMailer, type: :mailer do
describe ".dossier_submitted" do describe ".dossier_submitted" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) } let(:dossier) { create(:dossier, user: user) }
subject(:subject) { described_class.dossier_submitted(dossier) } subject(:subject) { described_class.dossier_submitted(dossier) }

View file

@ -24,6 +24,7 @@ describe Dossier do
it { is_expected.to have_one(:etablissement) } it { is_expected.to have_one(:etablissement) }
it { is_expected.to have_one(:entreprise) } it { is_expected.to have_one(:entreprise) }
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:invites) }
end end
describe 'delegation' do describe 'delegation' do
@ -47,7 +48,7 @@ describe Dossier do
end end
describe 'methods' do describe 'methods' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) } let(:dossier) { create(:dossier, :with_entreprise, user: user) }
let(:entreprise) { dossier.entreprise } let(:entreprise) { dossier.entreprise }
let(:etablissement) { dossier.etablissement } let(:etablissement) { dossier.etablissement }
@ -63,13 +64,27 @@ describe Dossier do
end end
describe 'creation' do describe 'creation' do
it 'create default cerfa' do describe 'Procedure accepts cerfa upload' do
expect { described_class.create(user: user) }.to change { Cerfa.count }.by(1) let(:procedure) { create(:procedure, cerfa_flag: true) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, user: user) }
it 'create default cerfa' do
expect { subject.to change(Cerfa.count).by(1) }
expect { subject.cerfa_available.to be_truthy }
end
it 'link cerfa to dossier' do
expect { subject.cerfa.to eq(Cerfa.last) }
end
end end
it 'link cerfa to dossier' do describe 'Procedure does not accept cerfa upload' do
dossier = described_class.create let(:procedure) { create(:procedure, cerfa_flag: false) }
expect(dossier.cerfa).to eq(Cerfa.last) let(:dossier) { create(:dossier, :with_entreprise, user: user) }
it 'default cerfa is not created' do
expect { subject.to change(Cerfa.count).by(0) }
expect { subject.cerfa.to eq(nil) }
expect { subject.cerfa_available.to be_falsey }
end
end end
end end
@ -87,7 +102,7 @@ describe Dossier do
describe '#build_default_pieces_justificatives' do describe '#build_default_pieces_justificatives' do
context 'when dossier is linked to a procedure' do context 'when dossier is linked to a procedure' do
let(:dossier) { create(:dossier, :with_procedure, user: user) } let(:dossier) { create(:dossier, user: user) }
it 'build all pieces justificatives needed' do it 'build all pieces justificatives needed' do
expect(dossier.pieces_justificatives.count).to eq(2) expect(dossier.pieces_justificatives.count).to eq(2)
end end
@ -96,7 +111,8 @@ describe Dossier do
describe '#build_default_champs' do describe '#build_default_champs' do
context 'when dossier is linked to a procedure' do context 'when dossier is linked to a procedure' do
let(:dossier) { create(:dossier, :with_procedure, user: user) } let(:dossier) { create(:dossier, user: user) }
it 'build all champs needed' do it 'build all champs needed' do
expect(dossier.champs.count).to eq(1) expect(dossier.champs.count).to eq(1)
end end
@ -104,20 +120,21 @@ describe Dossier do
end end
describe '#save' do describe '#save' do
subject { create(:dossier, procedure_id: nil, user: user) } subject { build(:dossier, procedure: procedure, user: user) }
let!(:procedure) { create(:procedure) } let!(:procedure) { create(:procedure) }
context 'when is linked to a procedure' do context 'when is linked to a procedure' do
it 'creates default pieces justificatives' do it 'creates default pieces justificatives' do
expect(subject).to receive(:build_default_pieces_justificatives) expect(subject).to receive(:build_default_pieces_justificatives)
subject.update_attributes(procedure_id: procedure.id) subject.save
end end
it 'creates default champs' do it 'creates default champs' do
expect(subject).to receive(:build_default_champs) expect(subject).to receive(:build_default_champs)
subject.update_attributes(procedure_id: procedure.id) subject.save
end end
end end
context 'when is not linked to a procedure' do context 'when is not linked to a procedure' do
subject { create(:dossier, procedure: procedure, user: user) }
it 'does not create default pieces justificatives' do it 'does not create default pieces justificatives' do
expect(subject).not_to receive(:build_default_pieces_justificatives) expect(subject).not_to receive(:build_default_pieces_justificatives)
subject.update_attributes(description: 'plop') subject.update_attributes(description: 'plop')
@ -382,7 +399,7 @@ describe Dossier do
end end
end end
context 'gestionnaire backoffice methods' do describe 'gestionnaire backoffice methods' do
let(:admin) { create(:administrateur) } let(:admin) { create(:administrateur) }
let(:admin_2) { create(:administrateur) } let(:admin_2) { create(:administrateur) }
@ -504,4 +521,26 @@ describe Dossier do
end end
end end
end end
describe '#cerfa_available?' do
let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) }
let(:dossier) { create(:dossier, procedure: procedure)}
context 'Procedure accepts CERFA' do
let(:cerfa_flag) { true }
context 'when cerfa is not uploaded' do
it { expect(dossier.cerfa_available?).to be_falsey }
end
context 'when cerfa is uploaded' do
let(:dossier_with_cerfa) { create(:dossier, procedure: procedure) }
before do
allow_any_instance_of(Cerfa).to receive(:empty?).and_return(false)
end
it { expect(dossier_with_cerfa.cerfa_available?).to be_truthy }
end
end
context 'Procedure does not accept CERFA' do
let(:cerfa_flag) { false }
it { expect(dossier.cerfa_available?).to be_falsey }
end
end
end end

View file

@ -0,0 +1,38 @@
require 'spec_helper'
describe Invite do
describe 'database columns' do
it { is_expected.to have_db_column(:email) }
end
describe 'associations' do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to belong_to(:user) }
end
describe 'an email can be used for multiple dossier' do
let(:email1) { 'plop@octo.com' }
let!(:dossier1) { create(:dossier) }
let!(:dossier2) { create(:dossier) }
context 'when an email is invite on two dossier' do
subject do
create(:invite, email: email1, dossier: dossier1)
create(:invite, email: email1, dossier: dossier2)
end
it { expect{ subject }.to change(Invite, :count).by(2) }
end
context 'when an email is invite twice on a dossier' do
subject do
create(:invite, email: email1, dossier: dossier1)
create(:invite, email: email1, dossier: dossier1)
end
it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid }
end
end
end

View file

@ -17,6 +17,7 @@ describe Procedure do
it { is_expected.to have_db_column(:test) } it { is_expected.to have_db_column(:test) }
it { is_expected.to have_db_column(:euro_flag) } it { is_expected.to have_db_column(:euro_flag) }
it { is_expected.to have_db_column(:logo) } it { is_expected.to have_db_column(:logo) }
it { is_expected.to have_db_column(:cerfa_flag) }
end end
describe 'validation' do describe 'validation' do

View file

@ -20,6 +20,7 @@ describe User, type: :model do
end end
describe 'associations' do describe 'associations' do
it { is_expected.to have_many(:dossiers) } it { is_expected.to have_many(:dossiers) }
it { is_expected.to have_many(:invites) }
end end
describe '#find_for_france_connect' do describe '#find_for_france_connect' do
let(:siret) { '00000000000000' } let(:siret) { '00000000000000' }

View file

@ -75,6 +75,7 @@ RSpec.configure do |config|
config.infer_spec_type_from_file_location! config.infer_spec_type_from_file_location!
config.tty = true config.tty = true
config.use_transactional_fixtures = false config.use_transactional_fixtures = false
config.infer_base_class_for_anonymous_controllers = false config.infer_base_class_for_anonymous_controllers = false

View file

@ -0,0 +1,34 @@
require 'spec_helper'
describe 'admin/gestionnaires/index.html.haml', type: :view do
let(:token) { 'super_token' }
let(:admin) { create(:administrateur, api_token: token) }
before do
assign(:gestionnaires, (smart_listing_create :gestionnaires,
admin.gestionnaires,
partial: "admin/gestionnaires/list",
array: true))
assign(:gestionnaire, Gestionnaire.new())
end
context 'Aucun gestionnaire' do
before do
render
end
it { expect(rendered).to have_content('Aucun gestionnaire') }
end
context 'Ajout d\'un gestionnaire' do
before do
create(:gestionnaire, administrateur: admin)
admin.reload
assign(:gestionnaires, (smart_listing_create :gestionnaires,
admin.gestionnaires,
partial: "admin/gestionnaires/list",
array: true))
render
end
it { expect(rendered).to match(/plop\d+@plop.com/) }
end
end

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'backoffice/dossiers/show.html.haml', type: :view do describe 'backoffice/dossiers/show.html.haml', type: :view do
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, state: state) } let!(:dossier) { create(:dossier, :with_entreprise, state: state) }
let(:state) { 'draft' } let(:state) { 'draft' }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
let(:gestionnaire) { create(:gestionnaire) } let(:gestionnaire) { create(:gestionnaire) }
@ -11,7 +11,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
assign(:facade, (DossierFacades.new dossier.id, gestionnaire.email)) assign(:facade, (DossierFacades.new dossier.id, gestionnaire.email))
end end
context 'on the dossier admin page' do context 'on the dossier gestionnaire page' do
before do before do
render render
end end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe 'users/carte/show.html.haml', type: :view do describe 'users/carte/show.html.haml', type: :view do
let(:state) { 'draft' } let(:state) { 'draft' }
let(:dossier) { create(:dossier, :with_procedure, state: state) } let(:dossier) { create(:dossier, state: state) }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
before do before do

View file

@ -2,7 +2,9 @@ require 'spec_helper'
describe 'users/description/show.html.haml', type: :view do describe 'users/description/show.html.haml', type: :view do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) } let(:cerfa_flag) { true }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: cerfa_flag) }
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
before do before do
@ -67,7 +69,7 @@ describe 'users/description/show.html.haml', type: :view do
context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do
let!(:dossier) do let!(:dossier) do
create(:dossier, :with_procedure, create(:dossier,
nom_projet: 'Projet de test', nom_projet: 'Projet de test',
description: 'Description de test', description: 'Description de test',
user: user) user: user)
@ -125,4 +127,46 @@ describe 'users/description/show.html.haml', type: :view do
end end
end end
end end
context 'Envoi des CERFA désactivé' do
let!(:cerfa_flag) { false }
before do
render
end
it { expect(rendered).to_not have_css("#cerfa_flag") }
it { expect(rendered).to_not have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') }
end
describe 'display title Documents administratifs' do
before do
render
end
let(:procedure) { create :procedure, lien_demarche: '' }
let(:dossier) { create(:dossier, procedure: procedure) }
context 'when dossier not have cerfa, piece justificative and demarche link' do
it { expect(rendered).not_to have_content 'Documents administratifs' }
end
context 'when dossier have pj' do
let(:dossier) { create(:dossier) }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have demarche link' do
let(:procedure) { create :procedure }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have cerfa flag true' do
let(:procedure) {create(:procedure, cerfa_flag: true)}
it { expect(rendered).to have_content 'Documents administratifs' }
end
end
end end

View file

@ -3,10 +3,10 @@ require 'spec_helper'
describe 'users/dossiers/index.html.haml', type: :view do describe 'users/dossiers/index.html.haml', type: :view do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:dossier) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate } let!(:dossier) { create(:dossier, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
let!(:dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied', nom_projet: 'projet répondu').decorate } let!(:dossier_2) { create(:dossier, user: user, state: 'replied', nom_projet: 'projet répondu').decorate }
let!(:dossier_3) { create(:dossier, :with_procedure, user: user, state: 'replied', nom_projet: 'projet répondu 2').decorate } let!(:dossier_3) { create(:dossier, user: user, state: 'replied', nom_projet: 'projet répondu 2').decorate }
let!(:dossier_termine) { create(:dossier, :with_procedure, user: user, state: 'closed').decorate } let!(:dossier_termine) { create(:dossier, user: user, state: 'closed').decorate }
describe 'params liste is a_traiter' do describe 'params liste is a_traiter' do
let(:dossiers_list) { user.dossiers.waiting_for_user('DESC') } let(:dossiers_list) { user.dossiers.waiting_for_user('DESC') }

View file

@ -3,8 +3,9 @@ require 'spec_helper'
describe 'users/dossiers/new.html.haml', type: :view do describe 'users/dossiers/new.html.haml', type: :view do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:euro_flag) { false } let(:euro_flag) { false }
let(:cerfa_flag) { false }
let(:logo) { '' } let(:logo) { '' }
let(:procedure) { create(:procedure, euro_flag: euro_flag, logo: logo) } let(:procedure) { create(:procedure, euro_flag: euro_flag, cerfa_flag: cerfa_flag, logo: logo) }
let!(:dossier) { create(:dossier, procedure: procedure, user: user).decorate } let!(:dossier) { create(:dossier, procedure: procedure, user: user).decorate }
before do before do
@ -31,7 +32,7 @@ describe 'users/dossiers/new.html.haml', type: :view do
describe 'logo procedure' do describe 'logo procedure' do
context 'procedure have no logo' do context 'procedure have no logo' do
it 'MPS logo is present' do it 'TPS logo is present' do
is_expected.to have_css("img[src='/assets#{asset_path('logo-tps.png')}']") is_expected.to have_css("img[src='/assets#{asset_path('logo-tps.png')}']")
end end
end end

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_procedure) } let(:dossier) { create(:dossier) }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' } let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') } let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }

View file

@ -1,11 +1,12 @@
require 'spec_helper' require 'spec_helper'
describe 'users/recapitulatif/show.html.haml', type: :view do describe 'users/recapitulatif/show.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto)) } let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto)) }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
let(:state) { 'draft' } let(:state) { 'draft' }
before do before do
sign_in dossier.user
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email)) assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
end end
@ -28,7 +29,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
expect(rendered).to have_content(dossier_id) expect(rendered).to have_content(dossier_id)
end end
context 'les liens de modifications' do describe 'les liens de modifications' do
context 'lien description' do context 'lien description' do
it 'le lien vers description est présent' do it 'le lien vers description est présent' do
expect(rendered).to have_css('#maj_infos') expect(rendered).to have_css('#maj_infos')
@ -128,5 +129,45 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end end
end end
end end
context 'when invite is logged' do
let!(:invite_user) { create(:user, email: 'invite@octo.com') }
before do
create(:invite) { create(:invite, email: invite_user.email, user: invite_user, dossier: dossier) }
sign_out dossier.user
sign_in invite_user
render
end
describe 'les liens de modifications' do
it 'describe link is not present' do
expect(rendered).not_to have_css('#maj_infos')
end
it 'map link is not present' do
expect(rendered).not_to have_css('#maj_carte')
end
it 'archive link is not present' do
expect(rendered).not_to have_content('Archiver')
end
end
context 'when dossier is validated' do
let(:state) { 'validated' }
before do
render
end
it 'submitted link is not present' do
expect(rendered).not_to have_content('Déposer mon dossier')
end
end
end
end end
end end

View file

@ -6,11 +6,14 @@ var franceConnectKit = {};
aboutUrl: '' aboutUrl: ''
}; };
franceConnectKit.init = function() { franceConnectKit.init = function () {
//initCurrentHostnameSource(); //initCurrentHostnameSource();
//includeFCCss(); //includeFCCss();
fconnect.currentHost = 'fcp.integ01.dev-franceconnect.fr' fconnect.currentHost = 'fcp.integ01.dev-franceconnect.fr';
if (window.location.hostname == 'tps.apientreprise.fr')
fconnect.currentHost = 'app.franceconnect.gouv.fr';
var fconnectProfile = document.getElementById('fconnect-profile'); var fconnectProfile = document.getElementById('fconnect-profile');
if (fconnectProfile) { if (fconnectProfile) {