Merge branch 'dev'
This commit is contained in:
commit
c01c09a6ea
8 changed files with 46 additions and 79 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.publiees.order(created_at: :desc),
|
current_administrateur.procedures.publiees.order(published_at: :desc),
|
||||||
partial: "admin/procedures/list",
|
partial: "admin/procedures/list",
|
||||||
array: true
|
array: true
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def archived
|
def archived
|
||||||
@procedures = smart_listing_create :procedures,
|
@procedures = smart_listing_create :procedures,
|
||||||
current_administrateur.procedures.archivees.order(created_at: :desc),
|
current_administrateur.procedures.archivees.order(published_at: :desc),
|
||||||
partial: "admin/procedures/list",
|
partial: "admin/procedures/list",
|
||||||
array: true
|
array: true
|
||||||
|
|
||||||
|
|
|
@ -95,9 +95,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive
|
def receive
|
||||||
create_dossier_facade params[:dossier_id]
|
dossier = Dossier.find(params[:dossier_id])
|
||||||
|
|
||||||
dossier = @facade.dossier
|
|
||||||
|
|
||||||
dossier.received!
|
dossier.received!
|
||||||
flash.notice = 'Dossier considéré comme reçu.'
|
flash.notice = 'Dossier considéré comme reçu.'
|
||||||
|
|
|
@ -4,14 +4,14 @@ 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.publiee_ou_archivee
|
procedures = Procedure.publiees_ou_archivees
|
||||||
dossiers = Dossier.where.not(:state => :draft)
|
dossiers = Dossier.where.not(:state => :draft)
|
||||||
|
|
||||||
@procedures_count = procedures.count
|
@procedures_count = procedures.count
|
||||||
@dossiers_count = dossiers.count
|
@dossiers_count = dossiers.count
|
||||||
|
|
||||||
@procedures_cumulative = cumulative_hash(procedures)
|
@procedures_cumulative = cumulative_hash(procedures, :published_at)
|
||||||
@procedures_in_the_last_4_months = last_four_months_hash(procedures)
|
@procedures_in_the_last_4_months = last_four_months_hash(procedures, :published_at)
|
||||||
|
|
||||||
@dossiers_cumulative = cumulative_hash(dossiers, :initiated_at)
|
@dossiers_cumulative = cumulative_hash(dossiers, :initiated_at)
|
||||||
@dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :initiated_at)
|
@dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :initiated_at)
|
||||||
|
@ -36,7 +36,7 @@ class StatsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def last_four_months_hash(association, date_attribute = :created_at)
|
def last_four_months_hash(association, date_attribute)
|
||||||
min_date = 3.months.ago.beginning_of_month.to_date
|
min_date = 3.months.ago.beginning_of_month.to_date
|
||||||
if administration_signed_in?
|
if administration_signed_in?
|
||||||
max_date = Time.now.to_date
|
max_date = Time.now.to_date
|
||||||
|
@ -53,7 +53,7 @@ class StatsController < ApplicationController
|
||||||
.map { |e| [I18n.l(e.first, format: "%B %Y"), e.last] }
|
.map { |e| [I18n.l(e.first, format: "%B %Y"), e.last] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def cumulative_hash(association, date_attribute = :created_at)
|
def cumulative_hash(association, date_attribute)
|
||||||
sum = 0
|
sum = 0
|
||||||
association
|
association
|
||||||
.group("DATE_TRUNC('month', #{date_attribute.to_s})")
|
.group("DATE_TRUNC('month', #{date_attribute.to_s})")
|
||||||
|
|
|
@ -9,6 +9,10 @@ class ProcedureDecorator < Draper::Decorator
|
||||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def published_at_fr
|
||||||
|
published_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||||
|
end
|
||||||
|
|
||||||
def logo_img
|
def logo_img
|
||||||
if logo.blank?
|
if logo.blank?
|
||||||
h.image_url(LOGO_NAME)
|
h.image_url(LOGO_NAME)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Procedure < ActiveRecord::Base
|
||||||
scope :brouillons, -> { where(published_at: nil).where(archived_at: nil) }
|
scope :brouillons, -> { where(published_at: nil).where(archived_at: nil) }
|
||||||
scope :publiees, -> { where.not(published_at: nil).where(archived_at: nil) }
|
scope :publiees, -> { where.not(published_at: nil).where(archived_at: nil) }
|
||||||
scope :archivees, -> { where.not(archived_at: nil) }
|
scope :archivees, -> { where.not(archived_at: nil) }
|
||||||
scope :publiee_ou_archivee, -> { where.not(published_at: nil) }
|
scope :publiees_ou_archivees, -> { where.not(published_at: nil) }
|
||||||
scope :by_libelle, -> { order(libelle: :asc) }
|
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
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
%th#libelle= smart_listing.sortable 'Libellé', 'libelle'
|
%th#libelle= smart_listing.sortable 'Libellé', 'libelle'
|
||||||
- if @active_class
|
- if @active_class
|
||||||
%th Lien
|
%th Lien
|
||||||
|
- if @active_class || @archived_class
|
||||||
|
%th#published_at= smart_listing.sortable 'Date publication', 'published_at'
|
||||||
|
- else
|
||||||
%th#created_at= smart_listing.sortable 'Date création', 'created_at'
|
%th#created_at= smart_listing.sortable 'Date création', 'created_at'
|
||||||
%th Actions
|
%th Actions
|
||||||
|
|
||||||
|
@ -16,6 +19,10 @@
|
||||||
= procedure.libelle
|
= procedure.libelle
|
||||||
- if @active_class
|
- if @active_class
|
||||||
%td.procedure-lien= link_to procedure.lien, procedure.lien, 'data-method' => :get
|
%td.procedure-lien= link_to procedure.lien, procedure.lien, 'data-method' => :get
|
||||||
|
- if @active_class || @archived_class
|
||||||
|
%td
|
||||||
|
= procedure.published_at_fr
|
||||||
|
- else
|
||||||
%td
|
%td
|
||||||
= procedure.created_at_fr
|
= procedure.created_at_fr
|
||||||
%td
|
%td
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
%ul.numbers
|
%ul.numbers
|
||||||
%li.number
|
%li.number
|
||||||
.number-value
|
.number-value
|
||||||
= number_with_delimiter(Procedure.publiee_ou_archivee.count, :locale => :fr)
|
= number_with_delimiter(Procedure.publiees_ou_archivees.count, :locale => :fr)
|
||||||
.number-label<
|
.number-label<
|
||||||
procédures
|
procédures
|
||||||
%br<>
|
%br<>
|
||||||
|
|
|
@ -2,35 +2,13 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe StatsController, type: :controller do
|
describe StatsController, type: :controller do
|
||||||
describe "#last_four_months_hash" do
|
describe "#last_four_months_hash" do
|
||||||
context "without a date attribute" do
|
context "while a regular user is logged in" do
|
||||||
before do
|
|
||||||
FactoryGirl.create(:procedure, :created_at => 6.months.ago)
|
|
||||||
FactoryGirl.create(:procedure, :created_at => 62.days.ago)
|
|
||||||
FactoryGirl.create(:procedure, :created_at => 62.days.ago)
|
|
||||||
FactoryGirl.create(:procedure, :created_at => 31.days.ago)
|
|
||||||
|
|
||||||
@controller = StatsController.new
|
|
||||||
|
|
||||||
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
let (:association) { Procedure.all }
|
|
||||||
|
|
||||||
subject { @controller.send(:last_four_months_hash, association) }
|
|
||||||
|
|
||||||
it { expect(subject).to eq([
|
|
||||||
[I18n.l(62.days.ago.beginning_of_month, format: "%B %Y"), 2],
|
|
||||||
[I18n.l(31.days.ago.beginning_of_month, format: "%B %Y"), 1]
|
|
||||||
])
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with a date attribute" do
|
|
||||||
before do
|
before do
|
||||||
FactoryGirl.create(:procedure, :created_at => 6.months.ago, :updated_at => 6.months.ago)
|
FactoryGirl.create(:procedure, :created_at => 6.months.ago, :updated_at => 6.months.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago)
|
||||||
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 1.day.ago)
|
||||||
@controller = StatsController.new
|
@controller = StatsController.new
|
||||||
|
|
||||||
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
||||||
|
@ -49,10 +27,10 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
context "while a super admin is logged in" do
|
context "while a super admin is logged in" do
|
||||||
before do
|
before do
|
||||||
FactoryGirl.create(:procedure, :created_at => 6.months.ago)
|
FactoryGirl.create(:procedure, :updated_at => 6.months.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago)
|
FactoryGirl.create(:procedure, :updated_at => 45.days.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 1.day.ago)
|
FactoryGirl.create(:procedure, :updated_at => 1.day.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 1.day.ago)
|
FactoryGirl.create(:procedure, :updated_at => 1.day.ago)
|
||||||
|
|
||||||
@controller = StatsController.new
|
@controller = StatsController.new
|
||||||
|
|
||||||
|
@ -61,7 +39,7 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
let (:association) { Procedure.all }
|
let (:association) { Procedure.all }
|
||||||
|
|
||||||
subject { @controller.send(:last_four_months_hash, association) }
|
subject { @controller.send(:last_four_months_hash, association, :updated_at) }
|
||||||
|
|
||||||
it { expect(subject).to eq([
|
it { expect(subject).to eq([
|
||||||
[I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1],
|
[I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1],
|
||||||
|
@ -72,25 +50,6 @@ describe StatsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#cumulative_hash' do
|
describe '#cumulative_hash' do
|
||||||
context "without a date attribute" do
|
|
||||||
before do
|
|
||||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago)
|
|
||||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago)
|
|
||||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago)
|
|
||||||
end
|
|
||||||
|
|
||||||
let (:association) { Procedure.all }
|
|
||||||
|
|
||||||
subject { StatsController.new.send(:cumulative_hash, association) }
|
|
||||||
|
|
||||||
it { expect(subject).to eq({
|
|
||||||
45.days.ago.beginning_of_month => 1,
|
|
||||||
15.days.ago.beginning_of_month => 3
|
|
||||||
})
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with a date attribute" do
|
|
||||||
before do
|
before do
|
||||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.days.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 20.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 20.days.ago)
|
||||||
|
@ -107,7 +66,6 @@ describe StatsController, type: :controller do
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
describe "#procedures_count_per_administrateur" do
|
describe "#procedures_count_per_administrateur" do
|
||||||
let!(:administrateur_1) { create(:administrateur) }
|
let!(:administrateur_1) { create(:administrateur) }
|
||||||
|
|
Loading…
Reference in a new issue