Add the published scope en Procedure
This commit is contained in:
parent
7bfe83e072
commit
5f50f76341
9 changed files with 10 additions and 9 deletions
|
@ -6,7 +6,7 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@procedures = smart_listing_create :procedures,
|
@procedures = smart_listing_create :procedures,
|
||||||
current_administrateur.procedures.where(published: true, archived: false).order(created_at: :desc),
|
current_administrateur.procedures.published.where(archived: false).order(created_at: :desc),
|
||||||
partial: "admin/procedures/list",
|
partial: "admin/procedures/list",
|
||||||
array: true
|
array: true
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ class DemoController < ApplicationController
|
||||||
return redirect_to root_path if Rails.env.production?
|
return redirect_to root_path if Rails.env.production?
|
||||||
|
|
||||||
smart_listing_create :procedures,
|
smart_listing_create :procedures,
|
||||||
Procedure.where(archived: false, published: true).order("id DESC"),
|
Procedure.published.where(archived: false).order("id DESC"),
|
||||||
partial: "demo/list",
|
partial: "demo/list",
|
||||||
array: true
|
array: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ class StatsController < ApplicationController
|
||||||
MEAN_NUMBER_OF_CHAMPS_IN_A_FORM = 24.0
|
MEAN_NUMBER_OF_CHAMPS_IN_A_FORM = 24.0
|
||||||
|
|
||||||
def index
|
def index
|
||||||
procedures = Procedure.where(:published => true)
|
procedures = Procedure.published
|
||||||
dossiers = Dossier.where.not(:state => :draft)
|
dossiers = Dossier.where.not(:state => :draft)
|
||||||
|
|
||||||
@procedures_count = procedures.count
|
@procedures_count = procedures.count
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Users::DossiersController < UsersController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
procedure = Procedure.where(archived: false, published: true).find(params[:procedure_id])
|
procedure = Procedure.where(archived: false).published.find(params[:procedure_id])
|
||||||
|
|
||||||
dossier = Dossier.create(procedure: procedure, user: current_user, state: 'draft')
|
dossier = Dossier.create(procedure: procedure, user: current_user, state: 'draft')
|
||||||
siret = params[:siret] || current_user.siret
|
siret = params[:siret] || current_user.siret
|
||||||
|
|
|
@ -108,7 +108,7 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
start_date = DateTime.now.beginning_of_week
|
start_date = DateTime.now.beginning_of_week
|
||||||
|
|
||||||
active_procedure_overviews = procedures
|
active_procedure_overviews = procedures
|
||||||
.where(published: true)
|
.published
|
||||||
.all
|
.all
|
||||||
.map { |procedure| procedure.procedure_overview(start_date) }
|
.map { |procedure| procedure.procedure_overview(start_date) }
|
||||||
.select(&:had_some_activities?)
|
.select(&:had_some_activities?)
|
||||||
|
|
|
@ -32,6 +32,7 @@ class Procedure < ActiveRecord::Base
|
||||||
mount_uploader :logo, ProcedureLogoUploader
|
mount_uploader :logo, ProcedureLogoUploader
|
||||||
|
|
||||||
default_scope { where(hidden_at: nil) }
|
default_scope { where(hidden_at: nil) }
|
||||||
|
scope :published, -> { where(published: true) }
|
||||||
scope :not_archived, -> { where(archived: false) }
|
scope :not_archived, -> { where(archived: false) }
|
||||||
scope :by_libelle, -> { order(libelle: :asc) }
|
scope :by_libelle, -> { order(libelle: :asc) }
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ class Procedure < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.active id
|
def self.active id
|
||||||
not_archived.where(published: true).find(id)
|
not_archived.published.find(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def switch_types_de_champ index_of_first_element
|
def switch_types_de_champ index_of_first_element
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
= admin.last_sign_in_at.localtime.strftime('%d/%m/%Y')
|
= admin.last_sign_in_at.localtime.strftime('%d/%m/%Y')
|
||||||
)
|
)
|
||||||
%td
|
%td
|
||||||
= admin.procedures.where(published: true).count
|
= admin.procedures.published.count
|
||||||
%td
|
%td
|
||||||
- total_dossier = 0
|
- total_dossier = 0
|
||||||
- admin.procedures.each do |procedure| total_dossier += procedure.dossiers.where.not(state: :draft).count end
|
- admin.procedures.each do |procedure| total_dossier += procedure.dossiers.where.not(state: :draft).count end
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
.procedure-list-element{ class: @active_class }
|
.procedure-list-element{ class: @active_class }
|
||||||
Actives
|
Actives
|
||||||
.badge.progress-bar-success
|
.badge.progress-bar-success
|
||||||
= current_administrateur.procedures.where(published: true, archived: false).count
|
= current_administrateur.procedures.published.where(archived: false).count
|
||||||
|
|
||||||
%a#archived-procedures{ :href => "#{url_for :admin_procedures_archived}" }
|
%a#archived-procedures{ :href => "#{url_for :admin_procedures_archived}" }
|
||||||
.procedure-list-element{ class: @archived_class }
|
.procedure-list-element{ class: @archived_class }
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
%ul.numbers
|
%ul.numbers
|
||||||
%li.number
|
%li.number
|
||||||
.number-value
|
.number-value
|
||||||
= number_with_delimiter(Procedure.where(:published => true).count, :locale => :fr)
|
= number_with_delimiter(Procedure.published.count, :locale => :fr)
|
||||||
.number-label<
|
.number-label<
|
||||||
procédures
|
procédures
|
||||||
%br<>
|
%br<>
|
||||||
|
|
Loading…
Reference in a new issue