diff --git a/app/controllers/api/statistiques_controller.rb b/app/controllers/api/statistiques_controller.rb index b920f47c6..fe12ffa2a 100644 --- a/app/controllers/api/statistiques_controller.rb +++ b/app/controllers/api/statistiques_controller.rb @@ -1,5 +1,4 @@ class API::StatistiquesController < ApplicationController - def dossiers_stats render json: { total: total_dossiers, diff --git a/app/controllers/api/v1/dossiers_controller.rb b/app/controllers/api/v1/dossiers_controller.rb index b2010c0f9..ddafcf82c 100644 --- a/app/controllers/api/v1/dossiers_controller.rb +++ b/app/controllers/api/v1/dossiers_controller.rb @@ -1,5 +1,4 @@ class API::V1::DossiersController < APIController - api :GET, '/procedures/:procedure_id/dossiers/', 'Liste de tous les dossiers d\'une procédure' param :procedure_id, Integer, desc: "L'identifiant de la procédure", required: true param :token, String, desc: "Token administrateur", required: true diff --git a/app/controllers/backoffice/dossiers/procedure_controller.rb b/app/controllers/backoffice/dossiers/procedure_controller.rb index 88bcf6536..5f96c1508 100644 --- a/app/controllers/backoffice/dossiers/procedure_controller.rb +++ b/app/controllers/backoffice/dossiers/procedure_controller.rb @@ -1,5 +1,4 @@ class Backoffice::Dossiers::ProcedureController < Backoffice::DossiersListController - def index super diff --git a/app/controllers/backoffice_controller.rb b/app/controllers/backoffice_controller.rb index fa77609d3..5f426be36 100644 --- a/app/controllers/backoffice_controller.rb +++ b/app/controllers/backoffice_controller.rb @@ -25,5 +25,4 @@ class BackofficeController < ApplicationController partial: 'backoffice/dossiers/list_invitations', array: true end - end diff --git a/app/controllers/france_connect/particulier_controller.rb b/app/controllers/france_connect/particulier_controller.rb index a625d0440..1fd9e507f 100644 --- a/app/controllers/france_connect/particulier_controller.rb +++ b/app/controllers/france_connect/particulier_controller.rb @@ -1,5 +1,4 @@ class FranceConnect::ParticulierController < ApplicationController - def login client = FranceConnectParticulierClient.new diff --git a/app/controllers/ping_controller.rb b/app/controllers/ping_controller.rb index 361adb56c..5848f722c 100644 --- a/app/controllers/ping_controller.rb +++ b/app/controllers/ping_controller.rb @@ -1,5 +1,4 @@ class PingController < ApplicationController - def index Rails.logger.silence do if (ActiveRecord::Base.connected?) @@ -9,5 +8,4 @@ class PingController < ApplicationController end end end - end diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index fec3780b4..70684f99e 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -1,6 +1,5 @@ class RootController < ApplicationController def index - begin route = Rails.application.routes.recognize_path(request.referrer) rescue ActionController::RoutingError diff --git a/app/controllers/sessions/sessions_controller.rb b/app/controllers/sessions/sessions_controller.rb index d288616c3..e30c51fc8 100644 --- a/app/controllers/sessions/sessions_controller.rb +++ b/app/controllers/sessions/sessions_controller.rb @@ -1,5 +1,4 @@ class Sessions::SessionsController < Devise::SessionsController - before_action :before_sign_in, only: [:create] def before_sign_in diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index f38f52ab5..3c10c7df9 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -1,5 +1,4 @@ class Users::CarteController < UsersController - before_action only: [:show] do authorized_routes? self.class end diff --git a/app/controllers/users/dossiers/invites_controller.rb b/app/controllers/users/dossiers/invites_controller.rb index c10f93d0a..c890dc6c8 100644 --- a/app/controllers/users/dossiers/invites_controller.rb +++ b/app/controllers/users/dossiers/invites_controller.rb @@ -1,5 +1,4 @@ class Users::Dossiers::InvitesController < UsersController - def authenticate_user! session["user_return_to"] = request.fullpath return redirect_to new_user_registration_path(user_email: params[:email]) if !params[:email].blank? && User.find_by_email(params[:email]).nil? diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index 8315380c8..88dd4d2f8 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -1,5 +1,4 @@ class Users::RecapitulatifController < UsersController - before_action only: [:show] do authorized_routes? self.class end diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb index ab69d0339..731e5df5c 100644 --- a/app/models/administrateur.rb +++ b/app/models/administrateur.rb @@ -27,5 +27,4 @@ class Administrateur < ActiveRecord::Base break token unless Administrateur.find_by(api_token: token) end end - end diff --git a/app/models/entreprise.rb b/app/models/entreprise.rb index 8e14d7640..5e24a31bb 100644 --- a/app/models/entreprise.rb +++ b/app/models/entreprise.rb @@ -1,5 +1,4 @@ class Entreprise < ActiveRecord::Base - belongs_to :dossier has_one :etablissement, dependent: :destroy has_one :rna_information, dependent: :destroy diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb index 1e80b4bad..44e840205 100644 --- a/app/models/etablissement.rb +++ b/app/models/etablissement.rb @@ -1,5 +1,4 @@ class Etablissement < ActiveRecord::Base - belongs_to :dossier belongs_to :entreprise diff --git a/app/models/exercice.rb b/app/models/exercice.rb index e6ec6a4cb..6b002c092 100644 --- a/app/models/exercice.rb +++ b/app/models/exercice.rb @@ -2,5 +2,4 @@ class Exercice < ActiveRecord::Base belongs_to :etablissement validates :ca, presence: true, allow_blank: false, allow_nil: false - end diff --git a/app/models/france_connect_particulier_client.rb b/app/models/france_connect_particulier_client.rb index 967ab84bd..bc0e99e9c 100644 --- a/app/models/france_connect_particulier_client.rb +++ b/app/models/france_connect_particulier_client.rb @@ -1,5 +1,4 @@ class FranceConnectParticulierClient < OpenIDConnect::Client - def initialize params={} super( identifier: FRANCE_CONNECT.particulier_identifier, diff --git a/app/models/notification.rb b/app/models/notification.rb index 0740ee823..53d8af02d 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,12 +1,14 @@ class Notification < ActiveRecord::Base - belongs_to :dossier enum type_notif: { - commentaire: 'commentaire', - cerfa: 'cerfa', - piece_justificative: 'piece_justificative', - champs: 'champs', - submitted: 'submitted', - avis: 'avis' - } + commentaire: 'commentaire', + cerfa: 'cerfa', + piece_justificative: 'piece_justificative', + champs: 'champs', + submitted: 'submitted', + avis: 'avis' + } + + belongs_to :dossier + scope :unread, -> { where(already_read: false) } end diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 864b3fcc3..0c33a5e94 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -24,6 +24,9 @@ class Procedure < ActiveRecord::Base mount_uploader :logo, ProcedureLogoUploader + scope :not_archived, -> { where(archived: false) } + scope :by_libelle, -> { order(libelle: :asc) } + validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false @@ -46,10 +49,6 @@ class Procedure < ActiveRecord::Base alias_method_chain "#{name.underscore.to_sym}".to_s, :override end - scope :not_archived, -> { where(archived: false) } - scope :by_libelle, -> { order(libelle: :asc) } - - def path procedure_path.path unless procedure_path.nil? end @@ -67,7 +66,7 @@ class Procedure < ActiveRecord::Base end def self.active id - Procedure.where(archived: false, published: true).find(id) + not_archived.where(published: true).find(id) end def switch_types_de_champ index_of_first_element @@ -83,12 +82,17 @@ class Procedure < ActiveRecord::Base end def switch_list_order(list, index_of_first_element) - return false if index_of_first_element < 0 - return false if index_of_first_element == list.count - 1 - return false if list.count < 1 - list[index_of_first_element].update_attributes(order_place: index_of_first_element + 1) - list[index_of_first_element + 1].update_attributes(order_place: index_of_first_element) - true + if index_of_first_element < 0 || + index_of_first_element == list.count - 1 || + list.count < 1 + + false + else + list[index_of_first_element].update_attributes(order_place: index_of_first_element + 1) + list[index_of_first_element + 1].update_attributes(order_place: index_of_first_element) + + true + end end def locked? diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index dcdf0a102..86747bc5a 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -1,26 +1,26 @@ class TypeDeChamp < ActiveRecord::Base enum type_champs: { - text: 'text', - textarea: 'textarea', - date: 'date', - datetime: 'datetime', - number: 'number', - checkbox: 'checkbox', - civilite: 'civilite', - email: 'email', - phone: 'phone', - address: 'address', - yes_no: 'yes_no', - drop_down_list: 'drop_down_list', - multiple_drop_down_list: 'multiple_drop_down_list', - pays: 'pays', - regions: 'regions', - departements: 'departements', - engagement: 'engagement', - header_section: 'header_section', - explication: 'explication', - dossier_link: 'dossier_link' - } + text: 'text', + textarea: 'textarea', + date: 'date', + datetime: 'datetime', + number: 'number', + checkbox: 'checkbox', + civilite: 'civilite', + email: 'email', + phone: 'phone', + address: 'address', + yes_no: 'yes_no', + drop_down_list: 'drop_down_list', + multiple_drop_down_list: 'multiple_drop_down_list', + pays: 'pays', + regions: 'regions', + departements: 'departements', + engagement: 'engagement', + header_section: 'header_section', + explication: 'explication', + dossier_link: 'dossier_link' + } belongs_to :procedure diff --git a/app/models/user.rb b/app/models/user.rb index 7ea29d260..c4dab2a5f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,8 @@ class User < ActiveRecord::Base - enum loged_in_with_france_connect: {particulier: 'particulier', - entreprise: 'entreprise'} + enum loged_in_with_france_connect: { + particulier: 'particulier', + entreprise: 'entreprise' + } # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable @@ -35,5 +37,4 @@ class User < ActiveRecord::Base def invite? dossier_id invites.pluck(:dossier_id).include?(dossier_id.to_i) end - end