Class: Decidim::Initiatives::CommitteeRequestsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Decidim::Initiatives::CommitteeRequestsController
- Includes:
- NeedsInitiative
- Defined in:
- app/controllers/decidim/initiatives/committee_requests_controller.rb
Overview
Controller in charge of managing committee membership
Instance Method Summary collapse
-
#approve ⇒ Object
GET /initiatives/:initiative_id/committee_requests/:id/approve.
-
#new ⇒ Object
GET /initiatives/:initiative_id/committee_requests/new.
-
#revoke ⇒ Object
DELETE /initiatives/:initiative_id/committee_requests/:id/revoke.
-
#spawn ⇒ Object
GET /initiatives/:initiative_id/committee_requests/spawn.
Methods inherited from ApplicationController
#permission_class_chain, #permission_scope, #permissions_context
Instance Method Details
#approve ⇒ Object
GET /initiatives/:initiative_id/committee_requests/:id/approve
44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/decidim/initiatives/committee_requests_controller.rb', line 44 def approve :approve, :initiative_committee_member, request: membership_request ApproveMembershipRequest.call(membership_request) do on(:ok) do redirect_to edit_initiative_path(current_initiative), flash: { notice: I18n.t("success", scope: "decidim.initiatives.committee_requests.approve") } end end end |
#new ⇒ Object
GET /initiatives/:initiative_id/committee_requests/new
13 14 15 |
# File 'app/controllers/decidim/initiatives/committee_requests_controller.rb', line 13 def new :request_membership, :initiative, initiative: current_initiative end |
#revoke ⇒ Object
DELETE /initiatives/:initiative_id/committee_requests/:id/revoke
57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/decidim/initiatives/committee_requests_controller.rb', line 57 def revoke :revoke, :initiative_committee_member, request: membership_request RevokeMembershipRequest.call(membership_request) do on(:ok) do redirect_to edit_initiative_path(current_initiative), flash: { notice: I18n.t("success", scope: "decidim.initiatives.committee_requests.revoke") } end end end |
#spawn ⇒ Object
GET /initiatives/:initiative_id/committee_requests/spawn
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/decidim/initiatives/committee_requests_controller.rb', line 18 def spawn :request_membership, :initiative, initiative: current_initiative form = Decidim::Initiatives::CommitteeMemberForm .from_params(initiative_id: current_initiative.id, user_id: current_user.id, state: "requested") .with_context(current_organization: current_initiative.organization, current_user:) SpawnCommitteeRequest.call(form) do on(:ok) do redirect_to initiatives_path, flash: { notice: I18n.t( "success", scope: "decidim.initiatives.committee_requests.spawn" ) } end on(:invalid) do |request| redirect_to initiatives_path, flash: { error: request.errors..to_sentence } end end end |