Sha256: 38a1573bb12484a8d43ccba340ae7c4f0cdf135ba14a55368bfc10da896aa9a1
Contents?: true
Size: 1.58 KB
Versions: 31
Compression:
Stored size: 1.58 KB
Contents
# frozen_string_literal: true module Decidim class ProfileCell < Decidim::ViewModel include Decidim::ApplicationHelper include Decidim::Core::Engine.routes.url_helpers include Decidim::UserProfileHelper include Decidim::AriaSelectedLinkToHelper include ActiveLinkTo delegate :current_organization, :current_user, :user_groups_enabled?, to: :controller def show return render :invalid if profile_holder.blank? return render :inaccessible if profile_holder.blocked? && current_user_logged_in? render :show end def profile_holder model end def content_cell context[:content_cell] end def active_content context[:active_content] end def current_user_logged_in? current_user && !current_user.admin? end def own_profile? current_user && current_user == profile_holder end def manageable_group? return false unless profile_holder.is_a?(Decidim::UserGroup) current_user && current_user.manageable_user_groups.include?(profile_holder) end def profile_tabs return render :user_group_tabs if profile_holder.is_a?(Decidim::UserGroup) render :user_tabs end def unread_count return profile_holder.unread_messages_count_for(current_user) if profile_holder.is_a?(Decidim::UserGroup) current_user.unread_messages_count end def label_conversations label = I18n.t("decidim.profiles.show.conversations") label = "#{label} <span class=\"badge\">#{unread_count}</span>" if unread_count.positive? label end end end
Version data entries
31 entries across 31 versions & 1 rubygems