show reply and review to anonymous users

This commit is contained in:
Your Name 2023-12-29 01:34:17 -05:00 committed by Henri Dickson
parent 047cbe5462
commit 391d82a418
7 changed files with 43 additions and 59 deletions

View file

@ -11,15 +11,11 @@
{% if forloop.counter <= 10 %}
<section>
<span class="action">
<span>
{% liked_piece review as liked %}
{% include 'like_stats.html' with liked=liked piece=review %}
</span>
<span>
<a target="_blank"
rel="noopener"
{% if review.shared_link %} href="{{ review.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}><i class="fa-solid {% if review.visibility > 0 %} fa-lock {% else %} fa-globe {% endif %}"></i></a>
</span>
{% 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 %}
</span>
<span>
{% if review.rating_grade %}{{ review.rating_grade|rating_star }}{% endif %}
@ -29,8 +25,8 @@
</span>
<span class="action inline">
<span class="timestamp">{{ review.created_time|date }}</span>
<span class="timestamp">评论</span>
</span>
评论
{% if review.item != item %}<a href="{{ review.item.url }}">{{ review.item.title }}</a>{% endif %}
<div>
<span>

View file

@ -237,50 +237,34 @@
{% block content %}{% endblock %}
</section>
<section class="solo-hidden">
{% if request.user.is_authenticated %}
<div>
<h5>
短评
<small>
<div>
<h5>
短评
<small>
{% if request.user.is_authenticated %}
| <a href="{% url 'catalog:mark_list' item.url_path item.uuid %}">{% trans '全部标记' %}</a>
| <a href="{% url 'catalog:mark_list' item.url_path item.uuid 'following' %}">{% trans '关注的人的标记' %}</a>
</small>
</h5>
<div id="comments">
<div hx-swap="outerHTML"
hx-get="{% if request.GET.focus and item.class_name == "tvseason" %}{% url 'catalog:comments_by_episode' item.url_path item.uuid %}?episode_uuid={{ request.GET.focus }}{% else %}{% url 'catalog:comments' item.url_path item.uuid %}{% endif %}"
hx-trigger="intersect once">
<i class="fa-solid fa-compact-disc fa-spin loading"></i>
</div>
</div>
</div>
{% else %}
<h5>短评</h5>
<p class="empty">登录后可见</p>
{% endif %}
</section>
<section class="solo-hidden">
<h5>
{% trans '评论' %}
{% comment %}
{% if request.user.is_authenticated %}
<small>
| <a href="{% url 'catalog:review_list' item.url_path item.uuid %}">{% trans '全部评论' %}</a>
</small>
{% endif %}
{% endcomment %}
</h5>
{% if request.user.is_authenticated %}
<div>
<div hx-get="{% url 'catalog:reviews' item.url_path item.uuid %}"
hx-trigger="intersect once"
hx-swap="outerHTML">
{% endif %}
</small>
</h5>
<div id="comments">
<div hx-swap="outerHTML"
hx-get="{% if request.GET.focus and item.class_name == "tvseason" %}{% url 'catalog:comments_by_episode' item.url_path item.uuid %}?episode_uuid={{ request.GET.focus }}{% else %}{% url 'catalog:comments' item.url_path item.uuid %}{% endif %}"
hx-trigger="intersect once">
<i class="fa-solid fa-compact-disc fa-spin loading"></i>
</div>
</div>
{% else %}
<p class="empty">登录后可见</p>
{% endif %}
</div>
</section>
<section class="solo-hidden">
<h5>{% trans '评论' %}</h5>
<div>
<div hx-get="{% url 'catalog:reviews' item.url_path item.uuid %}"
hx-trigger="intersect once"
hx-swap="outerHTML">
<i class="fa-solid fa-compact-disc fa-spin loading"></i>
</div>
</div>
</section>
</div>
<div id="item-more" class="middle">

View file

@ -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:

View file

@ -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)

View file

@ -1,13 +1,17 @@
{% load user_actions %}
<span hx-target="this" hx-swap="outerHTML">
<span hx-target="this"
hx-swap="outerHTML"
{% if not request.user.is_authenticated %}hx-disable{% endif %}>
{% liked_post post as liked %}
{% if liked %}
<a class="activated" hx-post="{% url 'journal:post_unlike' post.pk %}">
<a class="activated"
hx-post="{% url 'journal:post_unlike' post.pk %}"
title="已喜欢">
<i class="fa-solid fa-heart }}"></i>
<span>{{ post.stats.likes }}</span>
</a>
{% else %}
<a hx-post="{% url 'journal:post_like' post.pk %}">
<a hx-post="{% url 'journal:post_like' post.pk %}" title="喜欢">
<i class="fa-regular fa-heart }}"></i>
{% if post.stats.likes %}<span>{{ post.stats.likes }}</span>{% endif %}
</a>

View file

@ -2,7 +2,7 @@
<a target="_blank"
rel="noopener"
href="{{ post.object_uri }}"
class="disabled">
title="打开联邦宇宙分享链接">
{% if post.visibility == 1 %}
<i class="fa-solid fa-lock-open"></i>
{% elif post.visibility == 2 %}

View file

@ -1,8 +1,11 @@
<span>
<a hx-get="{% url 'journal:piece_replies' piece.uuid %}"
<a title="回应"
{% if href %} href="{{ href }}" {% else %} {% if not request.user.is_authenticated %}hx-disable{% endif %}
hx-get="{% url 'journal:piece_replies' piece.uuid %}"
hx-swap="outerHTML"
hx-trigger="click once"
hx-target="#replies_{{ post.pk }}">
hx-target="#replies_{{ post.pk }}"
{% endif %}>
<i class="fa-solid fa-reply"></i>
{% if post.stats.replies %}<span>{{ post.stats.replies }}</span>{% endif %}
</a>