From f9c1c80161dc5f2fdc3833b49ac7f6618ef9bfd3 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Wed, 7 Oct 2020 15:01:24 +0200
Subject: [PATCH 2/2] manager: add a generic template for user roles (#47408)

---
 .../authentic2/manager/user_common_roles.html | 22 +++++++++++++++++++
 .../authentic2/manager/user_ou_roles.html     | 22 ++-----------------
 .../authentic2/manager/user_roles.html        | 20 ++---------------
 3 files changed, 26 insertions(+), 38 deletions(-)
 create mode 100644 src/authentic2/manager/templates/authentic2/manager/user_common_roles.html

diff --git a/src/authentic2/manager/templates/authentic2/manager/user_common_roles.html b/src/authentic2/manager/templates/authentic2/manager/user_common_roles.html
new file mode 100644
index 00000000..dc0d7bd3
--- /dev/null
+++ b/src/authentic2/manager/templates/authentic2/manager/user_common_roles.html
@@ -0,0 +1,22 @@
+{% extends "authentic2/manager/base.html" %}
+{% load i18n %}
+
+{% block breadcrumb %}
+  {{ block.super }}
+  <a href="{% url 'a2-manager-users' %}">{% trans 'Users' %}</a>
+  {% if multiple_ou and object.ou %}
+  <a href="../?search-ou={{ object.ou.pk }}">{{ object.ou }}</a>
+  {% endif %}
+  <a href="{% url 'a2-manager-user-detail' pk=object.pk %}">{{ object.get_full_name }}</a>
+  <a href="#">{% trans "Roles" %}</a>
+{% endblock %}
+
+{% block page_title %}
+{% trans "Edit User Roles" %}
+{% endblock %}
+
+{% block sidebar %}
+  <aside id="sidebar">
+    {% include "authentic2/manager/search_form.html" %}
+  </aside>
+{% endblock %}
diff --git a/src/authentic2/manager/templates/authentic2/manager/user_ou_roles.html b/src/authentic2/manager/templates/authentic2/manager/user_ou_roles.html
index 580fef63..66634fdf 100644
--- a/src/authentic2/manager/templates/authentic2/manager/user_ou_roles.html
+++ b/src/authentic2/manager/templates/authentic2/manager/user_ou_roles.html
@@ -1,22 +1,10 @@
-{% extends "authentic2/manager/base.html" %}
-{% load i18n staticfiles django_tables2 %}
-
-{% block breadcrumb %}
-  {{ block.super }}
-  <a href="{% url 'a2-manager-users' %}">{% trans 'Users' %}</a>
-  <a href="../?search-ou={{ object.ou.pk }}">{{ object.ou }}</a>
-  <a href="{% url 'a2-manager-user-detail' pk=object.pk %}">{{ object.get_full_name }}</a>
-  <a href="#">{% trans "Roles" %}</a>
-{% endblock %}
-
-{% block page_title %}
-{% trans "Edit User Roles" %}
-{% endblock %}
+{% extends "authentic2/manager/user_common_roles.html" %}
+{% load django_tables2 %}
 
 {% block extrascripts %}
   {{ block.super }}
   <script>
   (function ($, window, undefined) {
     function fix_underterminate() {
       $('.indeterminate').each(function (i, elem) {
          elem.indeterminate = true;
@@ -46,19 +34,13 @@
 
         });
       });
     })
   })(jQuery, window, undefined);
   </script>
 {% endblock %}
 
-{% block sidebar %}
-  <aside id="sidebar">
-    {% include "authentic2/manager/search_form.html" %}
-  </aside>
-{% endblock %}
-
 {% block main %}
  {% with row_link=1 url_name="a2-manager-role-members" %}
    {% render_table table "authentic2/manager/table.html" %}
  {% endwith %}
 {% endblock %}
diff --git a/src/authentic2/manager/templates/authentic2/manager/user_roles.html b/src/authentic2/manager/templates/authentic2/manager/user_roles.html
index fa99f710..7afeddd3 100644
--- a/src/authentic2/manager/templates/authentic2/manager/user_roles.html
+++ b/src/authentic2/manager/templates/authentic2/manager/user_roles.html
@@ -1,38 +1,22 @@
-{% extends "authentic2/manager/base.html" %}
-{% load i18n staticfiles django_tables2 %}
+{% extends "authentic2/manager/user_common_roles.html" %}
+{% load i18n django_tables2 %}
 
-{% block breadcrumb %}
-  {{ block.super }}
-  <a href="{% url 'a2-manager-users' %}">{% trans 'Users' %}</a>
-  <a href="{% url 'a2-manager-user-detail' pk=object.pk %}">{{ object.get_full_name }}</a>
-  <a href="#">{% trans "Roles" %}</a>
-{% endblock %}
-
-{% block page_title %}
-{% trans "Edit User Roles" %}
-{% endblock %}
 {% block extrascripts %}
   {{ block.super }}
   <script>
   $(function () {
     $('.indeterminate').each(function (i, elem) {
        elem.indeterminate = true;
     })
   })
   </script>
 {% endblock %}
 
-{% block sidebar %}
-  <aside id="sidebar">
-    {% include "authentic2/manager/search_form.html" %}
-  </aside>
-{% endblock %}
-
 {% block main %}
  {% with row_link=1 url_name="a2-manager-role-members" %}
    {% render_table table "authentic2/manager/user_roles_table.html" %}
  {% endwith %}
 
  {% if view.can_change %}
    <form method="post" class="manager-m2m-add-form">
            {% csrf_token %}
-- 
2.28.0

