add login for gestionnaire
This commit is contained in:
parent
b3383bec9f
commit
44173a17fb
26 changed files with 313 additions and 142 deletions
|
@ -1,5 +1,5 @@
|
|||
class Admin::DossierController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
|
@ -8,7 +8,7 @@ class Admin::DossierController < ApplicationController
|
|||
@pieces_justificatives = @dossier.pieces_justificatives
|
||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
||||
@commentaires = @commentaires.all.decorate
|
||||
@commentaire_email = current_user.email
|
||||
@commentaire_email = current_gestionnaire.email
|
||||
|
||||
@procedure = @dossier.procedure
|
||||
|
||||
|
|
|
@ -3,20 +3,21 @@ class ApplicationController < ActionController::Base
|
|||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
before_action :store_location
|
||||
# before_action :store_location
|
||||
|
||||
def store_location
|
||||
unless params[:controller] == 'devise/sessions'
|
||||
url = "/admin/dossiers/#{params[:dossier_id]}"
|
||||
session[:user_return_to] = url
|
||||
end
|
||||
end
|
||||
# def store_location
|
||||
# unless params[:controller] == 'devise/sessions'
|
||||
# url = "/admin/dossiers/#{params[:dossier_id]}"
|
||||
# session[:user_return_to] = url
|
||||
# end
|
||||
# end
|
||||
|
||||
def stored_location_for(resource_or_scope)
|
||||
session[:user_return_to] || super
|
||||
end
|
||||
# def stored_location_for(resource_or_scope)
|
||||
# session[:user_return_to] || super
|
||||
# end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
stored_location_for(resource) || root_path
|
||||
end
|
||||
# def after_sign_in_path_for(resource)
|
||||
# puts "========================= coucou #{resource}"
|
||||
# stored_location_for(resource) || root_path
|
||||
# end
|
||||
end
|
||||
|
|
7
app/controllers/backoffice_controller.rb
Normal file
7
app/controllers/backoffice_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class BackofficeController < ApplicationController
|
||||
|
||||
def index
|
||||
redirect_to(controller: '/gestionnaires/sessions', action: :new) unless gestionnaire_signed_in?
|
||||
end
|
||||
|
||||
end
|
16
app/controllers/gestionnaires/sessions_controller.rb
Normal file
16
app/controllers/gestionnaires/sessions_controller.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class Gestionnaires::SessionsController < Devise::SessionsController
|
||||
|
||||
|
||||
def new
|
||||
@gestionnaire = Gestionnaire.new
|
||||
end
|
||||
|
||||
def create
|
||||
super
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
# stored_location_for(resource) ||
|
||||
backoffice_path
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
class Pros::SessionsController < Devise::SessionsController
|
||||
# before_filter :configure_sign_in_params, only: [:create]
|
||||
|
||||
# GET /resource/sign_in
|
||||
def new
|
||||
super
|
||||
end
|
||||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
super
|
||||
end
|
||||
|
||||
# DELETE /resource/sign_out
|
||||
# def destroy
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_sign_in_params
|
||||
# devise_parameter_sanitizer.for(:sign_in) << :attribute
|
||||
# end
|
||||
end
|
|
@ -1,14 +1,3 @@
|
|||
class User::CustomFailure < Devise::FailureApp
|
||||
def redirect_url
|
||||
url_for(controller: '/start', action: :index)
|
||||
end
|
||||
|
||||
# You need to override respond to eliminate recall
|
||||
def respond
|
||||
if http_auth?
|
||||
http_auth
|
||||
else
|
||||
redirect
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +1,3 @@
|
|||
class User::SessionsController < Devise::SessionsController
|
||||
# before_filter :configure_sign_in_params, only: [:create]
|
||||
|
||||
# GET /resource/sign_in
|
||||
def new
|
||||
redirect_to url_for(controller: '/start', action: :error_login)
|
||||
end
|
||||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
super
|
||||
end
|
||||
|
||||
# DELETE /resource/sign_out
|
||||
def destroy
|
||||
super
|
||||
end
|
||||
|
||||
# protected
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_sign_in_params
|
||||
# devise_parameter_sanitizer.for(:sign_in) << :attribute
|
||||
# end
|
||||
end
|
||||
|
|
6
app/models/gestionnaire.rb
Normal file
6
app/models/gestionnaire.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class Gestionnaire < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
end
|
14
app/views/backoffice/index.html.haml
Normal file
14
app/views/backoffice/index.html.haml
Normal file
|
@ -0,0 +1,14 @@
|
|||
#backoffice
|
||||
|
||||
|
||||
%table.table
|
||||
%thead
|
||||
%th Procédure
|
||||
%th Dossier
|
||||
%th etat
|
||||
%th Date de mise à jour
|
||||
%row
|
||||
%td Demande de subventions
|
||||
%td dossier n°34 Demande de subvention
|
||||
%td Mise à jour
|
||||
%td 24/12/2015
|
10
app/views/gestionnaires/sessions/new.html.haml
Normal file
10
app/views/gestionnaires/sessions/new.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
|||
%h1 Bienvenue sur TPS
|
||||
%br
|
||||
#gestionnaire_login
|
||||
= form_for @gestionnaire, url: {controller: 'gestionnaires/sessions', action: :create } do |f|
|
||||
.form-group-lg
|
||||
.form-group
|
||||
= f.text_field :email, class: 'form-control', placeholder: 'Email'
|
||||
.form-group
|
||||
= f.password_field :password, class: 'form-control', placeholder: 'Mot de passe'
|
||||
= f.submit 'Se connecter', class: %w(btn btn-lg btn-success), data: { disable_with: 'Connexion', submit: true }
|
|
@ -13,10 +13,10 @@
|
|||
%a{href: '/', class:'btn btn-lg'}
|
||||
='TPS'
|
||||
|
||||
-if user_signed_in?
|
||||
-if gestionnaire_signed_in?
|
||||
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
||||
= current_user.email
|
||||
= link_to "Déconnexion", '/logout', method: :delete, :class => 'btn btn-md'
|
||||
= current_gestionnaire.email
|
||||
= link_to "Déconnexion", '/gestionnaires/sign_out', method: :delete, :class => 'btn btn-md'
|
||||
|
||||
#flash_message.center
|
||||
- if flash.notice
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
%p.lead{id: 'admin_section'}
|
||||
%span{class:'text-info', style:'font-weight:bold'}
|
||||
-if user_signed_in?
|
||||
='Vous êtes identifié comme une administration'
|
||||
-else
|
||||
='Si vous êtes une administration, '
|
||||
/ %p.lead{id: 'admin_section'}
|
||||
/ %span{class:'text-info', style:'font-weight:bold'}
|
||||
/ -if user_signed_in?
|
||||
/ ='Vous êtes identifié comme une administration'
|
||||
/ -else
|
||||
/ ='Si vous êtes une administration, '
|
||||
|
||||
%p.lead
|
||||
-if user_signed_in?
|
||||
= form_tag(url_for({controller: 'admin/dossier', action: :index}), class: 'form-inline', method: 'GET') do
|
||||
.form-group.form-group-lg
|
||||
= text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
|
||||
%br
|
||||
= submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
|
||||
-else
|
||||
= form_tag(url_for({controller: 'user/sessions', action: :create}), class: 'form-inline', method: 'POST') do
|
||||
.form-group.form-group-lg
|
||||
= text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Identifiant", :id => "user_email", :name => "user[email]"
|
||||
%br
|
||||
= password_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Mot de passe", :id => "user_password", :name => "user[password]"
|
||||
%br
|
||||
= text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
|
||||
%br
|
||||
= submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
|
||||
/ %p.lead
|
||||
/ -if user_signed_in?
|
||||
/ = form_tag(url_for({controller: 'admin/dossier', action: :index}), class: 'form-inline', method: 'GET') do
|
||||
/ .form-group.form-group-lg
|
||||
/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
|
||||
/ %br
|
||||
/ = submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
|
||||
/ -else
|
||||
/ = form_tag(url_for({controller: 'user/sessions', action: :create}), class: 'form-inline', method: 'POST') do
|
||||
/ .form-group.form-group-lg
|
||||
/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Identifiant", :id => "user_email", :name => "user[email]"
|
||||
/ %br
|
||||
/ = password_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Mot de passe", :id => "user_password", :name => "user[password]"
|
||||
/ %br
|
||||
/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
|
||||
/ %br
|
||||
/ = submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
|
||||
|
|
|
@ -3,5 +3,7 @@
|
|||
%br
|
||||
%p{style: 'width:67%; margin-left:auto; margin-right:auto'}
|
||||
Site de démonstration d’un service public de saisie d’un projet ou de dépôt d’une démarche administrative, auprès d’un ou plusieurs organismes publics, simplifié des informations déjà connues des administrations, grâce à la fourniture du numéro SIRET.
|
||||
|
||||
.row
|
||||
= render partial: '/start/pro'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue