Sha256: c97645ca1747320cb479f8ac1dbef29f835ce239e0bedec228c42507449b0988

Contents?: true

Size: 1.89 KB

Versions: 7

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module Decidim
  class ProfileSidebarCell < Decidim::ProfileCell
    include Decidim::Messaging::ConversationHelper
    include Decidim::IconHelper
    include Decidim::ViewHooksHelper
    include Decidim::ApplicationHelper

    helper_method :profile_user, :logged_in?, :current_user

    delegate :user_signed_in?, to: :controller

    def show
      render :show
    end

    private

    def logged_in?
      current_user.present?
    end

    def profile_user
      @profile_user ||= present(model)
    end

    def can_contact_user?
      !current_user || (current_user && current_user != model && profile_user.can_be_contacted?)
    end

    def officialization_text
      profile_user.officialization_text
    end

    def can_edit_user_group_profile?
      return false unless current_user
      return false if model.is_a?(Decidim::User)
      Decidim::UserGroups::ManageableUserGroups.for(current_user).include?(model)
    end

    def profile_user_can_follow?
      profile_user.can_follow?
    end

    def badge_statuses
      Decidim::Gamification.badges.select { |badge| badge.valid_for?(profile_holder) }.map do |badge|
        status = Decidim::Gamification.status_for(profile_holder, badge.name)
        status.level.positive? ? status : nil
      end.compact
    end

    def can_join_user_group?
      return false unless current_user
      return false if model.is_a?(Decidim::User)
      Decidim::UserGroupMembership.where(user: current_user, user_group: model).empty?
    end

    def can_leave_group?
      return false unless current_user
      return false if model.is_a?(Decidim::User)
      Decidim::UserGroupMembership.where(user: current_user, user_group: model).where.not(role: :creator).any?
    end

    def user_group_email_to_be_confirmed?
      return false unless current_user
      return false if model.is_a?(Decidim::User)
      !model.confirmed?
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.18.1 app/cells/decidim/profile_sidebar_cell.rb
decidim-core-0.17.2 app/cells/decidim/profile_sidebar_cell.rb
decidim-core-0.18.0 app/cells/decidim/profile_sidebar_cell.rb
decidim-core-0.17.1 app/cells/decidim/profile_sidebar_cell.rb
decidim-core-0.16.1 app/cells/decidim/profile_sidebar_cell.rb
decidim-core-0.17.0 app/cells/decidim/profile_sidebar_cell.rb
decidim-core-0.16.0 app/cells/decidim/profile_sidebar_cell.rb