[PostSets] Fix exception on admin update

This code path had a few issues which weren't triggered previously.
Also changes the visibility change modaction to track the new visibility.
This commit is contained in:
Earlopain 2022-05-23 18:18:26 +02:00
parent babffdf2d4
commit 4168692f2d
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 7 additions and 7 deletions

View File

@ -53,11 +53,11 @@ class PostSetsController < ApplicationController
unless @post_set.is_owner?(CurrentUser.user)
if @post_set.saved_change_to_is_public?
ModAction.log(:set_mark_private, {set_id: @post_set.id, user_id: @post_set.creator_id})
ModAction.log(:set_change_visibility, { set_id: @post_set.id, user_id: @post_set.creator_id, is_public: @post_set.is_public })
end
if @post_set.saved_change_to_watched_attribute?
Modaction.log(:set_update, {set_id: @post_set.id, user_id: @post_set.creator_id})
if @post_set.saved_change_to_watched_attributes?
ModAction.log(:set_update, { set_id: @post_set.id, user_id: @post_set.creator_id })
end
end

View File

@ -100,8 +100,8 @@ class ModActionDecorator < ApplicationDecorator
### Set ###
when "set_mark_private"
"Made set ##{vals['set_id']} by #{user} private"
when "set_change_visibility"
"Made set ##{vals['set_id']} by #{user} #{vals['is_public'] ? 'public' : 'private'}"
when "set_update"
"Edited set ##{vals['set_id']} by #{user}"
when "set_delete"

View File

@ -46,7 +46,7 @@ class ModAction < ApplicationRecord
:report_reason_update,
:set_update,
:set_delete,
:set_mark_private,
:set_change_visibility,
:tag_alias_create,
:tag_alias_update,
:tag_implication_create,

View File

@ -66,7 +66,7 @@ class PostSet < ApplicationRecord
end
def saved_change_to_watched_attributes?
saved_change_to_name? || saved_change_to_shortname? || saved_change_to_description?
saved_change_to_name? || saved_change_to_shortname? || saved_change_to_description? || saved_change_to_transfer_on_delete?
end
module ValidationMethods