-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1747 from etalab/features/espace-editeur
Bootstrap Espace éditeur
- Loading branch information
Showing
33 changed files
with
606 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Admin::EditorsController < AdminController | ||
def index | ||
@editors = Editor.includes(:users).page(params[:page]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/controllers/editor/authorization_requests_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Editor::AuthorizationRequestsController < EditorController | ||
def index | ||
@authorization_requests = current_editor | ||
.authorization_requests(api: namespace) | ||
.includes(:active_token) | ||
.where( | ||
status: 'validated' | ||
).page(params[:page]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class EditorController < ApplicationController | ||
include AuthenticatedUserManagement | ||
|
||
before_action :user_is_editor? | ||
helper_method :current_editor | ||
|
||
layout 'editor' | ||
|
||
protected | ||
|
||
def current_editor | ||
@current_editor ||= current_user.editor | ||
end | ||
|
||
private | ||
|
||
def user_is_editor? | ||
redirect_to_root unless current_user.editor? | ||
end | ||
|
||
def namespace | ||
request.host.split('.').first | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ def perform | |
@contact_email = '[email protected]' | ||
@contact = create_contact | ||
|
||
create_editor | ||
create_data_for_api_entreprise | ||
create_data_for_api_particulier | ||
create_data_shared | ||
|
@@ -65,6 +66,19 @@ def create_contact | |
) | ||
end | ||
|
||
def create_editor | ||
editor = Editor.create!( | ||
name: 'UMAD Corp', | ||
form_uids: %w[umadcorp-form-api-entreprise umadcorp-form-api-particulier] | ||
) | ||
create_user( | ||
email: '[email protected]', | ||
first_name: 'Edouard', | ||
last_name: 'Lefevre', | ||
editor: editor | ||
) | ||
end | ||
|
||
def create_magic_link | ||
MagicLink.create!(email: @user.email) | ||
end | ||
|
@@ -81,6 +95,7 @@ def create_api_entreprise_token_valid | |
external_id: 102, | ||
status: :validated, | ||
first_submitted_at: 2.weeks.ago, | ||
demarche: 'umadcorp-form-api-entreprise', | ||
siret: '12000101100010' | ||
} | ||
) | ||
|
@@ -163,6 +178,7 @@ def create_api_particulier_token_valid | |
intitule: 'Mairie de Bordeaux', | ||
external_id: 201, | ||
status: :validated, | ||
demarche: 'umadcorp-form-api-particulier', | ||
first_submitted_at: 2.weeks.ago | ||
} | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Editor < ApplicationRecord | ||
has_many :users, | ||
dependent: :nullify | ||
|
||
validates :name, presence: true | ||
|
||
def authorization_requests(api:) | ||
AuthorizationRequest | ||
.where(api:) | ||
.where(demarche: form_uids) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<div class="fr-table fr-table--bordered fr-table--layout-fixed"> | ||
<table> | ||
<caption> | ||
Éditeurs | ||
</caption> | ||
<thead> | ||
<tr> | ||
<% | ||
[ | ||
'ID', | ||
'Nom', | ||
'Formulaires', | ||
'Emails', | ||
].each do |attr| | ||
%> | ||
<th scope="col"> | ||
<%= attr %> | ||
</th> | ||
<% end %> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @editors.each do |editor| %> | ||
<tr id="<%= dom_id(editor) %>" class="editor"> | ||
<td class="editor-id"> | ||
<%= editor.id %> | ||
</td> | ||
<td class="editor-name"> | ||
<%= editor.name %> | ||
</td> | ||
<td class="editor-form_uids"> | ||
<ul> | ||
<% editor.form_uids.each do |form_uid| %> | ||
<% url = "#{datapass_v2_base_url(namespace)}/formulaires/#{form_uid}/demande/nouveau" %> | ||
<li> | ||
<%= link_to form_uid, url, target: '_blank' %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</td> | ||
<td class="editor-emails"> | ||
<% if editor.users %> | ||
<ul> | ||
<% editor.users.each do |user| %> | ||
<li> | ||
<%= user.email %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<%= paginate @editors %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%= form_for(@user, url: [:admin, @user]) do |f| %> | ||
<div class="fr-input-group"> | ||
<%= f.label :email, class: %w[fr-label] %> | ||
<%= f.text_field :email, disabled: true, class: %w[fr-input] %> | ||
</div> | ||
|
||
<div class="fr-select-group"> | ||
<%= f.label :editor, class: %w[fr-label] %> | ||
<%= f.collection_select :editor_id, @editors, :id, :name, { include_blank: true }, { class: %w[fr-select] } %> | ||
</div> | ||
|
||
<%= f.button :submit, class: %[fr-btn], id: 'submit' %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div class="fr-table fr-table--bordered fr-table--layout-fixed"> | ||
<table> | ||
<caption> | ||
Habilitations | ||
</caption> | ||
<thead> | ||
<tr> | ||
<% | ||
[ | ||
'DataPass ID', | ||
'Intitule', | ||
'Jeton principal', | ||
'Organization', | ||
].each do |attr| | ||
%> | ||
<th scope="col"> | ||
<%= attr %> | ||
</th> | ||
<% end %> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @authorization_requests.each do |authorization_request| %> | ||
<tr id="<%= dom_id(authorization_request) %>" class="authorization-request"> | ||
<td class="authorization_request-external_id"> | ||
<%= link_to("DataPass ##{authorization_request.external_id}", "#{datapass_v2_base_url(authorization_request.api)}/public/demandes/#{authorization_request.public_id}", target: '_blank')%> | ||
</td> | ||
<td class="authorization_request-intitule"> | ||
<%= authorization_request.intitule %> | ||
</td> | ||
<td class="authorization_request-token"> | ||
<% if authorization_request.token %> | ||
<%= render partial: 'shared/tokens/detail_short', locals: { token: authorization_request.token.decorate } %> | ||
<% end %> | ||
</td> | ||
<td class="authorization_request-siret"> | ||
<a href="https://annuaire-entreprises.data.gouv.fr/etablissement/<%= authorization_request.siret %>" target="_blank"> | ||
<%= authorization_request.siret %> | ||
</a> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<%= paginate @authorization_requests %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.