From 964ff4bb9fbd0d6b0b0f53363762e29ed4ca6e97 Mon Sep 17 00:00:00 2001 From: andreymal Date: Thu, 31 Aug 2023 23:32:57 +0300 Subject: [PATCH] Fix things related to deleted authors --- mini_fiction/templates/admin/votes/index.html | 2 ++ mini_fiction/templates/includes/chapters_short.html | 3 ++- mini_fiction/views/editlog.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mini_fiction/templates/admin/votes/index.html b/mini_fiction/templates/admin/votes/index.html index db78a048..6844592b 100644 --- a/mini_fiction/templates/admin/votes/index.html +++ b/mini_fiction/templates/admin/votes/index.html @@ -29,10 +29,12 @@

{{ page_title }}

+ {% if vote.author %} {{- user_avatar(vote.author) }} {{- vote.author.username -}} + {% else %}N/A{% endif %} {{ vote.vote_value }} diff --git a/mini_fiction/templates/includes/chapters_short.html b/mini_fiction/templates/includes/chapters_short.html index c3343b51..ded9f300 100644 --- a/mini_fiction/templates/includes/chapters_short.html +++ b/mini_fiction/templates/includes/chapters_short.html @@ -1,10 +1,11 @@ {% for chapter in chapters %} + {% set authors = chapter.story.authors -%}

{{ chapter.autotitle }}

{{ chapter.story.title }} {%- if chapter.story.id in unread_chapters_count and unread_chapters_count[chapter.story.id] > 0 %} (+ {{- unread_chapters_count[chapter.story.id] -}} - ){% endif %} {{ pgettext('story_by', 'by') }} {{ chapter.story.authors[0].username }} + ){% endif %}{% if authors %} {{ pgettext('story_by', 'by') }} {{ authors[0].username }}{% endif %} {%- if chapter.first_published_at %} {%- endif -%}

diff --git a/mini_fiction/views/editlog.py b/mini_fiction/views/editlog.py index 14bec8f1..be5c6d10 100644 --- a/mini_fiction/views/editlog.py +++ b/mini_fiction/views/editlog.py @@ -93,6 +93,8 @@ def show(editlog_id): def load_users_for_editlog(edit_log): user_ids = set() for item in edit_log: + if item.user is None: + continue user_ids.add(item.user.id) item_data = item.data if 'contributors' in item_data: