fix template action link issue
This commit is contained in:
parent
ba865ef84a
commit
c0b9c0e09e
5 changed files with 113 additions and 105 deletions
|
@ -19,9 +19,11 @@ def wish_item_action(context, item):
|
|||
@register.simple_tag(takes_context=True)
|
||||
def like_piece_action(context, piece):
|
||||
user = context["request"].user
|
||||
action = {}
|
||||
if user and user.is_authenticated:
|
||||
action = {
|
||||
"taken": Like.objects.filter(target=piece, owner=user).first() is not None,
|
||||
"taken": piece.owner == user
|
||||
or Like.objects.filter(target=piece, owner=user).first() is not None,
|
||||
"url": reverse("journal:like", args=[piece.uuid]),
|
||||
}
|
||||
return action
|
||||
return action
|
||||
|
|
|
@ -9,12 +9,13 @@
|
|||
{% load prettydate %}
|
||||
{% load user_actions %}
|
||||
|
||||
{% like_piece_action activity.action_object as action %}
|
||||
{% with activity.action_object.target as collection %}
|
||||
{% like_piece_action collection as action %}
|
||||
<div class="entity-list__entity-img-wrapper">
|
||||
<a href="{{ activity.action_object.url }}">
|
||||
<img src="{{ activity.action_object.cover|thumb:'normal' }}" alt="" class="entity-list__entity-img" style="min-width:80px;max-width:80px">
|
||||
<a href="{{ collection.url }}">
|
||||
<img src="{{ collection.cover|thumb:'normal' }}" alt="" class="entity-list__entity-img" style="min-width:80px;max-width:80px">
|
||||
</a>
|
||||
{% if not action.take %}
|
||||
{% if not action.taken %}
|
||||
<a class="entity-list__entity-action-icon" hx-post="{{ action.url }}">➕</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -24,20 +25,22 @@
|
|||
{% if activity.action_object.metadata.shared_link %}
|
||||
<a href="{{ activity.action_object.metadata.shared_link }}" action_object="_blank">
|
||||
<img src="{% static 'img/fediverse.svg' %}" style="filter: invert(93%) sepia(1%) saturate(53%) hue-rotate(314deg) brightness(95%) contrast(80%); vertical-align:text-top; max-width:14px; margin-right:6px;" />
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {% trans '设置了目标' %}
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.target.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.target.title }}
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span>
|
||||
</a>
|
||||
</div>
|
||||
<p>
|
||||
<progress value="{{ activity.action_object.progress }}" max="100"></progress>
|
||||
</p>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {% trans '设置了目标' %}
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ collection.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ collection.title }}
|
||||
</a>
|
||||
</div>
|
||||
<p>
|
||||
<progress value="{{ activity.action_object.progress }}" max="100"></progress>
|
||||
</p>
|
||||
</div>
|
||||
{% endwith %}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<a href="{{ activity.action_object.target.url }}">
|
||||
<img src="{{ activity.action_object.target.cover|thumb:'normal' }}" alt="" class="entity-list__entity-img" style="min-width:80px;max-width:80px">
|
||||
</a>
|
||||
{% if not action.take %}
|
||||
{% if not action.taken %}
|
||||
<a class="entity-list__entity-action-icon" hx-post="{{ action.url }}">➕</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -24,34 +24,35 @@
|
|||
{% if activity.action_object.metadata.shared_link %}
|
||||
<a href="{{ activity.action_object.metadata.shared_link }}" action_object="_blank">
|
||||
<img src="{% static 'img/fediverse.svg' %}" style="filter: invert(93%) sepia(1%) saturate(53%) hue-rotate(314deg) brightness(95%) contrast(80%); vertical-align:text-top; max-width:14px; margin-right:6px;" />
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> 关注了
|
||||
<a href="{% url 'journal:user_profile' activity.action_object.target.owner.mastodon_username %}">{{ activity.action_object.target.owner.display_name }}</a>
|
||||
的收藏单
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.target.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.target.title }}
|
||||
{% if activity.action_object.target.year %}<small style="font-weight: lighter">({{ activity.action_object.target.year }})</small>{% endif %}
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span>
|
||||
</a>
|
||||
</div>
|
||||
<p class="entity-list__entity-brief">
|
||||
{% if activity.review %}
|
||||
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
|
||||
{% endif %}
|
||||
{% if activity.mark %}
|
||||
{% if activity.mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.mark.rating | floatformat:"0" }}" style=""></span>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> 关注了
|
||||
<a href="{% url 'journal:user_profile' activity.action_object.target.owner.mastodon_username %}">{{ activity.action_object.target.owner.display_name }}</a>
|
||||
的收藏单
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.target.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.target.title }}
|
||||
{% if activity.action_object.target.year %}<small style="font-weight: lighter">({{ activity.action_object.target.year }})</small>{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
<p class="entity-list__entity-brief">
|
||||
{% if activity.review %}
|
||||
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
|
||||
{% endif %}
|
||||
{% if activity.mark %}
|
||||
{% if activity.mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.mark.rating | floatformat:"0" }}" style=""></span>
|
||||
{% endif %}
|
||||
|
||||
{% if activity.mark.text %}
|
||||
<p class="entity-marks__mark-content">{{ activity.mark.text }}</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% if activity.mark.text %}
|
||||
<p class="entity-marks__mark-content">{{ activity.mark.text }}</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<a href="{{ activity.action_object.item.url }}">
|
||||
<img src="{{ activity.action_object.item.cover|thumb:'normal' }}" alt="" class="entity-list__entity-img" style="min-width:80px;max-width:80px">
|
||||
</a>
|
||||
{% if not action.take %}
|
||||
{% if not action.taken %}
|
||||
<a class="entity-list__entity-action-icon" hx-post="{{ action.url }}">➕</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -25,34 +25,35 @@
|
|||
{% if activity.action_object.metadata.shared_link %}
|
||||
<a href="{{ activity.action_object.metadata.shared_link }}" action_object="_blank">
|
||||
<img src="{% static 'img/fediverse.svg' %}" style="filter: invert(93%) sepia(1%) saturate(53%) hue-rotate(314deg) brightness(95%) contrast(80%); vertical-align:text-top; max-width:14px; margin-right:6px;" />
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {{ activity.action_object.mark.action_label }}
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.item.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.item.title }}
|
||||
{% if activity.action_object.item.year %}<small style="font-weight: lighter">({{ activity.action_object.item.year }})</small>{% endif %}
|
||||
</a>
|
||||
{% for res in activity.action_object.item.external_resources.all %}
|
||||
<a href="{{ res.url }}">
|
||||
<span class="source-label source-label__{{ res.site_name }}">{{ res.site_name.label }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<p class="entity-list__entity-brief">
|
||||
{% if activity.action_object.review %}
|
||||
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
|
||||
{% endif %}
|
||||
{% if activity.action_object.mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.action_object.mark.rating }}" style=""></span>
|
||||
{% endif %}
|
||||
{% if activity.action_object.mark.text %}
|
||||
<p class="entity-marks__mark-content">{{ activity.action_object.mark.text }}</p>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {{ activity.action_object.mark.action_label }}
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.item.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.item.title }}
|
||||
{% if activity.action_object.item.year %}<small style="font-weight: lighter">({{ activity.action_object.item.year }})</small>{% endif %}
|
||||
</a>
|
||||
{% for res in activity.action_object.item.external_resources.all %}
|
||||
<a href="{{ res.url }}">
|
||||
<span class="source-label source-label__{{ res.site_name }}">{{ res.site_name.label }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<p class="entity-list__entity-brief">
|
||||
{% if activity.action_object.review %}
|
||||
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
|
||||
{% endif %}
|
||||
{% if activity.action_object.mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.action_object.mark.rating }}" style=""></span>
|
||||
{% endif %}
|
||||
{% if activity.action_object.mark.text %}
|
||||
<p class="entity-marks__mark-content">{{ activity.action_object.mark.text }}</p>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -25,30 +25,31 @@
|
|||
{% if activity.action_object.metadata.shared_link %}
|
||||
<a href="{{ activity.action_object.metadata.shared_link }}" action_object="_blank">
|
||||
<img src="{% static 'img/fediverse.svg' %}" style="filter: invert(93%) sepia(1%) saturate(53%) hue-rotate(314deg) brightness(95%) contrast(80%); vertical-align:text-top; max-width:14px; margin-right:6px;" />
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {% trans '评论了' %}
|
||||
<a href="{{ activity.action_object.item.url }}">{{ activity.action_object.item.title }}
|
||||
{% if activity.action_object.item.year %}<small style="font-weight: lighter">({{ activity.action_object.item.year }})</small>{% endif %}
|
||||
<span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a><span class="entity-marks__mark-time">{{ activity.action_object.created_time|prettydate }}</span></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.title }}</a>
|
||||
</div>
|
||||
<p class="entity-list__entity-brief">
|
||||
{% if activity.action_object.review %}
|
||||
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
|
||||
{% endif %}
|
||||
{% if activity.action_object.rating_grade %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.action_object.rating_grade }}" style=""></span>
|
||||
{% endif %}
|
||||
<p class="entity-marks__mark-content">
|
||||
<!-- body -->
|
||||
</p>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {% trans '评论了' %}
|
||||
<a href="{{ activity.action_object.item.url }}">{{ activity.action_object.item.title }}
|
||||
{% if activity.action_object.item.year %}<small style="font-weight: lighter">({{ activity.action_object.item.year }})</small>{% endif %}
|
||||
</a>
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.title }}</a>
|
||||
</div>
|
||||
<p class="entity-list__entity-brief">
|
||||
{% if activity.action_object.review %}
|
||||
<a href="{{ activity.review.url }}">{{ activity.review.title }}</a>
|
||||
{% endif %}
|
||||
{% if activity.action_object.rating_grade %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ activity.action_object.rating_grade }}" style=""></span>
|
||||
{% endif %}
|
||||
<p class="entity-marks__mark-content">
|
||||
<!-- body -->
|
||||
</p>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue