[Misc] Fix the bug on the history page of a destroyed artist

This commit is contained in:
Cinder 2024-08-02 16:16:23 -07:00
parent 70cacaf9db
commit 8cf6052f91
3 changed files with 25 additions and 21 deletions

View File

@ -8,7 +8,11 @@ module ArtistVersionsHelper
def artist_version_other_names_diff(artist_version)
new_names = artist_version.other_names
old_names = artist_version.previous.try(:other_names)
latest_names = artist_version.artist.other_names
if artist_version.artist.present?
latest_names = artist_version.artist.other_names
else
latest_names = new_names
end
diff_list_html(new_names, old_names, latest_names)
end
@ -16,7 +20,11 @@ module ArtistVersionsHelper
def artist_version_urls_diff(artist_version)
new_urls = artist_version.urls
old_urls = artist_version.previous.try(:urls)
latest_urls = artist_version.artist.urls.map(&:to_s)
if artist_version.artist.present?
latest_urls = artist_version.artist.urls.map(&:to_s)
else
latest_urls = new_urls
end
diff_list_html(new_urls, old_urls, latest_urls)
end

View File

@ -7,7 +7,6 @@ class ArtistVersion < ApplicationRecord
belongs_to_updater
user_status_counter :artist_edit_count, foreign_key: :updater_id
belongs_to :artist
delegate :visible?, :to => :artist
module SearchMethods
def for_user(user_id)

View File

@ -15,30 +15,27 @@
<tbody>
<% @artist_versions.each do |artist_version| %>
<tr>
<% if artist_version.visible? %>
<td>
<%= link_to artist_version.name, artist_path(artist_version.artist_id) %>
<%= link_to "»", artist_versions_path(search: {artist_id: artist_version.artist_id}) %>
<td>
<%= link_to artist_version.name, artist_path(artist_version.artist_id) %>
<%= link_to "»", artist_versions_path(search: {artist_id: artist_version.artist_id}) %>
<% if !artist_version.is_active? %>
(deleted)
<% end %>
<% if !artist_version.is_active? %>
(deleted)
<% end %>
<% if artist_version.group_name.present? %>
<p>(group: <%= artist_version.group_name %>)</p>
<% end %>
</td>
<td><%= artist_version_other_names_diff(artist_version) %></td>
<% else %>
<td></td>
<td></td>
<% end %>
<% if artist_version.group_name.present? %>
<p>(group: <%= artist_version.group_name %>)</p>
<% end %>
</td>
<td><%= artist_version_other_names_diff(artist_version) %></td>
<td class="col-expand">
<%= artist_version_urls_diff(artist_version) if artist_version.visible? %>
<%= artist_version_urls_diff(artist_version) %>
</td>
<td>
<% if artist_version.notes_changed %>
<%= link_to "Note Changes", wiki_page_versions_path(search: {wiki_page_id: artist_version.artist.wiki_page})%>
<%= link_to "Note Changes", wiki_page_versions_path(
search: artist_version.artist.present? ? { wiki_page_id: artist_version.artist.wiki_page } : { title: artist_version.name }
)%>
<% else %>
(No Changes)
<% end %>