From 4b2ede1382e0632285a1203f8091da22e704c2ce Mon Sep 17 00:00:00 2001
From: Paul Marillonnet <pmarillonnet@entrouvert.com>
Date: Thu, 30 Sep 2021 16:20:08 +0200
Subject: [PATCH] manager: provide a human-friendly rbac inheritance
 terminology (#56638)

---
 .../authentic2/manager/role_members.html      | 44 +++++++++----------
 tests/test_role_manager.py                    | 12 ++---
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/authentic2/manager/templates/authentic2/manager/role_members.html b/src/authentic2/manager/templates/authentic2/manager/role_members.html
index b63c3009..f89e2f11 100644
--- a/src/authentic2/manager/templates/authentic2/manager/role_members.html
+++ b/src/authentic2/manager/templates/authentic2/manager/role_members.html
@@ -73,58 +73,58 @@
  {% endif %}
 
  <div class="section">
-   <h3>{% trans "Child roles" %}
-     {% if view.can_manage_members %}
-     <a href="{% url "a2-manager-role-children" pk=object.pk %}" class="button">{% trans "Edit" %}</a>
+   <h3>{% trans "Contains permissions of roles:" %}
+     {% if not object.is_internal %}
+     <a href="{% url "a2-manager-role-parents" pk=object.pk %}" class="button">{% trans "Edit" %}</a>
      {% else %}
-     <a title="{% trans "Permission denied" %}" class="button disabled">{% trans "Edit" %}</a>
+     <a title="{% trans "This role is technical, you cannot modify its permissions." %}" class="button disabled">{% trans "Edit" %}</a>
      {% endif %}
    </h3>
    <div>
-     {% if children %}
+     {% if parents %}
      <ul class="objects-list single-links">
-       {% for child in children|slice:":10" %}
+       {% for parent in parents|slice:":10" %}
        <li>
-         <a  class="role-inheritance-child" href="{% url "a2-manager-role-members" pk=child.pk %}">{% if child.ou and has_multiple_ou %}{{ child.ou }} - {% endif %}{{ child }}</a>
-         {% if not child.direct %}
+         <a class="role-inheritance-parent" href="{% url "a2-manager-role-members" pk=parent.pk %}">{% if parent.ou and has_multiple_ou %}{{ parent.ou }} - {% endif %}{{ parent }}</a>
+         {% if not parent.direct %}
          <span class="badge">{% trans "Indirect" %}</span>
          {% endif %}
        </li>
        {% endfor %}
-       {% if children|length > 10 %}
-       <li><a class="role-inheritance-view-all" href="{% url "a2-manager-role-children" pk=object.pk %}">({% trans "view all roles" %})</a></li>
+       {% if parents|length > 10 %}
+       <li><a class="role-inheritance-view-all" href="{% url "a2-manager-role-parents" pk=object.pk %}">({% trans "view all roles" %})</a></li>
        {% endif %}
      </ul>
      {% else %}
-     <p>{% trans "This role has no children." %}</p>
+     <p>{% trans "This role doesn't contain permissions of any other role." %}</p>
      {% endif %}
    </div>
  </div>
  <div class="section">
-   <h3>{% trans "Parent roles" %}
-     {% if not object.is_internal %}
-     <a href="{% url "a2-manager-role-parents" pk=object.pk %}" class="button">{% trans "Edit" %}</a>
+   <h3>{% trans "Grants its permissions to roles:" %}
+     {% if view.can_manage_members %}
+     <a href="{% url "a2-manager-role-children" pk=object.pk %}" class="button">{% trans "Edit" %}</a>
      {% else %}
-     <a title="{% trans "This role is technical, you cannot modify its permissions." %}" class="button disabled">{% trans "Edit" %}</a>
+     <a title="{% trans "Permission denied" %}" class="button disabled">{% trans "Edit" %}</a>
      {% endif %}
    </h3>
    <div>
-     {% if parents %}
+     {% if children %}
      <ul class="objects-list single-links">
-       {% for parent in parents|slice:":10" %}
+       {% for child in children|slice:":10" %}
        <li>
-         <a class="role-inheritance-parent" href="{% url "a2-manager-role-members" pk=parent.pk %}">{% if parent.ou and has_multiple_ou %}{{ parent.ou }} - {% endif %}{{ parent }}</a>
-         {% if not parent.direct %}
+         <a  class="role-inheritance-child" href="{% url "a2-manager-role-members" pk=child.pk %}">{% if child.ou and has_multiple_ou %}{{ child.ou }} - {% endif %}{{ child }}</a>
+         {% if not child.direct %}
          <span class="badge">{% trans "Indirect" %}</span>
          {% endif %}
        </li>
        {% endfor %}
-       {% if parents|length > 10 %}
-       <li><a class="role-inheritance-view-all" href="{% url "a2-manager-role-parents" pk=object.pk %}">({% trans "view all roles" %})</a></li>
+       {% if children|length > 10 %}
+       <li><a class="role-inheritance-view-all" href="{% url "a2-manager-role-children" pk=object.pk %}">({% trans "view all roles" %})</a></li>
        {% endif %}
      </ul>
      {% else %}
-     <p>{% trans "This role has no parents." %}</p>
+     <p>{% trans "This role doesn't grant its permissions to any other role." %}</p>
      {% endif %}
    </div>
  </div>
diff --git a/tests/test_role_manager.py b/tests/test_role_manager.py
index 770a79d2..8b1a8c2e 100644
--- a/tests/test_role_manager.py
+++ b/tests/test_role_manager.py
@@ -353,8 +353,8 @@ def test_role_members_display_inheritance_info(app, superuser, settings, simple_
     url = reverse('a2-manager-role-members', kwargs={'pk': simple_role.pk})
 
     resp = login(app, superuser, url)
-    assert 'This role has no children.' in resp.text
-    assert 'This role has no parents.' in resp.text
+    assert "This role doesn't grant its permissions to any other role." in resp.text
+    assert "This role doesn't contain permissions of any other role." in resp.text
 
     for i in range(10):
         role = Role.objects.create(name=f'Role {i}', ou=get_default_ou())
@@ -362,11 +362,11 @@ def test_role_members_display_inheritance_info(app, superuser, settings, simple_
 
     resp = app.get(url)
     if relation == 'child':
-        assert 'This role has no children.' not in resp.text
-        assert 'This role has no parents.' in resp.text
+        assert "This role doesn't grant its permissions to any other role." not in resp.text
+        assert "This role doesn't contain permissions of any other role." in resp.text
     elif relation == 'parent':
-        assert 'This role has no children.' in resp.text
-        assert 'This role has no parents.' not in resp.text
+        assert "This role doesn't grant its permissions to any other role." in resp.text
+        assert "This role doesn't contain permissions of any other role." not in resp.text
 
     for i, el in enumerate(resp.pyquery.find('a.role-inheritance-%s' % relation)):
         assert el.text == f'Role {i}'
-- 
2.33.0

