Class: Decidim::Proposals::InviteCoauthorsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Components::BaseController
- ApplicationController
- Decidim::Proposals::InviteCoauthorsController
- Includes:
- ControllerHelpers
- Defined in:
- decidim-proposals/app/controllers/decidim/proposals/invite_coauthors_controller.rb
Instance Method Summary collapse
-
#cancel ⇒ Object
author cancels invitation.
-
#create ⇒ Object
author invites coauthor.
-
#destroy ⇒ Object
coauthor declines invitation.
-
#update ⇒ Object
coauthor accepts invitation.
Methods included from ControllerHelpers
#expose, included, #present, #presenter
Methods inherited from ApplicationController
#proposal_limit, #proposal_limit_reached?, #proposals
Methods inherited from Components::BaseController
#current_component, #current_manifest, #current_participatory_space, #permission_class_chain, #permission_scope, #redirect_unless_feature_private, #set_component_breadcrumb_item
Methods included from RegistersPermissions
Methods inherited from ApplicationController
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from Headers::HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#cancel ⇒ Object
author cancels invitation
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'decidim-proposals/app/controllers/decidim/proposals/invite_coauthors_controller.rb', line 30 def cancel :cancel, :proposal_coauthor_invites, { proposal:, coauthor: } CancelCoauthorship.call(proposal, ) do on(:ok) do flash[:notice] = I18n.t("cancel.success", scope: "decidim.proposals.invite_coauthors", author_name: .name) end on(:invalid) do flash[:alert] = I18n.t("cancel.error", scope: "decidim.proposals.invite_coauthors") end end redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path end |
#create ⇒ Object
author invites coauthor
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'decidim-proposals/app/controllers/decidim/proposals/invite_coauthors_controller.rb', line 13 def create :invite, :proposal_coauthor_invites, { proposal:, coauthor: } InviteCoauthor.call(proposal, ) do on(:ok) do flash[:notice] = I18n.t("create.success", scope: "decidim.proposals.invite_coauthors", author_name: .name) end on(:invalid) do flash[:alert] = I18n.t("create.error", scope: "decidim.proposals.invite_coauthors") end end redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path end |
#destroy ⇒ Object
coauthor declines invitation
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'decidim-proposals/app/controllers/decidim/proposals/invite_coauthors_controller.rb', line 62 def destroy :decline, :proposal_coauthor_invites, { proposal:, coauthor: } RejectCoauthorship.call(proposal, current_user) do on(:ok) do render json: { message: I18n.t("destroy.success", scope: "decidim.proposals.invite_coauthors") } end on(:invalid) do render json: { message: I18n.t("destroy.error", scope: "decidim.proposals.invite_coauthors") }, status: :unprocessable_entity end end end |
#update ⇒ Object
coauthor accepts invitation
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'decidim-proposals/app/controllers/decidim/proposals/invite_coauthors_controller.rb', line 47 def update :accept, :proposal_coauthor_invites, { proposal:, coauthor: } AcceptCoauthorship.call(proposal, current_user) do on(:ok) do render json: { message: I18n.t("update.success", scope: "decidim.proposals.invite_coauthors") } end on(:invalid) do render json: { message: I18n.t("update.error", scope: "decidim.proposals.invite_coauthors") }, status: :unprocessable_entity end end end |