mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-10-31 07:49:57 +01:00 
			
		
		
		
	Cards for all rights template
This commit is contained in:
		| @@ -1,74 +1,92 @@ | |||||||
| {% extends "base.html" %} | {% extends "base.html" %} | ||||||
|  | {% comment %} | ||||||
|  | SPDX-License-Identifier: GPL-3.0-or-later | ||||||
|  | {% endcomment %} | ||||||
| {% load i18n %} | {% load i18n %} | ||||||
| {% load render_table from django_tables2 %} | {% load render_table from django_tables2 %} | ||||||
|  | {% block contenttitle %}{% endblock %} | ||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
|     {% if user.is_authenticated %} | {% if user.is_authenticated %} | ||||||
|         <h2>{% trans "Users that have surnormal rights" %}</h2> | <div class="card bg-light mb-3"> | ||||||
|         {% render_table special_memberships_table %} |   <h3 class="card-header text-center"> | ||||||
|  |     {% trans "Users that have surnormal rights" %} | ||||||
|  |   </h3> | ||||||
|  |   {% render_table special_memberships_table %} | ||||||
|  | </div> | ||||||
|  | {% endif %} | ||||||
|  |  | ||||||
|         <hr> | <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"> | ||||||
|  |         <input id="owned_only" name="owned_only" type="checkbox" class="checkboxinput form-check-input"> | ||||||
|  |         {% trans "Filter with roles that I have in at least one club" %} | ||||||
|  |       </label> | ||||||
|  |     </div> | ||||||
|     {% endif %} |     {% 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 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 %} | ||||||
|  |         </a> | ||||||
|  |       </div> | ||||||
|  |  | ||||||
|     <h2>{% trans "Roles description" %}</h2> |       <div id="collapse{{ role|slugify }}" class="collapse" aria-labelledby="{{ role|slugify }}" | ||||||
|     {% if user.is_authenticated %} |         data-parent="#accordionRoles"> | ||||||
|         <div class="form-check"> |         <div class="card-body"> | ||||||
|             <label for="owned_only" class="form-check-label"> |           {% if role.clubs %} | ||||||
|                 <input id="owned_only" name="owned_only" type="checkbox" class="checkboxinput form-check-input"> |           <div class="alert alert-success"> | ||||||
|                 {% trans "Filter with roles that I have in at least one club" %} |             {% trans "Own this role in the clubs" %} {{ role.clubs|join:", " }} | ||||||
|             </label> |           </div> | ||||||
|  |           {% endif %} | ||||||
|  |           <ul> | ||||||
|  |             {% for permission in role.permissions.all %} | ||||||
|  |             <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 %} | ||||||
|  |           </ul> | ||||||
|         </div> |         </div> | ||||||
|         {% endif %} |       </div> | ||||||
|         <div class="accordion" id="accordionRoles"> |     </div> | ||||||
|         {% regroup active_memberships by roles as memberships_per_role %} |     {% endfor %} | ||||||
|         {% for role in roles %} |   </div> | ||||||
|             <div class="card {% if not role.clubs %}no-club{% endif %}"> | </div> | ||||||
|               <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 %} |  | ||||||
|                     {% if role.clubs %} |  | ||||||
|                       <small><span class="badge badge-success">{% trans "Owned" %} : {{ role.clubs|join:", " }}</span></small> |  | ||||||
|                     {% endif %} |  | ||||||
|                   </button> |  | ||||||
|                 </h2> |  | ||||||
|               </div> |  | ||||||
|  |  | ||||||
|               <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"> |  | ||||||
|                           {% trans "Own this role in the clubs" %} {{ role.clubs|join:", " }} |  | ||||||
|                       </div> |  | ||||||
|                   {% 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> |  | ||||||
|                   {% empty %} |  | ||||||
|                       <em>{% trans "No associated permission" %}</em> |  | ||||||
|                   {% endfor %} |  | ||||||
|                   </ul> |  | ||||||
|                 </div> |  | ||||||
|               </div> |  | ||||||
|             </div> |  | ||||||
|         {% endfor %} |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
| {% block extrajavascript %} | {% block extrajavascript %} | ||||||
|     <script> | <script> | ||||||
|     $(document).ready(function() { |   $(document).ready(function () { | ||||||
|        let checkbox = $("#owned_only"); |     let checkbox = $("#owned_only"); | ||||||
|  |  | ||||||
|        function update() { |     function update() { | ||||||
|            if (checkbox.is(":checked")) |       if (checkbox.is(":checked")) | ||||||
|                $(".no-club").addClass('d-none'); |         $(".no-club").addClass('d-none'); | ||||||
|            else |       else | ||||||
|                $(".no-club").removeClass('d-none'); |         $(".no-club").removeClass('d-none'); | ||||||
|        } |     } | ||||||
|  |  | ||||||
|        checkbox.change(update); |     checkbox.change(update); | ||||||
|        update(); |     update(); | ||||||
|     }); |   }); | ||||||
|     </script> | </script> | ||||||
| {% endblock %} | {% endblock %} | ||||||
		Reference in New Issue
	
	Block a user