Cards for all rights template

This commit is contained in:
Alexandre Iooss 2020-08-22 10:01:22 +02:00
parent 8063354e0f
commit 891955cedf
1 changed files with 78 additions and 60 deletions

View File

@ -1,17 +1,26 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% load render_table from django_tables2 %}
{% block contenttitle %}{% endblock %}
{% block content %}
{% if user.is_authenticated %}
<h2>{% trans "Users that have surnormal rights" %}</h2>
{% if user.is_authenticated %}
<div class="card bg-light mb-3">
<h3 class="card-header text-center">
{% trans "Users that have surnormal rights" %}
</h3>
{% render_table special_memberships_table %}
</div>
{% endif %}
<hr>
{% endif %}
<h2>{% trans "Roles description" %}</h2>
<div class="card bg-light">
<h3 class="card-header text-center">
{% trans "Roles description" %}
</h3>
<div class="card-body">
{% if user.is_authenticated %}
<div class="form-check">
<label for="owned_only" class="form-check-label">
@ -20,22 +29,25 @@
</label>
</div>
{% endif %}
</div>
<div class="accordion" id="accordionRoles">
{% regroup active_memberships by roles as memberships_per_role %}
{% for role in roles %}
<div class="card {% if not role.clubs %}no-club{% endif %}">
<div class="card-header" id="{{ role|slugify }} ">
<h2 class="mb-0">
<button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse{{ role|slugify }}" aria-expanded="true" aria-controls="collapse{{ role|slugify }}">
{{ role }} {% if role.weirole %}(<em>Pour le WEI</em>){% endif %} {% if role.for_club %}(<em>Pour le club {{ role.for_club }} uniquement</em>){% endif %}
<div class="card-header py-1" id="{{ role|slugify }} ">
<a href="#" class="text-decoration-none" data-toggle="collapse" data-target="#collapse{{ role|slugify }}"
aria-expanded="true" aria-controls="collapse{{ role|slugify }}">
{{ role }}
{% if role.weirole %}(<em>Pour le WEI</em>){% endif %}
{% if role.for_club %}(<em>Pour le club {{ role.for_club }} uniquement</em>){% endif %}
{% if role.clubs %}
<small><span class="badge badge-success">{% trans "Owned" %} : {{ role.clubs|join:", " }}</span></small>
{% endif %}
</button>
</h2>
</a>
</div>
<div id="collapse{{ role|slugify }}" class="collapse" aria-labelledby="{{ role|slugify }}" data-parent="#accordionRoles">
<div id="collapse{{ role|slugify }}" class="collapse" aria-labelledby="{{ role|slugify }}"
data-parent="#accordionRoles">
<div class="card-body">
{% if role.clubs %}
<div class="alert alert-success">
@ -44,7 +56,11 @@
{% endif %}
<ul>
{% for permission in role.permissions.all %}
<li data-toggle="tooltip" title="{% trans "Mask:" %} {{ permission.mask }}, {% trans "Query:" %} {{ permission.query }}">{{ permission }} ({{ permission.get_type_display }} {{ permission.model }}{% if permission.permanent %}, {% trans "permanent" %}{% endif %})</li>
<li data-toggle="tooltip"
title="{% trans "Mask:" %} {{ permission.mask }}, {% trans "Query:" %} {{ permission.query }}">
<b>{{ permission }}</b> ({{ permission.get_type_display }}
{{ permission.model }}{% if permission.permanent %},
{% trans "permanent" %}{% endif %})</li>
{% empty %}
<em>{% trans "No associated permission" %}</em>
{% endfor %}
@ -53,11 +69,13 @@
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
{% block extrajavascript %}
<script>
$(document).ready(function() {
<script>
$(document).ready(function () {
let checkbox = $("#owned_only");
function update() {
@ -70,5 +88,5 @@
checkbox.change(update);
update();
});
</script>
</script>
{% endblock %}