Class: Decidim::EndorsementsController
- Inherits:
-
Components::BaseController
- Object
- DecidimController
- ApplicationController
- Components::BaseController
- Decidim::EndorsementsController
- Includes:
- EndorsableHelper
- Defined in:
- app/controllers/decidim/endorsements_controller.rb
Overview
Exposes the ‘Endorsements` so that users can endorse resources.
Instance Method Summary collapse
- #create ⇒ Object
-
#current_component ⇒ Object
should be pubic in order to be visibe in NeedsPermission#permissions_context.
- #destroy ⇒ Object
- #identities ⇒ Object
Methods included from EndorsableHelper
#current_user_can_endorse?, #endorsement_buttons_cell, #endorsements_blocked?, #endorsements_enabled?, #endorsers_list_cell, #fully_endorsed?, #path_to_create_endorsement, #path_to_destroy_endorsement, #render_endorsement_identity, #show_endorsements_card?
Methods inherited from Components::BaseController
#current_manifest, #permission_class_chain, #permission_scope, #redirect_unless_feature_private, #share_token
Methods included from RegistersPermissions
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/decidim/endorsements_controller.rb', line 15 def create :create, :endorsement, resource: resource user_group_id = params[:user_group_id] EndorseResource.call(resource, current_user, user_group_id) do on(:ok) do resource.reload render :update_buttons_and_counters end on(:invalid) do render json: { error: I18n.t("resource_endorsements.create.error", scope: "decidim") }, status: :unprocessable_entity end end end |
#current_component ⇒ Object
should be pubic in order to be visibe in NeedsPermission#permissions_context
52 53 54 |
# File 'app/controllers/decidim/endorsements_controller.rb', line 52 def current_component resource.component end |
#destroy ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/decidim/endorsements_controller.rb', line 31 def destroy :withdraw, :endorsement, resource: resource user_group_id = params[:user_group_id] user_group = user_groups.find(user_group_id) if user_group_id UnendorseResource.call(resource, current_user, user_group) do on(:ok) do resource.reload render :update_buttons_and_counters end end end |
#identities ⇒ Object
44 45 46 47 48 49 |
# File 'app/controllers/decidim/endorsements_controller.rb', line 44 def identities :create, :endorsement, resource: resource @user_verified_groups = Decidim::UserGroups::ManageableUserGroups.for(current_user).verified render :identities, layout: false end |