delete access permissions
This commit is contained in:
parent
e5f33079b7
commit
9454c82058
3 changed files with 32 additions and 0 deletions
|
@ -25,20 +25,29 @@
|
|||
|
||||
<h4>{% trans 'Access Permissions' %}</h4>
|
||||
{% if user.accesspermissions.all %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
<tr>
|
||||
<th>{% trans 'Access Restriction' %}</th>
|
||||
<th>{% trans 'expires' %}</th>
|
||||
<th>{% trans 'can grant' %}</th>
|
||||
{% if request.user_permissions.access_all %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% for access_permission in user.accesspermissions.all %}
|
||||
<tr>
|
||||
<td>{{ access_permission.access_restriction.title }}</td>
|
||||
<td>{{ access_permission.expire_date }}</td>
|
||||
<td>{% if access_permission.can_grant %}{% trans 'Yes' %}{% else %}{% trans 'No' %}{% endif %}</td>
|
||||
{% if request.user_permissions.access_all %}
|
||||
<td class="button-cell"><button type="submit" name="delete_access_permission" value="{{ access_permission.pk }}">{% trans 'Delete' %}</button></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</form>
|
||||
{% else %}
|
||||
<p><em>{% trans 'none' %}</em></p>
|
||||
{% endif %}
|
||||
|
|
|
@ -57,6 +57,18 @@ def user_detail(request, user):
|
|||
)
|
||||
user = get_object_or_404(qs, pk=user)
|
||||
|
||||
if request.method == 'POST':
|
||||
delete_access_permission = request.POST.get('delete_access_permission')
|
||||
if delete_access_permission:
|
||||
try:
|
||||
permission = AccessPermission.objects.get(pk=delete_access_permission)
|
||||
except AccessPermission.DoesNotExist:
|
||||
messages.error(request, _('Unknown access permission.'))
|
||||
else:
|
||||
permission.delete()
|
||||
messages.success(request, _('Access Permission successfully deleted.'))
|
||||
return redirect(request.path_info)
|
||||
|
||||
ctx = {
|
||||
'user': user,
|
||||
}
|
||||
|
|
|
@ -700,6 +700,17 @@ main.control h4, main.control h2 {
|
|||
main.control h4 {
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
main.control form tr > * {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.button-cell {
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
text-align: right;
|
||||
}
|
||||
.button-cell button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.user-permissions-form label {
|
||||
font-weight: 400;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue