remove focus_item column which is no longer in use
This commit is contained in:
parent
add2a2077e
commit
fc2f98a5bc
9 changed files with 66 additions and 114 deletions
|
@ -33,6 +33,19 @@
|
|||
{% if forloop.counter <= 10 %}
|
||||
<section>
|
||||
<span class="action">
|
||||
{% if comment.item.class_name == "podcastepisode" %}
|
||||
<span>
|
||||
<a href="{{ comment.item_url }}"
|
||||
data-media="{{ comment.item.media_url }}"
|
||||
data-position="{{ comment.metadata.position|default:0 }}"
|
||||
data-cover="{{ comment.item.cover_url|default:item.cover.url }}"
|
||||
class="episode"
|
||||
data-hosts="{{ comment.item.hosts|join:' / ' }}"
|
||||
data-title="{{ comment.item.title }}"
|
||||
data-album="{{ item.title }}"
|
||||
data-uuid="{{ comment.item.uuid }}"><i class="fa-regular fa-circle-play"></i></a>
|
||||
</span>
|
||||
{% endif %}
|
||||
<span>
|
||||
{% liked_piece comment as liked %}
|
||||
{% include 'like_stats.html' with liked=liked piece=comment %}
|
||||
|
@ -55,8 +68,7 @@
|
|||
{{ comment.mark.action_label }}
|
||||
</span>
|
||||
</span>
|
||||
{% if comment.focus_item %}<a href="{{ comment.focus_item.url }}">{{ comment.focus_item.title }}</a>{% endif %}
|
||||
{% if comment.item != item %}<a href="{{ comment.item.url }}">{{ comment.item.title }}</a>{% endif %}
|
||||
{% if comment.item != item %}<a href="{{ comment.item_url }}">{{ comment.item.title }}</a>{% endif %}
|
||||
<div>{{ comment.html|safe }}</div>
|
||||
</section>
|
||||
{% else %}
|
||||
|
|
|
@ -51,9 +51,7 @@
|
|||
<a href="{{ mark.owner.url }}" title="@{{ mark.owner.handler }}">{{ mark.owner.display_name }}</a>
|
||||
<span>{{ mark.action_label }}</span>
|
||||
{% if mark.rating_grade %}{{ mark.rating_grade|rating_star }}{% endif %}
|
||||
{% if mark.comment.focus_item %}
|
||||
<a href="{{ mark.comment.focus_item.url }}">{{ mark.comment.focus_item.title }}</a>
|
||||
{% endif %}
|
||||
{% if mark.comment.item != item %}<a href="{{ mark.comment.item_url }}">{{ mark.comment.item.title }}</a>{% endif %}
|
||||
</div>
|
||||
<div>{{ mark.comment.html|safe }}</div>
|
||||
</section>
|
||||
|
|
16
journal/migrations/0013_remove_comment_focus_item.py
Normal file
16
journal/migrations/0013_remove_comment_focus_item.py
Normal file
|
@ -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",
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
|
@ -63,9 +63,6 @@
|
|||
{% comment %} <a href="{{mark.owner.url }}" title="@{{ mark.owner.handler }}">{{ mark.owner.display_name }}</a> {% endcomment %}
|
||||
<span>{{ mark.action_label }}</span>
|
||||
{% if mark.rating_grade %}{{ mark.rating_grade|rating_star }}{% endif %}
|
||||
{% if mark.comment.focus_item %}
|
||||
<a href="{{ mark.comment.focus_item.url }}">{{ mark.comment.focus_item.title }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if mark.tags %}
|
||||
<div class="tag-list">
|
||||
|
|
27
social/migrations/0006_alter_localactivity_template.py
Normal file
27
social/migrations/0006_alter_localactivity_template.py
Normal file
|
@ -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,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -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
|
||||
|
|
|
@ -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 %}
|
||||
<span class="action">
|
||||
{% if activity.action_object.metadata.shared_link %}
|
||||
<span>
|
||||
<a href="{{ activity.action_object.metadata.shared_link }}"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
title="打开联邦宇宙分享链接"><i class="fa-solid fa-circle-nodes"></i></a>
|
||||
</span>
|
||||
{% endif %}
|
||||
<span>
|
||||
{% liked_piece activity.action_object as liked %}
|
||||
{% include 'like_stats.html' with liked=liked piece=activity.action_object %}
|
||||
</span>
|
||||
<span>
|
||||
<a><i class="fa-regular fa-comment"></i></a>
|
||||
</span>
|
||||
<span>
|
||||
<a class="episode"
|
||||
data-uuid="{{ activity.action_object.focus_item.uuid }}"
|
||||
data-media="{{ activity.action_object.focus_item.media_url }}"
|
||||
data-cover="{{ activity.action_object.focus_item.cover_url|default:activity.action_object.item.cover.url }}"
|
||||
data-title="{{ activity.action_object.focus_item.title }}"
|
||||
data-album="{{ activity.action_object.item.title }}"
|
||||
data-hosts="{{ activity.action_object.item.hosts|join:' / ' }}"
|
||||
data-position="{{ activity.action_object.metadata.position | default:0 }}"><i class="fa-solid fa-circle-play"></i></a>
|
||||
</span>
|
||||
<span>
|
||||
{% if not action.taken %}
|
||||
<a title="添加标记"
|
||||
hx-get="{% url 'journal:mark' activity.action_object.item.uuid %}?shelf_type=wishlist"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend">
|
||||
<i class="fa-regular fa-bookmark"></i>
|
||||
</a>
|
||||
{% else %}
|
||||
<a title="修改标记"
|
||||
hx-get="{% url 'journal:mark' activity.action_object.item.uuid %}"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend">
|
||||
<i class="fa-solid fa-bookmark"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</span>
|
||||
<div class="spacing">
|
||||
{{ activity.action_object.mark.action_label }}
|
||||
<a href="{{ activity.action_object.item_url }}">{{ activity.action_object.focus_item.title }}</a>
|
||||
{% if activity.action_object.metadata.position %}
|
||||
<span class="muted">{{ activity.action_object.metadata.position|duration_format:1 }}</span>
|
||||
{% endif %}
|
||||
{% if activity.action_object.mark.rating_grade %}
|
||||
{{ activity.action_object.mark.rating_grade | rating_star }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<article>
|
||||
{% include "_item_card.html" with item=activity.action_object.item allow_embed=1 %}
|
||||
{% if activity.action_object.mark.comment_text %}
|
||||
<footer>
|
||||
<p>{{ activity.action_object.mark.comment_html|safe }}</p>
|
||||
</footer>
|
||||
{% endif %}
|
||||
</article>
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue