website/conservancy/usethesource/templates/usethesource/candidate.html
Ben Sturmfels 28f3b8de08
usethesource: Allow logged in users to edit/delete their own comments only
Unless of course they're given the "change comment" and "delete comment"
permissions, with which they can change or delete any comment.
2024-03-21 11:51:57 +11:00

55 lines
2.5 KiB
HTML

{% extends "usethesource/base.html" %}
{% block title %}{{ candidate.name }} - Software Freedom Conservancy{% endblock %}
{% block head %}
{{ block.super }}
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
{% endblock %}
{% block content %}
{{ block.super }}
<section class="pa2 mt4 mb3">
<div style="display: flex; justify-content: space-between">
<div>
<div class="flex items-center">
<h2 class="f2 lh-title ttu mt0">{{ candidate.name }}</h2>
{% if perms.usethesource.change_candidate %}<a href="{% url 'admin:usethesource_candidate_change' object_id=candidate.id %}" title="Edit candidate" class="f3 white bg-light-silver db ph2 mh2 mb3" style="transform: scaleX(-1); text-decoration: none !important"></a>{% endif %}
</div>
<p><strong>Vendor</strong>: {{ candidate.vendor }}</p>
<p><strong>Device</strong>: {{ candidate.device }}</p>
<p><strong>Released</strong>: {{ candidate.release_date }}</p>
</div>
<div class="mt2">
{% if candidate.show_download_disclaimer %}
<div><a href="{% url 'usethesource:download' slug=candidate.slug download_type='source' %}" class="white bg-green db pv2 ph3 mb2">Download source</a></div>
<div><a href="{% url 'usethesource:download' slug=candidate.slug download_type='binary' %}" class="white bg-green db pv2 ph3">Download image</a></div>
{% else %}
<form method="post" action="{% url 'usethesource:download' slug=candidate.slug download_type='source' %}">
{% csrf_token %}
<button type="submit" class="white b bg-green db w-100 pv2 ph3 bn mb2">Download source</button>
</form>
<form method="post" action="{% url 'usethesource:download' slug=candidate.slug download_type='binary' %}">
{% csrf_token %}
<button type="submit" class="white b bg-green db w-100 pv2 ph3 bn mb2">Download image</button>
</form>
{% endif %}
</div>
</div>
{{ candidate.description|urlize|linebreaksbr }}
{% with comments=candidate.comment_set.all %}
{% if comments or user.is_staff %}<h3 class="f3 lh-title mt4">Comments</h3>{% endif %}
{% for comment in comments %}
{% include "usethesource/comment_partial.html" %}
{% endfor %}
{% endwith %}
{% if user.is_staff or user.is_superuser %}
{% include "usethesource/add_comment_button_partial.html" %}
{% endif %}
</section>
{% endblock content %}