Sha256: db585051e0e10973941087de90539f9bd0647162a7c6808152a2319ba60c2f7d
Contents?: true
Size: 1.24 KB
Versions: 65
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when unofficializing a user. class UnofficializeUser < Rectify::Command # Public: Initializes the command. # # user - The user to be unofficialized. # current_user - The user performing the action def initialize(user, current_user) @user = user @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when the unofficialization suceeds. # - :invalid when the form is invalid. # # Returns nothing. def call unofficialize_user broadcast(:ok) end private attr_reader :user, :current_user def unofficialize_user Decidim.traceability.perform_action!( "unofficialize", user, current_user, extra: { officialized_user_badge: nil, officialized_user_badge_previous: user.officialized_as, officialized_user_at: nil, officialized_user_at_previous: user.officialized_at } ) do user.update!(officialized_at: nil, officialized_as: nil) end end end end end
Version data entries
65 entries across 65 versions & 1 rubygems