Sha256: 1cf4c0d1f6c2df54ef6c56fb2770e8bd07d5f1695a360e2fdaaa842c8ad78224

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders the author of a resource. It is intended to be used
  # below resource titles to indicate its authorship & such, and is intended
  # for resources that have a single author.
  class AuthorCell < Decidim::ViewModel
    include LayoutHelper
    include CellsHelper
    include ::Devise::Controllers::Helpers
    include ::Devise::Controllers::UrlHelpers
    include Messaging::ConversationHelper

    property :profile_path

    delegate :current_user, to: :controller, prefix: false

    def show
      render
    end

    def profile
      render
    end

    def profile_inline
      render
    end

    def date
      render
    end

    def flag
      render
    end

    def withdraw
      render
    end

    private

    def from_context_path
      resource_locator(from_context).path
    end

    def withdraw_path
      from_context_path + "/withdraw"
    end

    def creation_date?
      return true if posts_controller?
      return unless from_context
      return unless proposals_controller?
      return unless show_action?
      true
    end

    def creation_date
      date_at = if proposals_controller?
                  from_context.published_at
                else
                  from_context.created_at
                end

      l date_at, format: :decidim_short
    end

    def commentable?
      return unless posts_controller?
      true
    end

    def author_classes
      (["author-data"] + options[:extra_classes].to_a).join(" ")
    end

    def actionable?
      return false if options[:has_actions] == false
      return true if user_author? && posts_controller?
      true if withdrawable? || flagable?
    end

    def user_author?
      true if "Decidim::UserPresenter".include? model.class.to_s
    end

    def profile_path?
      profile_path.present?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.13.1 app/cells/decidim/author_cell.rb
decidim-core-0.13.0 app/cells/decidim/author_cell.rb
decidim-core-0.13.0.pre1 app/cells/decidim/author_cell.rb