app/commands/decidim/admin/unofficialize_user.rb in decidim-admin-0.9.3 vs app/commands/decidim/admin/unofficialize_user.rb in decidim-admin-0.10.0
- old
+ new
@@ -5,12 +5,14 @@
# 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.
- def initialize(user)
+ # 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.
@@ -23,13 +25,25 @@
broadcast(:ok)
end
private
- attr_reader :user
+ attr_reader :user, :current_user
def unofficialize_user
- user.update!(officialized_at: nil, officialized_as: nil)
+ 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