From 6ed93fb9087a723717edd1601cf4c2ffbb4fc46b Mon Sep 17 00:00:00 2001
From: Valentin Deniaud <vdeniaud@entrouvert.com>
Date: Thu, 14 Mar 2019 11:44:32 +0100
Subject: [PATCH 2/2] manager: remove some unused code (#31222)

---
 src/authentic2/manager/role_views.py          | 36 -------------------
 .../authentic2/manager/ous_table.html         | 19 ----------
 .../manager/role_children_table.html          | 12 -------
 3 files changed, 67 deletions(-)
 delete mode 100644 src/authentic2/manager/templates/authentic2/manager/ous_table.html
 delete mode 100644 src/authentic2/manager/templates/authentic2/manager/role_children_table.html

diff --git a/src/authentic2/manager/role_views.py b/src/authentic2/manager/role_views.py
index 44c9f8e8..30d65d39 100644
--- a/src/authentic2/manager/role_views.py
+++ b/src/authentic2/manager/role_views.py
@@ -190,42 +190,6 @@ class RoleMembersView(views.HideOUColumnMixin, RoleViewMixin, views.BaseSubTable
 members = RoleMembersView.as_view()
 
 
-class RoleChildrenView(views.HideOUColumnMixin, RoleViewMixin, views.BaseSubTableView):
-    template_name = 'authentic2/manager/role_children.html'
-    table_class = tables.RoleChildrenTable
-    form_class = forms.ChooseRoleForm
-    search_form_class = forms.RoleSearchForm
-    success_url = '.'
-    permissions = ['a2_rbac.view_role']
-
-    def get_table_queryset(self):
-        return self.object.children(include_self=False, annotate=True)
-
-    def form_valid(self, form):
-        RoleParenting = get_role_parenting_model()
-        role = form.cleaned_data['role']
-        action = form.cleaned_data['action']
-        if self.can_change:
-            if action == 'add':
-                if RoleParenting.objects.filter(parent=self.object, child=role,
-                                                direct=True).exists():
-                    messages.warning(self.request, _('Role "%s" is already a '
-                                     'child of this role.') % role.name)
-                else:
-                    self.object.add_child(role)
-                    hooks.call_hooks('event', name='manager-add-child-role',
-                                     user=self.request.user, parent=self.object, child=role)
-            elif action == 'remove':
-                hooks.call_hooks('event', name='manager-remove-child-role',
-                                 user=self.request.user, parent=self.object, child=role)
-                self.object.remove_child(role)
-        else:
-            messages.warning(self.request, _('You are not authorized'))
-        return super(RoleChildrenView, self).form_valid(form)
-
-children = RoleChildrenView.as_view()
-
-
 class RoleDeleteView(RoleViewMixin, views.BaseDeleteView):
     title = _('Delete role')
     template_name = 'authentic2/manager/role_delete.html'
diff --git a/src/authentic2/manager/templates/authentic2/manager/ous_table.html b/src/authentic2/manager/templates/authentic2/manager/ous_table.html
deleted file mode 100644
index 040a5b11..00000000
--- a/src/authentic2/manager/templates/authentic2/manager/ous_table.html
+++ /dev/null
@@ -1,19 +0,0 @@
-{% extends "authentic2/manager/table.html" %}
-
-{% load i18n %}
-
-{% block table.head.last.column %}
-  {% if perms.a2_rbac.delete_organizationalunit %}
-    <th></th>
-  {% endif %}
-{% endblock %}
-{% block table.tbody.last.column %}
-  {% if perms.a2_rbac.delete_organizationalunit %}
-    {% if row.record.default %}
-    <td><a class="icon-remove-sign disabled" 
-           title="{% trans "You cannot delete the default organizational unit, you must first set another default organiational unit." %}"></a></td>
-    {% else %}
-       <td><a class="icon-remove-sign" rel="popup" href="{% url "a2-manager-ou-delete" pk=row.record.pk %}"></a></td>
-    {% endif %}
-  {% endif %}
-{% endblock %}
diff --git a/src/authentic2/manager/templates/authentic2/manager/role_children_table.html b/src/authentic2/manager/templates/authentic2/manager/role_children_table.html
deleted file mode 100644
index a3807659..00000000
--- a/src/authentic2/manager/templates/authentic2/manager/role_children_table.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{% extends "authentic2/manager/table.html" %}
-
-{% load i18n %}
-
-{% if perms.auth.change_group %}
-  {% block table.head.last.column %}
-    <th></th>
-  {% endblock %}
-  {% block table.tbody.last.column %}
-    <td>{% if view.can_change and row.record.is_direct %}<a class="icon-remove-sign js-remove-object" data-confirm="{% blocktrans with name=row.record.name role=active_role.name %}Do you really want to remove role &quot;{{ name }}&quot; from role &quot;{{ object }}&quot;&nbsp;?{% endblocktrans %}" href="#" data-pk-arg="role"></a>{% endif %}</td>
-  {% endblock %}
-{% endif %}
-- 
2.20.1

