mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 01:48:21 +02:00
Don't display the alias create form if the user can't create anyone
This commit is contained in:
@ -9,15 +9,18 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<h3 class="card-header text-center">
|
||||
{% trans "Note aliases" %}
|
||||
</h3>
|
||||
|
||||
<div class="card-body">
|
||||
<form class="input-group" method="POST" id="form_alias">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="note" value="{{ object.note.pk }}">
|
||||
<input type="text" name="name" class="form-control">
|
||||
<div class="input-group-append">
|
||||
<input type="submit" class="btn btn-success" value="{% trans "Add" %}">
|
||||
</div>
|
||||
</form>
|
||||
{% if can_create %}
|
||||
<form class="input-group" method="POST" id="form_alias">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="note" value="{{ object.note.pk }}">
|
||||
<input type="text" name="name" class="form-control">
|
||||
<div class="input-group-append">
|
||||
<input type="submit" class="btn btn-success" value="{% trans "Add" %}">
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% render_table aliases %}
|
||||
</div>
|
||||
|
@ -10,14 +10,16 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% trans "Note aliases" %}
|
||||
</h3>
|
||||
<div class="card-body">
|
||||
<form class="input-group" method="POST" id="form_alias">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="note" value="{{ object.note.pk }}">
|
||||
<input type="text" name="name" class="form-control">
|
||||
<div class="input-group-append">
|
||||
<input type="submit" class="btn btn-success" value="{% trans "Add" %}">
|
||||
</div>
|
||||
</form>
|
||||
{% if can_create %}
|
||||
<form class="input-group" method="POST" id="form_alias">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="note" value="{{ object.note.pk }}">
|
||||
<input type="text" name="name" class="form-control">
|
||||
<div class="input-group-append">
|
||||
<input type="submit" class="btn btn-success" value="{% trans "Add" %}">
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% render_table aliases %}
|
||||
</div>
|
||||
|
@ -218,7 +218,13 @@ class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
note = context['object'].note
|
||||
context["aliases"] = AliasTable(note.alias_set.all())
|
||||
context["aliases"] = AliasTable(note.alias_set.filter(PermissionBackend
|
||||
.filter_queryset(self.request.user, Alias, "view")).all())
|
||||
context["can_create"] = PermissionBackend.check_perm(self.request.user, "note.add_alias", Alias(
|
||||
note=context["object"].note,
|
||||
name="",
|
||||
normalized_name="",
|
||||
))
|
||||
return context
|
||||
|
||||
|
||||
@ -422,7 +428,13 @@ class ClubAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
note = context['object'].note
|
||||
context["aliases"] = AliasTable(note.alias_set.all())
|
||||
context["aliases"] = AliasTable(note.alias_set.filter(PermissionBackend
|
||||
.filter_queryset(self.request.user, Alias, "view")).all())
|
||||
context["can_create"] = PermissionBackend.check_perm(self.request.user, "note.add_alias", Alias(
|
||||
note=context["object"].note,
|
||||
name="",
|
||||
normalized_name="",
|
||||
))
|
||||
return context
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user