Sha256: 2395aab5896f59ecc34e35a22ad9491f48942d6e4fda71cfc632bd62b167735b

Contents?: true

Size: 1.54 KB

Versions: 7

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
      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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.27.4 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.3 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.2 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.1 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.0 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.0.rc2 app/controllers/decidim/user_timeline_controller.rb
decidim-core-0.27.0.rc1 app/controllers/decidim/user_timeline_controller.rb