Permissions: If no sections, do not show list

This commit is contained in:
William Bouzourène 2025-01-21 16:25:22 +01:00
parent 2592577e55
commit 60476a260e
Signed by: bouzoure
SSH key fingerprint: SHA256:19MbXpLua4rUtk8tunMesD8KUKb91LXLHg8E/qTooww

View file

@ -25,51 +25,57 @@
</div> </div>
{% endif %} {% endif %}
<form id="user" method="post"> {% if Sections %}
<form id="user" method="post">
{% for Section in Sections %} {% for Section in Sections %}
<div class="row mb-3"> <div class="row mb-3">
<div class="col-md-2"> <div class="col-md-2">
{{ Section.Name }} {{ Section.Name }}
</div> </div>
<div class="col-md-10"> <div class="col-md-10">
<div class="input-group"> <div class="input-group">
<span class="input-group-text"> <span class="input-group-text">
<i class="bi-key"></i> <i class="bi-key"></i>
</span> </span>
<select <select
class="form-select" class="form-select"
name="section-{{ Section.ID }}" name="section-{{ Section.ID }}"
id="section-{{ Section.ID }}" id="section-{{ Section.ID }}"
autocomplete="off" autocomplete="off"
> >
<option value="0">--- Aucun ---</option> <option value="0">--- Aucun ---</option>
{% for Role in Roles %} {% for Role in Roles %}
<option <option
value="{{ Role.ID }}" value="{{ Role.ID }}"
{% for UserRole in UserRoles %} {% for UserRole in UserRoles %}
{% if Section.ID == UserRole.SectionID and Role.ID == UserRole.RoleID %} {% if Section.ID == UserRole.SectionID and Role.ID == UserRole.RoleID %}
selected selected
{% endif %} {% endif %}
{% endfor %} {% endfor %}
> >
{{ Role.Name }} {{ Role.Name }}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
</div>
</div> </div>
</div> </div>
</div> {% endfor %}
{% endfor %}
<div class="my-4">
<button class="btn btn-primary" type="submit">
<i class="me-1 bi-floppy"></i>
Enregistrer
</button>
</div>
</form>
{% else %}
<div class="my-4"> <div class="my-4">
<button class="btn btn-primary" type="submit"> Pas de section pour le moment
<i class="me-1 bi-floppy"></i>
Enregistrer
</button>
</div> </div>
</form> {% endif %}
</div> </div>
{% endblock %} {% endblock %}