[ModActions] Log when user is linked to artists

This commit is contained in:
Earlopain 2022-03-06 15:38:08 +01:00
parent a72473cb32
commit 57a9c728dc
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 17 additions and 3 deletions

View File

@ -47,6 +47,10 @@ class ModActionDecorator < ApplicationDecorator
"Locked artist page artist ##{vals['artist_page']}"
when "artist_page_unlock"
"Unlocked artist page artist ##{vals['artist_page']}"
when "artist_user_linked"
"Linked #{user} to artist ##{vals['artist_page']}"
when "artist_user_unlinked"
"Unlinked #{user} from artist ##{vals['artist_page']}"
### User ###

View File

@ -34,10 +34,18 @@ class Artist < ApplicationRecord
def log_changes
if name_changed? && !new_record?
ModAction.log(:artist_page_rename, {new_name: name, old_name: name_was})
ModAction.log(:artist_page_rename, { new_name: name, old_name: name_was })
end
if is_locked_changed?
ModAction.log(is_locked ? :artist_page_lock : :artist_page_unlock, {artist_page: id})
ModAction.log(is_locked ? :artist_page_lock : :artist_page_unlock, { artist_page: id })
end
if linked_user_id_changed?
# FIXME: This should also go in artist_versions
if linked_user_id.present?
ModAction.log(:artist_user_linked, { artist_page: id, user_id: linked_user_id })
else
ModAction.log(:artist_user_unlinked, { artist_page: id, user_id: linked_user_id_was })
end
end
end

View File

@ -9,6 +9,8 @@ class ModAction < ApplicationRecord
:artist_page_rename,
:artist_page_lock,
:artist_page_unlock,
:artist_user_linked,
:artist_user_unlinked,
:blip_delete,
:blip_hide,
:blip_unhide,

View File

@ -10,7 +10,7 @@
<%= f.input :linked_user_id, label: "Linked User ID" %>
<%= f.input :is_locked, label: "Locked" %>
<% end %>
<%= f.input :other_names_string, label: "Other names", as: :text, hint: '<b style="color: red;">NEW</b> Separate names with spaces, not commas. Use underscores for spaces inside names. Limit 25.'.html_safe %>
<%= f.input :other_names_string, label: "Other names", as: :text, hint: 'Separate names with spaces, not commas. Use underscores for spaces inside names. Limit 25.'.html_safe %>
<%= f.input :group_name %>
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5", :value => params.dig(:artist, :url_string) || @artist.urls.join("\n")}, :hint => "You can prefix a URL with - to mark it as dead." %>