Sha256: 5945cbb5319e25baf06c930537bf7caf09bc2a543dc2e9b1ad111d3e00ea623f
Contents?: true
Size: 1.69 KB
Versions: 4
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true module Decidim module AdminLog # This class holds the logic to present a `Decidim::User` # for the `AdminLog` log. # # Usage should be automatic and you shouldn't need to call this class # directly, but here's an example: # # action_log = Decidim::ActionLog.last # view_helpers # => this comes from the views # UserPresenter.new(action_log, view_helpers).present class UserPresenter < Decidim::Log::BasePresenter private def action_string case action when "grant_id_documents_offline_verification", "invite", "officialize", "remove_from_admin", "show_email", "unofficialize" "decidim.admin_log.user.#{action}" else super end end def i18n_params super.merge( role: I18n.t("models.user.fields.roles.#{user_role}", scope: "decidim.admin") ) end def user_role Array(action_log.extra.dig("extra", "invited_user_role")).last end def user_badge action_log.extra.dig("extra", "officialized_user_badge") || Hash.new("") end def previous_user_badge action_log.extra.dig("extra", "officialized_user_badge_previous") || Hash.new("") end # We fake the changeset for officialization actions. def changeset Decidim::Log::DiffChangesetCalculator.new( { badge: [previous_user_badge, user_badge] }, { badge: :i18n }, i18n_labels_scope ).changeset end # If the action is officialization, then we want to show the diff def has_diff? %w(officialize unofficialize).include?(action) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems