Sha256: 27f7efb2d650b87202ff759440f7756aac6896630a7ef45dbe9c2da459de39d6

Contents?: true

Size: 857 Bytes

Versions: 7

Compression:

Stored size: 857 Bytes

Contents

# frozen_string_literal: true

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

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

    def update
      enforce_permission_to(:update, :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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.28.3 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.28.2 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.28.1 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.28.0 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.28.0.rc5 app/controllers/decidim/user_interests_controller.rb
decidim-core-0.28.0.rc4 app/controllers/decidim/user_interests_controller.rb