Merge branch 'dev'

This commit is contained in:
gregoirenovel 2018-01-10 18:43:45 +01:00
commit c6842eb25b
16 changed files with 78 additions and 28 deletions

View file

@ -1,21 +1,10 @@
module Manager module Manager
class ProceduresController < Manager::ApplicationController class ProceduresController < Manager::ApplicationController
# To customize the behavior of this controller, def whitelist
# simply overwrite any of the RESTful actions. For example: procedure = Procedure.find(params[:id])
# procedure.whitelist!
# def index flash[:notice] = "Procédure whitelistée."
# super redirect_to manager_procedure_path(procedure)
# @resources = Procedure. end
# page(params[:page]).
# per(10)
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Procedure.find_by!(slug: param)
# end
# See https://administrate-prototype.herokuapp.com/customizing_controller_actions
# for more information
end end
end end

View file

@ -53,8 +53,9 @@ class Users::DescriptionController < UsersController
redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon) redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon)
else else
if dossier.brouillon? if dossier.brouillon?
NotificationMailer.send_notification(dossier, procedure.initiated_mail_template).deliver_now!
dossier.en_construction! dossier.en_construction!
# TODO move to model
NotificationMailer.send_notification(dossier, procedure.initiated_mail_template).deliver_now!
end end
flash.notice = 'Félicitations, votre demande a bien été enregistrée.' flash.notice = 'Félicitations, votre demande a bien été enregistrée.'
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: dossier.id) redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: dossier.id)

View file

@ -26,6 +26,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
published_at: Field::DateTime, published_at: Field::DateTime,
hidden_at: Field::DateTime, hidden_at: Field::DateTime,
archived_at: Field::DateTime, archived_at: Field::DateTime,
whitelisted_at: Field::DateTime,
}.freeze }.freeze
# COLLECTION_ATTRIBUTES # COLLECTION_ATTRIBUTES
@ -54,6 +55,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
:created_at, :created_at,
:updated_at, :updated_at,
:published_at, :published_at,
:whitelisted_at,
:hidden_at, :hidden_at,
:archived_at, :archived_at,
:types_de_champ, :types_de_champ,

View file

@ -11,7 +11,7 @@ class AdministrationMailer < ApplicationMailer
def dubious_procedures(procedures_and_type_de_champs) def dubious_procedures(procedures_and_type_de_champs)
@procedures_and_type_de_champs = procedures_and_type_de_champs @procedures_and_type_de_champs = procedures_and_type_de_champs
mail(to: 'tech@tps.apientreprise.fr', mail(to: 'equipe@tps.apientreprise.fr',
subject: "[RGS] De nouvelles procédures comportent des champs interdits") subject: "[RGS] De nouvelles procédures comportent des champs interdits")
end end
end end

View file

@ -147,6 +147,10 @@ class Procedure < ActiveRecord::Base
publiee? || archivee? publiee? || archivee?
end end
def whitelisted?
whitelisted_at.present?
end
def total_dossier def total_dossier
self.dossiers.state_not_brouillon.size self.dossiers.state_not_brouillon.size
end end
@ -248,6 +252,10 @@ class Procedure < ActiveRecord::Base
}.to_json }.to_json
end end
def whitelist!
update_attribute('whitelisted_at', DateTime.now)
end
private private
def field_hash(label, table, column) def field_hash(label, table, column)

View file

@ -3,5 +3,6 @@
%ul %ul
- @procedures_and_type_de_champs.each do |procedure, type_de_champs| - @procedures_and_type_de_champs.each do |procedure, type_de_champs|
%li %li
Nº #{procedure.id}, #{procedure.libelle} : = link_to "Nº #{procedure.id},", manager_procedure_url(procedure)
 #{procedure.libelle} :
%b= type_de_champs.map(&:libelle).join(', ') %b= type_de_champs.map(&:libelle).join(', ')

View file

@ -3,7 +3,7 @@
= link_to 'SGMAP', "http://etatplateforme.modernisation.gouv.fr" = link_to 'SGMAP', "http://etatplateforme.modernisation.gouv.fr"
= Time.now.year = Time.now.year
\- \-
= link_to 'Nouveautés', 'https://github.com/sgmap/tps/releases', target: '_blank' = link_to 'Nouveautés', 'https://github.com/betagouv/tps/releases', target: '_blank'
\- \-
= link_to 'Statistiques', stats_path = link_to 'Statistiques', stats_path
\- \-

View file

@ -17,7 +17,7 @@
%li.footer-link %li.footer-link
%a{ href: '#', 'data-token' => '11c89e7ddb46fbcdcb7f8fe5fdfca818', onclick: 'mjOpenPopin(event, this)' } Newsletter %a{ href: '#', 'data-token' => '11c89e7ddb46fbcdcb7f8fe5fdfca818', onclick: 'mjOpenPopin(event, this)' } Newsletter
%li.footer-link %li.footer-link
= link_to "Nouveautés", "https://github.com/sgmap/tps/releases", :class => "footer-link" = link_to "Nouveautés", "https://github.com/betagouv/tps/releases", :class => "footer-link"
%li.footer-link %li.footer-link
= link_to "Statistiques", stats_path, :class => "footer-link" = link_to "Statistiques", stats_path, :class => "footer-link"
%li.footer-link %li.footer-link

View file

@ -0,0 +1,32 @@
-# # Show
-#
-# This view is the template for the show page.
-# It renders the attributes of a resource,
-# as well as a link to its edit page.
-#
-# ## Local variables:
-#
-# - `page`:
-# An instance of [Administrate::Page::Show][1].
-# Contains methods for accessing the resource to be displayed on the page,
-# as well as helpers for describing how each attribute of the resource
-# should be displayed.
-#
-# [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
- content_for(:title) { page.page_title }
- procedure = page.resource
%header.header
%h1.header__heading= content_for(:title)
.header__actions
- if !procedure.whitelisted?
= link_to 'whitelister', whitelist_manager_procedure_path(procedure), method: :post, class: 'button'
%dl
- page.attributes.each do |attribute|
%dt.attribute-label
= t("helpers.label.#{resource_name}.#{attribute.name}", default: attribute.name.titleize)
%dd.attribute-data{ class: "attribute-data--#{attribute.html_class}" }
= render_field attribute

View file

@ -17,7 +17,7 @@ raise "missing domain, run with 'rake deploy domain=37.187.154.237'" if ENV['dom
# set :domain, '5.135.190.60' # set :domain, '5.135.190.60'
set :domain, ENV['domain'] set :domain, ENV['domain']
set :repository, 'https://github.com/sgmap/tps.git' set :repository, 'https://github.com/betagouv/tps.git'
set :port, 2200 set :port, 2200
set :deploy_to, '/var/www/tps_dev' set :deploy_to, '/var/www/tps_dev'

View file

@ -1,6 +1,9 @@
Rails.application.routes.draw do Rails.application.routes.draw do
namespace :manager do namespace :manager do
resources :procedures, only: [:index, :show] resources :procedures, only: [:index, :show] do
post 'whitelist', on: :member
end
resources :administrateurs, only: [:index, :show] resources :administrateurs, only: [:index, :show]
root to: "procedures#index" root to: "procedures#index"

View file

@ -0,0 +1,14 @@
describe Manager::ProceduresController, type: :controller do
describe '#whitelist' do
let(:administration) { create :administration }
let!(:procedure) { create(:procedure) }
before do
sign_in administration
post :whitelist, id: procedure.id
procedure.reload
end
it { expect(procedure.whitelisted_at).not_to be_nil }
end
end

View file

@ -50,7 +50,7 @@ describe RootController, type: :controller do
render_views render_views
before do before do
stub_request(:get, "https://api.github.com/repos/sgmap/tps/releases/latest") stub_request(:get, "https://api.github.com/repos/betagouv/tps/releases/latest")
.to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {}) .to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
subject subject

View file

@ -29,7 +29,7 @@ feature 'Administrator connection' do
end end
context 'when clicking on sign-out' do context 'when clicking on sign-out' do
before do before do
stub_request(:get, "https://api.github.com/repos/sgmap/tps/releases/latest") stub_request(:get, "https://api.github.com/repos/betagouv/tps/releases/latest")
.to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {}) .to_return(:status => 200, :body => '{"tag_name": "plip", "body": "blabla", "published_at": "2016-02-09T16:46:47Z"}', :headers => {})
page.find_by_id('sign-out').find('a').click page.find_by_id('sign-out').find('a').click

View file

@ -2,7 +2,7 @@
http_interactions: http_interactions:
- request: - request:
method: get method: get
uri: https://api.github.com/repos/sgmap/tps/releases/latest uri: https://api.github.com/repos/betagouv/tps/releases/latest
body: body:
encoding: US-ASCII encoding: US-ASCII
string: '' string: ''

View file

@ -2,7 +2,7 @@
http_interactions: http_interactions:
- request: - request:
method: get method: get
uri: https://api.github.com/repos/sgmap/tps/releases/latest uri: https://api.github.com/repos/betagouv/tps/releases/latest
body: body:
encoding: US-ASCII encoding: US-ASCII
string: '' string: ''