artists: fix ban/unban actions.

Fix the ban! and unban! methods to:

* Lock the artist while it is being banned or unbanned.
* Perform the edits as a mass update, so that the posts are updated in parallel.
* Edit the artist as the banner rather than as the current user.
* Soft delete the banned_artist implication when an artist is unbanned instead of hard deleting it.
* Ignore the banned_artist implication if it's deleted.
This commit is contained in:
evazion
2022-11-20 18:33:15 -06:00
parent 01c6d11253
commit 4fd028a5ce
5 changed files with 32 additions and 29 deletions

View File

@@ -19,13 +19,13 @@ class ArtistsController < ApplicationController
def ban
@artist = authorize Artist.find(params[:id])
@artist.ban!(banner: CurrentUser.user)
@artist.ban!(CurrentUser.user)
redirect_to(artist_path(@artist), :notice => "Artist was banned")
end
def unban
@artist = authorize Artist.find(params[:id])
@artist.unban!
@artist.unban!(CurrentUser.user)
redirect_to(artist_path(@artist), :notice => "Artist was unbanned")
end