forked from demarches-simplifiees/demarches-simplifiees.fr
-
Notifications
You must be signed in to change notification settings - Fork 0
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 demarches-simplifiees#9578 from adullact/feature-o…
…uidou/admin_creation_delegation_administrateur_pages Feature ouidou/admin creation delegation administrateur pages
- Loading branch information
Showing
25 changed files
with
221 additions
and
55 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
app/components/groupe_gestionnaire/card/administrateurs_component.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class GroupeGestionnaire::Card::AdministrateursComponent < ApplicationComponent | ||
def initialize(groupe_gestionnaire:) | ||
def initialize(groupe_gestionnaire:, path:) | ||
@groupe_gestionnaire = groupe_gestionnaire | ||
@path = path | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...ts/groupe_gestionnaire/card/administrateurs_component/administrateurs_component.html.haml
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class GroupeGestionnaire::Card::ChildrenComponent < ApplicationComponent | ||
def initialize(groupe_gestionnaire:) | ||
def initialize(groupe_gestionnaire:, path:) | ||
@groupe_gestionnaire = groupe_gestionnaire | ||
@path = path | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
app/components/groupe_gestionnaire/card/children_component/children_component.html.haml
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
3 changes: 2 additions & 1 deletion
3
app/components/groupe_gestionnaire/card/gestionnaires_component.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class GroupeGestionnaire::Card::GestionnairesComponent < ApplicationComponent | ||
def initialize(groupe_gestionnaire:) | ||
def initialize(groupe_gestionnaire:, path:) | ||
@groupe_gestionnaire = groupe_gestionnaire | ||
@path = path | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...onents/groupe_gestionnaire/card/gestionnaires_component/gestionnaires_component.html.haml
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
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
3 changes: 2 additions & 1 deletion
3
...omponents/groupe_gestionnaire/groupe_gestionnaire_gestionnaires/gestionnaire_component.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
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
%td= email | ||
%td= created_at | ||
%td= registration_state | ||
%td= remove_button | ||
- if @is_gestionnaire | ||
%td= remove_button |
28 changes: 28 additions & 0 deletions
28
app/controllers/administrateurs/groupe_gestionnaire_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,28 @@ | ||
module Administrateurs | ||
class GroupeGestionnaireController < AdministrateurController | ||
before_action :retrieve_groupe_gestionnaire, only: [:show, :administrateurs, :gestionnaires] | ||
|
||
def show | ||
end | ||
|
||
def administrateurs | ||
end | ||
|
||
def gestionnaires | ||
end | ||
|
||
private | ||
|
||
def retrieve_groupe_gestionnaire | ||
id = current_administrateur.groupe_gestionnaire_id | ||
@groupe_gestionnaire = GroupeGestionnaire.find(id) | ||
|
||
Sentry.configure_scope do |scope| | ||
scope.set_tags(groupe_gestionnaire: @groupe_gestionnaire.id) | ||
end | ||
rescue ActiveRecord::RecordNotFound | ||
flash.alert = 'Groupe inexistant' | ||
redirect_to admin_procedures_path, status: 404 | ||
end | ||
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
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
15 changes: 15 additions & 0 deletions
15
app/views/administrateurs/groupe_gestionnaire/administrateurs.html.haml
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,15 @@ | ||
= render partial: 'gestionnaires/breadcrumbs', | ||
locals: { steps: [['Mon groupe gestionnaire', admin_groupe_gestionnaire_path], | ||
['Administrateurs']], preview: false } | ||
|
||
.container | ||
%h1 Administrateurs de « #{@groupe_gestionnaire.name} » | ||
|
||
%table.table | ||
%thead | ||
%tr | ||
%th= 'Adresse email' | ||
%th= 'Enregistré le' | ||
%th= 'État' | ||
%tbody#administrateurs | ||
= render(GroupeGestionnaire::GroupeGestionnaireAdministrateurs::AdministrateurComponent.with_collection(@groupe_gestionnaire.administrateurs.order('users.email'), groupe_gestionnaire: @groupe_gestionnaire, is_gestionnaire: false)) |
15 changes: 15 additions & 0 deletions
15
app/views/administrateurs/groupe_gestionnaire/gestionnaires.html.haml
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,15 @@ | ||
= render partial: 'gestionnaires/breadcrumbs', | ||
locals: { steps: [['Mon groupe gestionnaire', admin_groupe_gestionnaire_path], | ||
['Gestionnaires']], preview: false } | ||
|
||
.container | ||
%h1 Gestionnaires de « #{@groupe_gestionnaire.name} » | ||
|
||
%table.table | ||
%thead | ||
%tr | ||
%th= 'Adresse email' | ||
%th= 'Enregistré le' | ||
%th= 'État' | ||
%tbody#gestionnaires | ||
= render(GroupeGestionnaire::GroupeGestionnaireGestionnaires::GestionnaireComponent.with_collection(@groupe_gestionnaire.gestionnaires.order('users.email'), groupe_gestionnaire: @groupe_gestionnaire, is_gestionnaire: false)) |
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,9 @@ | ||
= render partial: 'gestionnaires/breadcrumbs', | ||
locals: { steps: [["Mon groupe gestionnaire"]], | ||
metadatas: true } | ||
|
||
.fr-container | ||
%h2= "Gestion du groupe gestionnaire № #{@groupe_gestionnaire.id}" | ||
.fr-grid-row.fr-grid-row--gutters.fr-mb-5w | ||
= render GroupeGestionnaire::Card::GestionnairesComponent.new(groupe_gestionnaire: @groupe_gestionnaire, path: admin_groupe_gestionnaire_gestionnaires_path) | ||
= render GroupeGestionnaire::Card::AdministrateursComponent.new(groupe_gestionnaire: @groupe_gestionnaire, path: admin_groupe_gestionnaire_administrateurs_path) |
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
66 changes: 66 additions & 0 deletions
66
spec/controllers/administrateurs/groupe_gestionnaire_controller_spec.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,66 @@ | ||
describe Administrateurs::GroupeGestionnaireController, type: :controller do | ||
let(:admin) { create(:administrateur) } | ||
|
||
describe "#show" do | ||
subject { get :show } | ||
|
||
context "when not logged" do | ||
before { subject } | ||
it { expect(response).to redirect_to(new_user_session_path) } | ||
end | ||
|
||
context "when logged in" do | ||
let(:gestionnaire) { create(:gestionnaire) } | ||
let!(:groupe_gestionnaire) { create(:groupe_gestionnaire, gestionnaires: [gestionnaire], administrateurs: [admin]) } | ||
before do | ||
sign_in(admin.user) | ||
subject | ||
end | ||
|
||
it { expect(response).to have_http_status(:ok) } | ||
it { expect(assigns(:groupe_gestionnaire)).to eq(groupe_gestionnaire) } | ||
end | ||
end | ||
|
||
describe "#gestionnaires" do | ||
subject { get :gestionnaires } | ||
let(:gestionnaire) { create(:gestionnaire) } | ||
let!(:groupe_gestionnaire) { create(:groupe_gestionnaire, gestionnaires: [gestionnaire], administrateurs: [admin]) } | ||
|
||
context "when not logged" do | ||
before { subject } | ||
it { expect(response).to redirect_to(new_user_session_path) } | ||
end | ||
|
||
context "when logged in" do | ||
before do | ||
sign_in(admin.user) | ||
subject | ||
end | ||
|
||
it { expect(response).to have_http_status(:ok) } | ||
it { expect(assigns(:groupe_gestionnaire)).to eq(groupe_gestionnaire) } | ||
end | ||
end | ||
|
||
describe "#administrateurs" do | ||
subject { get :administrateurs } | ||
let(:gestionnaire) { create(:gestionnaire) } | ||
let!(:groupe_gestionnaire) { create(:groupe_gestionnaire, gestionnaires: [gestionnaire], administrateurs: [admin]) } | ||
|
||
context "when not logged" do | ||
before { subject } | ||
it { expect(response).to redirect_to(new_user_session_path) } | ||
end | ||
|
||
context "when logged in" do | ||
before do | ||
sign_in(admin.user) | ||
subject | ||
end | ||
|
||
it { expect(response).to have_http_status(:ok) } | ||
it { expect(assigns(:groupe_gestionnaire)).to eq(groupe_gestionnaire) } | ||
end | ||
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
Oops, something went wrong.