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
|
||||
@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",
|
||||
array: true
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class DemoController < ApplicationController
|
|||
return redirect_to root_path if Rails.env.production?
|
||||
|
||||
smart_listing_create :procedures,
|
||||
Procedure.where(archived: false, published: true).order("id DESC"),
|
||||
Procedure.published.where(archived: false).order("id DESC"),
|
||||
partial: "demo/list",
|
||||
array: true
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class StatsController < ApplicationController
|
|||
MEAN_NUMBER_OF_CHAMPS_IN_A_FORM = 24.0
|
||||
|
||||
def index
|
||||
procedures = Procedure.where(:published => true)
|
||||
procedures = Procedure.published
|
||||
dossiers = Dossier.where.not(:state => :draft)
|
||||
|
||||
@procedures_count = procedures.count
|
||||
|
|
|
@ -60,7 +60,7 @@ class Users::DossiersController < UsersController
|
|||
end
|
||||
|
||||
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')
|
||||
siret = params[:siret] || current_user.siret
|
||||
|
|
|
@ -108,7 +108,7 @@ class Gestionnaire < ActiveRecord::Base
|
|||
start_date = DateTime.now.beginning_of_week
|
||||
|
||||
active_procedure_overviews = procedures
|
||||
.where(published: true)
|
||||
.published
|
||||
.all
|
||||
.map { |procedure| procedure.procedure_overview(start_date) }
|
||||
.select(&:had_some_activities?)
|
||||
|
|
|
@ -32,6 +32,7 @@ class Procedure < ActiveRecord::Base
|
|||
mount_uploader :logo, ProcedureLogoUploader
|
||||
|
||||
default_scope { where(hidden_at: nil) }
|
||||
scope :published, -> { where(published: true) }
|
||||
scope :not_archived, -> { where(archived: false) }
|
||||
scope :by_libelle, -> { order(libelle: :asc) }
|
||||
|
||||
|
@ -61,7 +62,7 @@ class Procedure < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.active id
|
||||
not_archived.where(published: true).find(id)
|
||||
not_archived.published.find(id)
|
||||
end
|
||||
|
||||
def switch_types_de_champ index_of_first_element
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
= admin.last_sign_in_at.localtime.strftime('%d/%m/%Y')
|
||||
)
|
||||
%td
|
||||
= admin.procedures.where(published: true).count
|
||||
= admin.procedures.published.count
|
||||
%td
|
||||
- total_dossier = 0
|
||||
- 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 }
|
||||
Actives
|
||||
.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}" }
|
||||
.procedure-list-element{ class: @archived_class }
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
%ul.numbers
|
||||
%li.number
|
||||
.number-value
|
||||
= number_with_delimiter(Procedure.where(:published => true).count, :locale => :fr)
|
||||
= number_with_delimiter(Procedure.published.count, :locale => :fr)
|
||||
.number-label<
|
||||
procédures
|
||||
%br<>
|
||||
|
|
Loading…
Reference in a new issue