Sha256: 4069f548dc198a5b2b0650c7c3b71fa02f2d336257093f30e3bfdf783c340f7d

Contents?: true

Size: 908 Bytes

Versions: 46

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # The controller to handle the user's interests page.
  class UserInterestsController < Decidim::ApplicationController
    include Decidim::UserProfile

    helper_method :scopes

    def show
      enforce_permission_to :read, :user, current_user: current_user
      @user_interests = form(UserInterestsForm).from_model(current_user)
    end

    def update
      enforce_permission_to :update, :user, current_user: current_user
      @user_interests = form(UserInterestsForm).from_params(params)

      UpdateUserInterests.call(current_user, @user_interests) do
        on(:ok) do
          flash.keep[:notice] = t("user_interests.update.success", scope: "decidim")
        end

        on(:invalid) do
          flash.keep[:alert] = t("user_interests.update.error", scope: "decidim")
        end
      end

      redirect_to action: :show
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
decidim-core-0.17.2 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.18.0 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.17.1 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.16.1 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.17.0 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.16.0 app/controllers/decidim/user_interests_controller.rb