feat: Don't display edit buttons when no permission
This commit is contained in:
parent
8c51597c29
commit
87188dbd4f
@ -5,10 +5,12 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="detail-adoption-notice-header">
|
<div class="detail-adoption-notice-header">
|
||||||
<h1 class="detail-adoption-notice-header">{{ adoption_notice.name }}</h1>
|
<h1 class="detail-adoption-notice-header">{{ adoption_notice.name }}</h1>
|
||||||
<a class="btn2"
|
{% if has_edit_permission %}
|
||||||
href="{% url 'adoption-notice-add-photo' adoption_notice_id=adoption_notice.pk %}">{% translate 'Foto hinzufügen' %}</a>
|
<a class="btn2"
|
||||||
<a class="btn2 detail-adoption-notice-header"
|
href="{% url 'adoption-notice-add-photo' adoption_notice_id=adoption_notice.pk %}">{% translate 'Foto hinzufügen' %}</a>
|
||||||
href="{% url 'adoption-notice-edit' adoption_notice_id=adoption_notice.pk %}">{% translate 'Bearbeiten' %}</a>
|
<a class="btn2 detail-adoption-notice-header"
|
||||||
|
href="{% url 'adoption-notice-edit' adoption_notice_id=adoption_notice.pk %}">{% translate 'Bearbeiten' %}</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="table-adoption-notice-info">
|
<div class="table-adoption-notice-info">
|
||||||
<table>
|
<table>
|
||||||
|
@ -67,6 +67,7 @@ def change_language(request):
|
|||||||
|
|
||||||
def adoption_notice_detail(request, adoption_notice_id):
|
def adoption_notice_detail(request, adoption_notice_id):
|
||||||
adoption_notice = AdoptionNotice.objects.get(id=adoption_notice_id)
|
adoption_notice = AdoptionNotice.objects.get(id=adoption_notice_id)
|
||||||
|
has_edit_permission = user_is_owner_or_trust_level(request.user, adoption_notice)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
comment_form = CommentForm(request.POST)
|
comment_form = CommentForm(request.POST)
|
||||||
@ -95,7 +96,7 @@ def adoption_notice_detail(request, adoption_notice_id):
|
|||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
else:
|
else:
|
||||||
comment_form = CommentForm(instance=adoption_notice)
|
comment_form = CommentForm(instance=adoption_notice)
|
||||||
context = {"adoption_notice": adoption_notice, "comment_form": comment_form, "user": request.user}
|
context = {"adoption_notice": adoption_notice, "comment_form": comment_form, "user": request.user, "has_edit_permission": has_edit_permission}
|
||||||
return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context)
|
return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user