feat(FastAPI): add /pkgbase/{name}/comments/{id}/pin (post)

In addition, fix up some templates to display pinned comments,
and include the unpin form input for pinned comments, which is
not yet implemented.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-01 15:47:16 -07:00
parent bb45ae7ac3
commit 0895dd07ee
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
5 changed files with 100 additions and 14 deletions

View file

@ -18,7 +18,5 @@
{% set pkgname = result.Name %}
{% set pkgbase_id = result.ID %}
{% if comments.count() %}
{% include "partials/packages/comments.html" %}
{% endif %}
{% include "partials/packages/comments.html" %}
{% endblock %}

View file

@ -49,16 +49,38 @@
<a href="/pkgbase/{{ pkgname }}/edit-comment/?comment_id={{ comment.ID }}" class="edit-comment" title="Edit comment"><img src="/images/pencil.min.svg" alt="Edit comment" width="11" height="11"></a>
{% endif %}
{% if request.user.has_credential("CRED_COMMENT_PIN", approved=[pkgbase.Maintainer]) %}
<form class="pin-comment-form" method="post" action="/pkgbase/{{ name }}/">
<fieldset style="display:inline;">
<input type="hidden" name="action" value="do_PinComment"/>
<input type="hidden" name="comment_id" value="{{ comment.ID }}"/>
<input type="hidden" name="package_base" value="{{ pkgbase.ID }}"/>
<input type="hidden" name="return_to" value="/pkgbase/{{ name }}/"/>
<input type="image" class="pin-comment" src="/images/pin.min.svg" width="11" height="11" alt="{{ 'Pin comment' | tr }}" title="{{ 'Pin comment' | tr }}" name="submit" value="1"/>
</fieldset>
</form>
{% if request.user.has_credential("CRED_COMMENT_PIN", approved=[pkgbase.Maintainer]) %}
{% if comment.PinnedTS %}
<form class="pin-comment-form"
method="post"
action="/pkgbase/{{ pkgbase.Name }}/comments/{{ comment.ID }}/unpin"
>
<fieldset style="display:inline;">
<input type="image"
class="pin-comment"
src="/images/unpin.min.svg"
alt="{{ 'Unpin comment' | tr }}"
title="{{ 'Unpin comment' | tr }}"
name="submit"
value="1" width="11" height="11" />
</fieldset>
</form>
{% else %}
<form class="pin-comment-form"
method="post"
action="/pkgbase/{{ pkgbase.Name }}/comments/{{ comment.ID }}/pin"
>
<fieldset style="display:inline;">
<input type="image"
class="pin-comment"
src="/images/pin.min.svg"
alt="{{ 'Pin comment' | tr }}"
title="{{ 'Pin comment' | tr }}"
name="submit"
value="1" width="11" height="11" />
</fieldset>
</form>
{% endif %}
{% endif %}
{% else %}
{% if request.user.has_credential("CRED_COMMENT_UNDELETE", approved=[comment.User]) %}

View file

@ -12,7 +12,21 @@
</div>
{% endif %}
{% if comments %}
{% if pinned_comments.count() %}
<div class="comments package-comments">
<div class="comments-header">
<h3>
<span class="text">{{ "Pinned Comments" | tr }}</span>
<span class="arrow"></span>
</h3>
</div>
{% for comment in pinned_comments.all() %}
{% include "partials/packages/comment.html" %}
{% endfor %}
</div>
{% endif %}
{% if comments.count() %}
<div class="comments package-comments">
<div class="comments-header">
<h3>