Merge pull request #365 from sgmap/clean

Clean
This commit is contained in:
gregoirenovel 2017-05-31 10:03:28 +02:00 committed by GitHub
commit 082898af45
20 changed files with 50 additions and 60 deletions

View file

@ -1,5 +1,4 @@
class API::StatistiquesController < ApplicationController class API::StatistiquesController < ApplicationController
def dossiers_stats def dossiers_stats
render json: { render json: {
total: total_dossiers, total: total_dossiers,

View file

@ -1,5 +1,4 @@
class API::V1::DossiersController < APIController class API::V1::DossiersController < APIController
api :GET, '/procedures/:procedure_id/dossiers/', 'Liste de tous les dossiers d\'une procédure' 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 :procedure_id, Integer, desc: "L'identifiant de la procédure", required: true
param :token, String, desc: "Token administrateur", required: true param :token, String, desc: "Token administrateur", required: true

View file

@ -1,5 +1,4 @@
class Backoffice::Dossiers::ProcedureController < Backoffice::DossiersListController class Backoffice::Dossiers::ProcedureController < Backoffice::DossiersListController
def index def index
super super

View file

@ -25,5 +25,4 @@ class BackofficeController < ApplicationController
partial: 'backoffice/dossiers/list_invitations', partial: 'backoffice/dossiers/list_invitations',
array: true array: true
end end
end end

View file

@ -1,5 +1,4 @@
class FranceConnect::ParticulierController < ApplicationController class FranceConnect::ParticulierController < ApplicationController
def login def login
client = FranceConnectParticulierClient.new client = FranceConnectParticulierClient.new

View file

@ -1,5 +1,4 @@
class PingController < ApplicationController class PingController < ApplicationController
def index def index
Rails.logger.silence do Rails.logger.silence do
if (ActiveRecord::Base.connected?) if (ActiveRecord::Base.connected?)
@ -9,5 +8,4 @@ class PingController < ApplicationController
end end
end end
end end
end end

View file

@ -1,6 +1,5 @@
class RootController < ApplicationController class RootController < ApplicationController
def index def index
begin begin
route = Rails.application.routes.recognize_path(request.referrer) route = Rails.application.routes.recognize_path(request.referrer)
rescue ActionController::RoutingError rescue ActionController::RoutingError

View file

@ -1,5 +1,4 @@
class Sessions::SessionsController < Devise::SessionsController class Sessions::SessionsController < Devise::SessionsController
before_action :before_sign_in, only: [:create] before_action :before_sign_in, only: [:create]
def before_sign_in def before_sign_in

View file

@ -1,5 +1,4 @@
class Users::CarteController < UsersController class Users::CarteController < UsersController
before_action only: [:show] do before_action only: [:show] do
authorized_routes? self.class authorized_routes? self.class
end end

View file

@ -1,5 +1,4 @@
class Users::Dossiers::InvitesController < UsersController class Users::Dossiers::InvitesController < UsersController
def authenticate_user! def authenticate_user!
session["user_return_to"] = request.fullpath 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? return redirect_to new_user_registration_path(user_email: params[:email]) if !params[:email].blank? && User.find_by_email(params[:email]).nil?

View file

@ -1,5 +1,4 @@
class Users::RecapitulatifController < UsersController class Users::RecapitulatifController < UsersController
before_action only: [:show] do before_action only: [:show] do
authorized_routes? self.class authorized_routes? self.class
end end

View file

@ -27,5 +27,4 @@ class Administrateur < ActiveRecord::Base
break token unless Administrateur.find_by(api_token: token) break token unless Administrateur.find_by(api_token: token)
end end
end end
end end

View file

@ -1,5 +1,4 @@
class Entreprise < ActiveRecord::Base class Entreprise < ActiveRecord::Base
belongs_to :dossier belongs_to :dossier
has_one :etablissement, dependent: :destroy has_one :etablissement, dependent: :destroy
has_one :rna_information, dependent: :destroy has_one :rna_information, dependent: :destroy

View file

@ -1,5 +1,4 @@
class Etablissement < ActiveRecord::Base class Etablissement < ActiveRecord::Base
belongs_to :dossier belongs_to :dossier
belongs_to :entreprise belongs_to :entreprise

View file

@ -2,5 +2,4 @@ class Exercice < ActiveRecord::Base
belongs_to :etablissement belongs_to :etablissement
validates :ca, presence: true, allow_blank: false, allow_nil: false validates :ca, presence: true, allow_blank: false, allow_nil: false
end end

View file

@ -1,5 +1,4 @@
class FranceConnectParticulierClient < OpenIDConnect::Client class FranceConnectParticulierClient < OpenIDConnect::Client
def initialize params={} def initialize params={}
super( super(
identifier: FRANCE_CONNECT.particulier_identifier, identifier: FRANCE_CONNECT.particulier_identifier,

View file

@ -1,5 +1,4 @@
class Notification < ActiveRecord::Base class Notification < ActiveRecord::Base
belongs_to :dossier
enum type_notif: { enum type_notif: {
commentaire: 'commentaire', commentaire: 'commentaire',
cerfa: 'cerfa', cerfa: 'cerfa',
@ -8,5 +7,8 @@ class Notification < ActiveRecord::Base
submitted: 'submitted', submitted: 'submitted',
avis: 'avis' avis: 'avis'
} }
belongs_to :dossier
scope :unread, -> { where(already_read: false) } scope :unread, -> { where(already_read: false) }
end end

View file

@ -24,6 +24,9 @@ class Procedure < ActiveRecord::Base
mount_uploader :logo, ProcedureLogoUploader 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 :libelle, presence: true, allow_blank: false, allow_nil: false
validates :description, 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 alias_method_chain "#{name.underscore.to_sym}".to_s, :override
end end
scope :not_archived, -> { where(archived: false) }
scope :by_libelle, -> { order(libelle: :asc) }
def path def path
procedure_path.path unless procedure_path.nil? procedure_path.path unless procedure_path.nil?
end end
@ -67,7 +66,7 @@ class Procedure < ActiveRecord::Base
end end
def self.active id def self.active id
Procedure.where(archived: false, published: true).find(id) not_archived.where(published: true).find(id)
end end
def switch_types_de_champ index_of_first_element def switch_types_de_champ index_of_first_element
@ -83,13 +82,18 @@ class Procedure < ActiveRecord::Base
end end
def switch_list_order(list, index_of_first_element) def switch_list_order(list, index_of_first_element)
return false if index_of_first_element < 0 if index_of_first_element < 0 ||
return false if index_of_first_element == list.count - 1 index_of_first_element == list.count - 1 ||
return false if 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].update_attributes(order_place: index_of_first_element + 1)
list[index_of_first_element + 1].update_attributes(order_place: index_of_first_element) list[index_of_first_element + 1].update_attributes(order_place: index_of_first_element)
true true
end end
end
def locked? def locked?
published? published?

View file

@ -1,6 +1,8 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
enum loged_in_with_france_connect: {particulier: 'particulier', enum loged_in_with_france_connect: {
entreprise: 'entreprise'} particulier: 'particulier',
entreprise: 'entreprise'
}
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable # :confirmable, :lockable, :timeoutable and :omniauthable
@ -35,5 +37,4 @@ class User < ActiveRecord::Base
def invite? dossier_id def invite? dossier_id
invites.pluck(:dossier_id).include?(dossier_id.to_i) invites.pluck(:dossier_id).include?(dossier_id.to_i)
end end
end end