diff --git a/catalog/templates/_item_comments.html b/catalog/templates/_item_comments.html index ca8503f7..61fd2b3d 100644 --- a/catalog/templates/_item_comments.html +++ b/catalog/templates/_item_comments.html @@ -33,6 +33,19 @@ {% if forloop.counter <= 10 %}
+ {% if comment.item.class_name == "podcastepisode" %} + + + + {% endif %} {% liked_piece comment as liked %} {% include 'like_stats.html' with liked=liked piece=comment %} @@ -55,8 +68,7 @@ {{ comment.mark.action_label }} - {% if comment.focus_item %}{{ comment.focus_item.title }}{% endif %} - {% if comment.item != item %}{{ comment.item.title }}{% endif %} + {% if comment.item != item %}{{ comment.item.title }}{% endif %}
{{ comment.html|safe }}
{% else %} diff --git a/catalog/templates/item_mark_list.html b/catalog/templates/item_mark_list.html index edeea024..e4da00f3 100644 --- a/catalog/templates/item_mark_list.html +++ b/catalog/templates/item_mark_list.html @@ -51,9 +51,7 @@ {{ mark.owner.display_name }} {{ mark.action_label }} {% if mark.rating_grade %}{{ mark.rating_grade|rating_star }}{% endif %} - {% if mark.comment.focus_item %} - {{ mark.comment.focus_item.title }} - {% endif %} + {% if mark.comment.item != item %}{{ mark.comment.item.title }}{% endif %}
{{ mark.comment.html|safe }}
diff --git a/journal/migrations/0013_remove_comment_focus_item.py b/journal/migrations/0013_remove_comment_focus_item.py new file mode 100644 index 00000000..58191169 --- /dev/null +++ b/journal/migrations/0013_remove_comment_focus_item.py @@ -0,0 +1,16 @@ +# Generated by Django 4.2.3 on 2023-07-12 21:55 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("journal", "0012_alter_piece_polymorphic_ctype_alter_shelf_items"), + ] + + operations = [ + migrations.RemoveField( + model_name="comment", + name="focus_item", + ), + ] diff --git a/journal/models.py b/journal/models.py index 7062dfa6..50d4d259 100644 --- a/journal/models.py +++ b/journal/models.py @@ -212,9 +212,6 @@ class Memo(Content): class Comment(Content): text = models.TextField(blank=False, null=False) - focus_item = models.ForeignKey( - Item, on_delete=models.PROTECT, null=True, related_name="focused_comments" - ) @property def html(self): @@ -232,18 +229,14 @@ class Comment(Content): @property def item_url(self): - if self.focus_item: - return self.focus_item.get_absolute_url_with_position( - self.metadata["position"] - ) + if self.metadata.get("position"): + return self.item.get_absolute_url_with_position(self.metadata["position"]) else: return self.item.url @staticmethod def comment_item_by_user(item, user, text, visibility=0, created_time=None): - comment = Comment.objects.filter( - owner=user, item=item, focus_item__isnull=True - ).first() + comment = Comment.objects.filter(owner=user, item=item).first() if not text: if comment is not None: comment.delete() @@ -1138,9 +1131,7 @@ class Mark: @cached_property def comment(self): - return Comment.objects.filter( - owner=self.owner, item=self.item, focus_item__isnull=True - ).first() + return Comment.objects.filter(owner=self.owner, item=self.item).first() @property def comment_text(self): diff --git a/journal/templates/_list_item.html b/journal/templates/_list_item.html index 72804dc6..feb98f83 100644 --- a/journal/templates/_list_item.html +++ b/journal/templates/_list_item.html @@ -63,9 +63,6 @@ {% comment %} {{ mark.owner.display_name }} {% endcomment %} {{ mark.action_label }} {% if mark.rating_grade %}{{ mark.rating_grade|rating_star }}{% endif %} - {% if mark.comment.focus_item %} - {{ mark.comment.focus_item.title }} - {% endif %} {% if mark.tags %}
diff --git a/social/migrations/0006_alter_localactivity_template.py b/social/migrations/0006_alter_localactivity_template.py new file mode 100644 index 00000000..70fc04b5 --- /dev/null +++ b/social/migrations/0006_alter_localactivity_template.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.3 on 2023-07-12 21:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("social", "0005_alter_localactivity_template"), + ] + + operations = [ + migrations.AlterField( + model_name="localactivity", + name="template", + field=models.CharField( + choices=[ + ("mark_item", "Markitem"), + ("review_item", "Reviewitem"), + ("create_collection", "Createcollection"), + ("like_collection", "Likecollection"), + ("feature_collection", "Featurecollection"), + ("comment_child_item", "Commentchilditem"), + ], + max_length=50, + ), + ), + ] diff --git a/social/models.py b/social/models.py index a94aaa2b..bb6024fd 100644 --- a/social/models.py +++ b/social/models.py @@ -27,7 +27,6 @@ class ActivityTemplate(models.TextChoices): LikeCollection = "like_collection" FeatureCollection = "feature_collection" CommentChildItem = "comment_child_item" - CommentFocusItem = "comment_focus_item" # TODO: remove this after migration class LocalActivity(models.Model, UserOwnedObjectMixin): @@ -184,20 +183,6 @@ class FeaturedCollectionProcessor(DefaultActivityProcessor): template = ActivityTemplate.FeatureCollection -# @DataSignalManager.register -# class CommentFocusItemProcessor(DefaultActivityProcessor): -# model = Comment -# template = ActivityTemplate.CommentFocusItem - -# def created(self): -# if self.action_object.focus_item: -# super().created() - -# def updated(self): -# if self.action_object.focus_item: -# super().updated() - - @DataSignalManager.register class CommentChildItemProcessor(DefaultActivityProcessor): model = Comment diff --git a/social/templates/activity/comment_focus_item.html b/social/templates/activity/comment_focus_item.html deleted file mode 100644 index 1221e1e5..00000000 --- a/social/templates/activity/comment_focus_item.html +++ /dev/null @@ -1,75 +0,0 @@ -{% load static %} -{% load i18n %} -{% load l10n %} -{% load admin_url %} -{% load mastodon %} -{% load oauth_token %} -{% load truncate %} -{% load thumb %} -{% load prettydate %} -{% load user_actions %} -{% load duration %} -{% wish_item_action activity.action_object.item as action %} -{% like_piece_action activity.action_object as like_action %} - - {% if activity.action_object.metadata.shared_link %} - - - - {% endif %} - - {% liked_piece activity.action_object as liked %} - {% include 'like_stats.html' with liked=liked piece=activity.action_object %} - - - - - - - - - {% if not action.taken %} - - - - {% else %} - - - - {% endif %} - - -
- {{ activity.action_object.mark.action_label }} - {{ activity.action_object.focus_item.title }} - {% if activity.action_object.metadata.position %} - {{ activity.action_object.metadata.position|duration_format:1 }} - {% endif %} - {% if activity.action_object.mark.rating_grade %} - {{ activity.action_object.mark.rating_grade | rating_star }} - {% endif %} -
-
- {% include "_item_card.html" with item=activity.action_object.item allow_embed=1 %} - {% if activity.action_object.mark.comment_text %} - - {% endif %} -
diff --git a/users/models.py b/users/models.py index 9d687f06..0cb2c319 100644 --- a/users/models.py +++ b/users/models.py @@ -161,9 +161,10 @@ class User(AbstractUser): @property def display_name(self): return ( - self.mastodon_account.get("display_name") - if self.mastodon_account - else (self.username or self.mastodon_acct or "") + (self.mastodon_account.get("display_name") if self.mastodon_account else "") + or self.username + or self.mastodon_acct + or "" ) @property