Sha256: ea69cdb52a937e56658553097eb76f8ec709b3a9a31c70c33c1b9be4e838e390

Contents?: true

Size: 1.54 KB

Versions: 23

Compression:

Stored size: 1.54 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" if current_user != user
    end

    private

    def user
      @user ||= Decidim::User.find_by(
        organization: current_organization,
        nickname: params[:nickname]
      )
    end

    def activities
      @activities ||= paginate(
        ActivitySearch.new(
          organization: current_organization,
          resource_type: "all",
          scopes: current_user.interested_scopes,
          follows: follows,
          resource_name: filter.resource_type
        ).run
      )
    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

23 entries across 23 versions & 1 rubygems

Version Path
decidim-core-0.26.8 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.7 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.5 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.4 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.3 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.2 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.1 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.0 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.0.rc2 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.26.0.rc1 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.25.2 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.25.1 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.25.0 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.25.0.rc4 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.25.0.rc3 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.25.0.rc2 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.25.0.rc1 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.24.3 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.24.2 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.24.1 app/controllers/decidim/user_timeline_controller.rb