From 391d82a418710f878121a2fa5f14595e6c318caf Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 29 Dec 2023 01:34:17 -0500 Subject: [PATCH] show reply and review to anonymous users --- catalog/templates/_item_reviews.html | 16 +++--- catalog/templates/item_base.html | 62 +++++++++-------------- catalog/views.py | 3 -- journal/models/common.py | 2 +- journal/templates/action_like_post.html | 10 ++-- journal/templates/action_open_post.html | 2 +- journal/templates/action_reply_piece.html | 7 ++- 7 files changed, 43 insertions(+), 59 deletions(-) diff --git a/catalog/templates/_item_reviews.html b/catalog/templates/_item_reviews.html index 5908c93d..d14bd0dc 100644 --- a/catalog/templates/_item_reviews.html +++ b/catalog/templates/_item_reviews.html @@ -11,15 +11,11 @@ {% if forloop.counter <= 10 %}
- - {% liked_piece review as liked %} - {% include 'like_stats.html' with liked=liked piece=review %} - - - - + {% if review.latest_post %} + {% include "action_reply_piece.html" with post=review.latest_post piece=review href=review.url %} + {% include "action_like_post.html" with post=review.latest_post %} + {% include "action_open_post.html" with post=review.latest_post %} + {% endif %} {% if review.rating_grade %}{{ review.rating_grade|rating_star }}{% endif %} @@ -29,8 +25,8 @@ {{ review.created_time|date }} + 评论 - 评论 {% if review.item != item %}{{ review.item.title }}{% endif %}
diff --git a/catalog/templates/item_base.html b/catalog/templates/item_base.html index 47556be4..441f6aa7 100644 --- a/catalog/templates/item_base.html +++ b/catalog/templates/item_base.html @@ -237,50 +237,34 @@ {% block content %}{% endblock %}
- {% if request.user.is_authenticated %} -
-
- 短评 - +
+
+ 短评 + + {% if request.user.is_authenticated %} | {% trans '全部标记' %} | {% trans '关注的人的标记' %} - -
-
-
- -
-
-
- {% else %} -
短评
-

登录后可见

- {% endif %} -
-
-
- {% trans '评论' %} - {% comment %} - {% if request.user.is_authenticated %} - - | {% trans '全部评论' %} - - {% endif %} - {% endcomment %} -
- {% if request.user.is_authenticated %} -
-
+ {% endif %} + + +
+
- {% else %} -

登录后可见

- {% endif %} +
+
+
+
{% trans '评论' %}
+
+
+ +
+
diff --git a/catalog/views.py b/catalog/views.py index f6d984bd..11ed0da2 100644 --- a/catalog/views.py +++ b/catalog/views.py @@ -191,7 +191,6 @@ def review_list(request, item_path, item_uuid): ) -@login_required def comments(request, item_path, item_uuid): item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid)) if not item: @@ -212,7 +211,6 @@ def comments(request, item_path, item_uuid): ) -@login_required def comments_by_episode(request, item_path, item_uuid): item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid)) if not item: @@ -239,7 +237,6 @@ def comments_by_episode(request, item_path, item_uuid): ) -@login_required def reviews(request, item_path, item_uuid): item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid)) if not item: diff --git a/journal/models/common.py b/journal/models/common.py index 7bfff65b..3d267563 100644 --- a/journal/models/common.py +++ b/journal/models/common.py @@ -64,7 +64,7 @@ def max_visiblity_to_user(viewing_user: User, owner: APIdentity): def q_piece_visible_to_user(user: User): if not user or not user.is_authenticated or not user.identity: - return Q(visibility=0) + return Q(visibility=0, owner__user__preference__no_anonymous_view=False) return ( Q(visibility=0) | Q(owner_id__in=user.identity.following, visibility=1) diff --git a/journal/templates/action_like_post.html b/journal/templates/action_like_post.html index 87cadb42..1e89f5f8 100644 --- a/journal/templates/action_like_post.html +++ b/journal/templates/action_like_post.html @@ -1,13 +1,17 @@ {% load user_actions %} - + {% liked_post post as liked %} {% if liked %} - + {{ post.stats.likes }} {% else %} - + {% if post.stats.likes %}{{ post.stats.likes }}{% endif %} diff --git a/journal/templates/action_open_post.html b/journal/templates/action_open_post.html index eb89aea8..0645b0bc 100644 --- a/journal/templates/action_open_post.html +++ b/journal/templates/action_open_post.html @@ -2,7 +2,7 @@ + title="打开联邦宇宙分享链接"> {% if post.visibility == 1 %} {% elif post.visibility == 2 %} diff --git a/journal/templates/action_reply_piece.html b/journal/templates/action_reply_piece.html index 3d3a22ea..00cb6c53 100644 --- a/journal/templates/action_reply_piece.html +++ b/journal/templates/action_reply_piece.html @@ -1,8 +1,11 @@ - + hx-target="#replies_{{ post.pk }}" + {% endif %}> {% if post.stats.replies %}{{ post.stats.replies }}{% endif %}