manager: order user's roles by OU (fixes #23843)
This commit is contained in:
parent
d16801c4b3
commit
07865e418e
|
@ -98,6 +98,16 @@ table.users tbody tr td:nth-child(2):hover {
|
|||
width: auto;
|
||||
}
|
||||
|
||||
.user-roles ul {
|
||||
margin-left: 2rem;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.user-roles ul ul {
|
||||
margin-left: 1rem;
|
||||
margin-bottom: 1ex;
|
||||
}
|
||||
|
||||
li#roles a { background-image: url(icon-personnes.png); }
|
||||
li#roles a:hover { background-image: url(icon-personnes-hover.png); }
|
||||
|
||||
|
|
|
@ -65,14 +65,23 @@
|
|||
|
||||
{{ block.super }}
|
||||
|
||||
{% if roles or can_change_roles %}
|
||||
{% if roles_by_ou or can_change_roles %}
|
||||
<div class="user-roles">
|
||||
<strong>{% trans "Roles" %}</strong>
|
||||
<ul>
|
||||
{% for role in object.roles_and_parents %}
|
||||
<li {% if role.description %}title="{{ role.description }}"{% endif %}>
|
||||
<a href="{% url "a2-manager-role-members" pk=role.pk %}">{% if multiple_ou and role.ou %}{{ role.ou }} — {% endif %}{{ role }}</a>
|
||||
</li>
|
||||
{% for ou, ou_roles in roles_by_ou.items %}
|
||||
{% if multiple_ou %}
|
||||
<li>{% if ou %}{{ ou }}{% else %}{% trans "All organizational units" %}{% endif %}
|
||||
<ul>
|
||||
{% endif %}
|
||||
{% for role in ou_roles %}
|
||||
<li {% if role.description %}title="{{ role.description }}"{% endif %}>
|
||||
<a href="{% url "a2-manager-role-members" pk=role.pk %}">{{ role }}</a></li>
|
||||
{% endfor %}
|
||||
{% if multiple_ou %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -257,7 +257,12 @@ class UserDetailView(OtherActionsMixin, BaseDetailView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs['default_ou'] = get_default_ou
|
||||
kwargs['roles'] = self.object.roles_and_parents()
|
||||
roles = self.object.roles_and_parents().order_by('ou__name', 'name')
|
||||
roles_by_ou = collections.OrderedDict()
|
||||
for role in roles:
|
||||
roles_by_ou.setdefault(role.ou.name if role.ou else '', []).append(role)
|
||||
kwargs['roles'] = roles
|
||||
kwargs['roles_by_ou'] = roles_by_ou
|
||||
# show modify roles button only if something is possible
|
||||
kwargs['can_change_roles'] = self.has_perm_on_roles(self.request.user, self.object)
|
||||
user_data = []
|
||||
|
|
Loading…
Reference in New Issue