Merge branch 'staging'
This commit is contained in:
commit
1b50d96e59
16 changed files with 251 additions and 26 deletions
39
app/controllers/administrations_controller.rb
Normal file
39
app/controllers/administrations_controller.rb
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
class AdministrationsController < ApplicationController
|
||||||
|
include SmartListing::Helper::ControllerExtensions
|
||||||
|
helper SmartListing::Helper
|
||||||
|
|
||||||
|
before_action :authenticate_administration!
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
@admins = smart_listing_create :admins,
|
||||||
|
Administrateur.all,
|
||||||
|
partial: "administrations/list",
|
||||||
|
array: true
|
||||||
|
|
||||||
|
@admin = Administrateur.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@admin = Administrateur.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
admin = Administrateur.new create_administrateur_params
|
||||||
|
|
||||||
|
if admin.save
|
||||||
|
flash.notice = "Administrateur créé"
|
||||||
|
NewAdminMailer.new_admin_email(admin, params[:administrateur][:password]).deliver_now!
|
||||||
|
else
|
||||||
|
flash.alert = admin.errors.full_messages.join('<br>').html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to administrations_path
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def create_administrateur_params
|
||||||
|
params.require(:administrateur).permit(:email, :password)
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,6 +10,9 @@ class RootController < ApplicationController
|
||||||
elsif administrateur_signed_in?
|
elsif administrateur_signed_in?
|
||||||
redirect_to admin_procedures_path
|
redirect_to admin_procedures_path
|
||||||
|
|
||||||
|
elsif administration_signed_in?
|
||||||
|
redirect_to administrations_path
|
||||||
|
|
||||||
else
|
else
|
||||||
@latest_release = Github::Releases.latest
|
@latest_release = Github::Releases.latest
|
||||||
render 'landing'
|
render 'landing'
|
||||||
|
|
|
@ -6,5 +6,6 @@ class Sessions::SessionsController < Devise::SessionsController
|
||||||
sign_out :user if user_signed_in?
|
sign_out :user if user_signed_in?
|
||||||
sign_out :gestionnaire if gestionnaire_signed_in?
|
sign_out :gestionnaire if gestionnaire_signed_in?
|
||||||
sign_out :administrateur if administrateur_signed_in?
|
sign_out :administrateur if administrateur_signed_in?
|
||||||
|
sign_out :administration if administration_signed_in?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,7 @@ class ChampDecorator < Draper::Decorator
|
||||||
if type_champ == 'checkbox'
|
if type_champ == 'checkbox'
|
||||||
return object.value == 'on' ? 'Oui' : 'Non'
|
return object.value == 'on' ? 'Oui' : 'Non'
|
||||||
end
|
end
|
||||||
|
object.value
|
||||||
end
|
end
|
||||||
|
|
||||||
def type_champ
|
def type_champ
|
||||||
|
|
10
app/mailers/new_admin_mailer.rb
Normal file
10
app/mailers/new_admin_mailer.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class NewAdminMailer < ApplicationMailer
|
||||||
|
def new_admin_email admin, password
|
||||||
|
|
||||||
|
@admin = admin
|
||||||
|
@password = password
|
||||||
|
|
||||||
|
mail(from: "tech@apientreprise.fr", to: 'tech@apientreprise.fr',
|
||||||
|
subject: "Création d'un compte Admin TPS")
|
||||||
|
end
|
||||||
|
end
|
5
app/models/administration.rb
Normal file
5
app/models/administration.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class Administration < ActiveRecord::Base
|
||||||
|
# Include default devise modules. Others available are:
|
||||||
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
|
devise :database_authenticatable, :rememberable, :trackable, :validatable
|
||||||
|
end
|
25
app/views/administrations/_list.html.haml
Normal file
25
app/views/administrations/_list.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
- unless smart_listing.empty?
|
||||||
|
%table.table
|
||||||
|
%thead
|
||||||
|
%th.col-md-4.col-lg-4= smart_listing.sortable 'Email', :email
|
||||||
|
%th.col-md-4.col-lg-4= smart_listing.sortable 'API Token', :api_token
|
||||||
|
%th.col-md-4.col-lg-4= smart_listing.sortable 'Date de dernière connexion', :last_sign_in_at
|
||||||
|
|
||||||
|
- @admins.each do |admin|
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
= admin.email
|
||||||
|
%td
|
||||||
|
= admin.api_token
|
||||||
|
%td
|
||||||
|
- unless admin.last_sign_in_at.nil?
|
||||||
|
= time_ago_in_words(l(admin.last_sign_in_at, format: "%d/%m/%Y %H:%M UTC +02:00"))
|
||||||
|
(
|
||||||
|
= admin.last_sign_in_at.to_date.strftime('%d/%m/%Y')
|
||||||
|
)
|
||||||
|
|
||||||
|
= smart_listing.paginate
|
||||||
|
= smart_listing.pagination_per_page_links
|
||||||
|
- else
|
||||||
|
%h4.center
|
||||||
|
Aucun administrateur créé
|
19
app/views/administrations/index.html.haml
Normal file
19
app/views/administrations/index.html.haml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
|
= form_for @admin, url: {controller: 'administrations', action: :create} do |f|
|
||||||
|
.form-group.form-inline.center
|
||||||
|
= f.text_field :email, placeholder: :email, class: 'form-control'
|
||||||
|
= f.text_field :password, placeholder: :password, class: 'form-control'
|
||||||
|
|
||||||
|
= f.submit 'Valider', class: 'btn btn-success', id: 'submit_new_administrateur'
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
= smart_listing_render :admins
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
|
.center
|
||||||
|
=link_to 'Deconnexion', '/administrations/sign_out', method: :delete
|
9
app/views/new_admin_mailer/new_admin_email.text.erb
Normal file
9
app/views/new_admin_mailer/new_admin_email.text.erb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Un nouvel administrateur a été créé sur TPS.
|
||||||
|
|
||||||
|
Plateforme : <%= TPS::Application::URL %>
|
||||||
|
|
||||||
|
Login : <%= @admin.email %>
|
||||||
|
Password : <%= @password %>
|
||||||
|
|
||||||
|
---
|
||||||
|
L'équipe TPS - tps@apientreprise.fr
|
|
@ -66,6 +66,7 @@ set :shared_paths, [
|
||||||
'config/initializers/secret_token.rb',
|
'config/initializers/secret_token.rb',
|
||||||
"config/environments/#{ENV['to']}.rb",
|
"config/environments/#{ENV['to']}.rb",
|
||||||
"config/initializers/token.rb",
|
"config/initializers/token.rb",
|
||||||
|
"config/initializers/super_admin.rb",
|
||||||
"config/unicorn.rb",
|
"config/unicorn.rb",
|
||||||
"config/initializers/raven.rb",
|
"config/initializers/raven.rb",
|
||||||
'config/france_connect.yml',
|
'config/france_connect.yml',
|
||||||
|
@ -131,6 +132,10 @@ task :deploy => :environment do
|
||||||
|
|
||||||
to :launch do
|
to :launch do
|
||||||
queue "/etc/init.d/#{user} upgrade "
|
queue "/etc/init.d/#{user} upgrade "
|
||||||
|
|
||||||
|
queue "cd #{deploy_to}/#{current_path}/"
|
||||||
|
queue "bundle exec rake db:seed RAILS_ENV=#{rails_env}"
|
||||||
|
queue %[echo "-----> Rake Seeding Completed."]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -140,3 +140,41 @@ fr:
|
||||||
connexion: "Erreur lors de la connexion à France Connect."
|
connexion: "Erreur lors de la connexion à France Connect."
|
||||||
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
|
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
|
||||||
|
|
||||||
|
datetime:
|
||||||
|
distance_in_words:
|
||||||
|
about_x_hours:
|
||||||
|
one: environ une heure
|
||||||
|
other: environ %{count} heures
|
||||||
|
about_x_months:
|
||||||
|
one: environ un mois
|
||||||
|
other: environ %{count} mois
|
||||||
|
about_x_years:
|
||||||
|
one: environ un an
|
||||||
|
other: environ %{count} ans
|
||||||
|
almost_x_years:
|
||||||
|
one: presqu'un an
|
||||||
|
other: presque %{count} ans
|
||||||
|
half_a_minute: une demi-minute
|
||||||
|
less_than_x_minutes:
|
||||||
|
zero: moins d'une minute
|
||||||
|
one: moins d'une minute
|
||||||
|
other: moins de %{count} minutes
|
||||||
|
less_than_x_seconds:
|
||||||
|
zero: moins d'une seconde
|
||||||
|
one: moins d'une seconde
|
||||||
|
other: moins de %{count} secondes
|
||||||
|
over_x_years:
|
||||||
|
one: plus d'un an
|
||||||
|
other: plus de %{count} ans
|
||||||
|
x_days:
|
||||||
|
one: 1 jour
|
||||||
|
other: "%{count} jours"
|
||||||
|
x_minutes:
|
||||||
|
one: 1 minute
|
||||||
|
other: "%{count} minutes"
|
||||||
|
x_months:
|
||||||
|
one: 1 mois
|
||||||
|
other: "%{count} mois"
|
||||||
|
x_seconds:
|
||||||
|
one: 1 seconde
|
||||||
|
other: "%{count} secondes"
|
|
@ -1,5 +1,7 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
|
devise_for :administrations, skip: [:password, :registrations]
|
||||||
|
|
||||||
devise_for :administrateurs, controllers: {
|
devise_for :administrateurs, controllers: {
|
||||||
sessions: 'administrateurs/sessions'
|
sessions: 'administrateurs/sessions'
|
||||||
}, skip: [:password, :registrations]
|
}, skip: [:password, :registrations]
|
||||||
|
@ -106,6 +108,8 @@ Rails.application.routes.draw do
|
||||||
resources :commentaires, only: [:create]
|
resources :commentaires, only: [:create]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :administrations
|
||||||
|
|
||||||
namespace :api do
|
namespace :api do
|
||||||
namespace :v1 do
|
namespace :v1 do
|
||||||
resources :procedures, only: [:index, :show] do
|
resources :procedures, only: [:index, :show] do
|
||||||
|
|
42
db/migrate/20160223134354_devise_create_administrations.rb
Normal file
42
db/migrate/20160223134354_devise_create_administrations.rb
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
class DeviseCreateAdministrations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table(:administrations) do |t|
|
||||||
|
## Database authenticatable
|
||||||
|
t.string :email, null: false, default: ""
|
||||||
|
t.string :encrypted_password, null: false, default: ""
|
||||||
|
|
||||||
|
## Recoverable
|
||||||
|
t.string :reset_password_token
|
||||||
|
t.datetime :reset_password_sent_at
|
||||||
|
|
||||||
|
## Rememberable
|
||||||
|
t.datetime :remember_created_at
|
||||||
|
|
||||||
|
## Trackable
|
||||||
|
t.integer :sign_in_count, default: 0, null: false
|
||||||
|
t.datetime :current_sign_in_at
|
||||||
|
t.datetime :last_sign_in_at
|
||||||
|
t.inet :current_sign_in_ip
|
||||||
|
t.inet :last_sign_in_ip
|
||||||
|
|
||||||
|
## Confirmable
|
||||||
|
# t.string :confirmation_token
|
||||||
|
# t.datetime :confirmed_at
|
||||||
|
# t.datetime :confirmation_sent_at
|
||||||
|
# t.string :unconfirmed_email # Only if using reconfirmable
|
||||||
|
|
||||||
|
## Lockable
|
||||||
|
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
||||||
|
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
||||||
|
# t.datetime :locked_at
|
||||||
|
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :administrations, :email, unique: true
|
||||||
|
add_index :administrations, :reset_password_token, unique: true
|
||||||
|
# add_index :administrations, :confirmation_token, unique: true
|
||||||
|
# add_index :administrations, :unlock_token, unique: true
|
||||||
|
end
|
||||||
|
end
|
20
db/schema.rb
20
db/schema.rb
|
@ -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: 20160204155519) do
|
ActiveRecord::Schema.define(version: 20160223134354) 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"
|
||||||
|
@ -35,6 +35,24 @@ ActiveRecord::Schema.define(version: 20160204155519) do
|
||||||
add_index "administrateurs", ["email"], name: "index_administrateurs_on_email", unique: true, using: :btree
|
add_index "administrateurs", ["email"], name: "index_administrateurs_on_email", unique: true, using: :btree
|
||||||
add_index "administrateurs", ["reset_password_token"], name: "index_administrateurs_on_reset_password_token", unique: true, using: :btree
|
add_index "administrateurs", ["reset_password_token"], name: "index_administrateurs_on_reset_password_token", unique: true, using: :btree
|
||||||
|
|
||||||
|
create_table "administrations", force: :cascade do |t|
|
||||||
|
t.string "email", default: "", null: false
|
||||||
|
t.string "encrypted_password", default: "", null: false
|
||||||
|
t.string "reset_password_token"
|
||||||
|
t.datetime "reset_password_sent_at"
|
||||||
|
t.datetime "remember_created_at"
|
||||||
|
t.integer "sign_in_count", default: 0, null: false
|
||||||
|
t.datetime "current_sign_in_at"
|
||||||
|
t.datetime "last_sign_in_at"
|
||||||
|
t.inet "current_sign_in_ip"
|
||||||
|
t.inet "last_sign_in_ip"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "administrations", ["email"], name: "index_administrations_on_email", unique: true, using: :btree
|
||||||
|
add_index "administrations", ["reset_password_token"], name: "index_administrations_on_reset_password_token", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "cadastres", force: :cascade do |t|
|
create_table "cadastres", force: :cascade do |t|
|
||||||
t.string "surface_intersection"
|
t.string "surface_intersection"
|
||||||
t.float "surface_parcelle"
|
t.float "surface_parcelle"
|
||||||
|
|
1
db/seeds/super_admin.rb
Normal file
1
db/seeds/super_admin.rb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Administration.create(email: SUPERADMIN.email, password: SUPERADMIN.password)
|
|
@ -4,6 +4,11 @@ describe 'dossiers/_infos_dossier.html.haml', type: :view do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
|
let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
champs.each do |champ|
|
||||||
|
champ.value = ((0...8).map { (65 + rand(26)).chr }.join)
|
||||||
|
champ.save
|
||||||
|
end
|
||||||
|
|
||||||
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
|
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue