Merge pull request #2183 from betagouv/change_dossier_state_from_manager

Manager: can change dossier state to instruction
This commit is contained in:
LeSim 2018-07-02 16:27:45 +02:00 committed by GitHub
commit 132919260d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 1 deletions

View file

@ -1,4 +1,12 @@
module Manager
class DossiersController < Manager::ApplicationController
def change_state_to_instruction
dossier = Dossier.find(params[:id])
dossier.update(state: 'en_instruction', processed_at: nil, motivation: nil)
dossier.attestation&.destroy
logger.info("Le dossier #{dossier.id} est repassé en instruction par #{current_administration.email}")
flash[:notice] = "Le dossier #{dossier.id} est repassé en instruction"
redirect_to manager_dossier_path(dossier)
end
end
end

View file

@ -12,7 +12,7 @@ as defined by the routes in the `admin/` namespace
<hr />
<% Administrate::Namespace.new(namespace).resources.reject { |resource| resource.resource == 'dossiers'}.each do |resource| %>
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
<%= link_to(
display_resource_name(resource),

View file

@ -0,0 +1,48 @@
<%#
# 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) { t("administrate.actions.show_resource", name: page.page_title) } %>
<% dossier = page.resource %>
<header class="main-content__header" role="banner">
<h1 class="main-content__page-title">
<%= content_for(:title) %>
</h1>
<div>
<% if dossier.termine? %>
<%= link_to 'repasser en instruction', change_state_to_instruction_manager_dossier_path(dossier), method: :post, class: 'button' %>
<% end %>
<div>
</header>
<section class="main-content__body">
<dl>
<% page.attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: attribute.name.titleize,
) %>
</dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute %></dd>
<% end %>
</dl>
</section>

View file

@ -6,6 +6,10 @@ Rails.application.routes.draw do
post 'whitelist', on: :member
end
resources :dossiers, only: [:index, :show] do
post 'change_state_to_instruction', on: :member
end
resources :administrateurs, only: [:index, :show, :new, :create] do
post 'reinvite', on: :member
put 'enable_feature', on: :member