Sha256: 6716b82202a77dfcddfaa2a91e990ca34f591178bf67f61226f21b0f77771f2b

Contents?: true

Size: 1.55 KB

Versions: 5

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

module Decidim
  # The controller to show all the last activities in a Decidim Organization.
  class UserTimelineController < Decidim::ApplicationController
    include Paginable
    include UserGroups
    include FilterResource
    include Flaggable

    helper Decidim::ResourceHelper
    helper_method :activities, :resource_types, :user

    def index
      raise ActionController::RoutingError, "Not Found" unless user && current_user == user
    end

    private

    def user
      return unless params[:nickname]

      @user ||= current_organization.users.find_by("LOWER(nickname) = ?", params[:nickname].downcase)
    end

    def activities
      @activities ||= paginate(
        PublicActivities.new(
          current_organization,
          scopes: current_user.interested_scopes,
          follows: follows,
          resource_name: filter.resource_type
        ).query.with_resource_type("all")
      )
    end

    def follows
      @follows ||= Decidim::Follow.where(user: user)
    end

    def default_filter_params
      { resource_type: nil }
    end

    def resource_types
      @resource_types = %w(Decidim::Proposals::CollaborativeDraft
                           Decidim::Comments::Comment
                           Decidim::Debates::Debate
                           Decidim::Initiative
                           Decidim::Meetings::Meeting
                           Decidim::Blogs::Post
                           Decidim::Proposals::Proposal
                           Decidim::Consultations::Question)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.8 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.7 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.6 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.5 app/controllers/decidim/user_timeline_controller.rb