Projet

Général

Profil

0002-manager-remove-some-unused-code-31222.patch

Valentin Deniaud, 14 mars 2019 11:52

Télécharger (4,66 ko)

Voir les différences:

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
src/authentic2/manager/role_views.py
190 190
members = RoleMembersView.as_view()
191 191

  
192 192

  
193
class RoleChildrenView(views.HideOUColumnMixin, RoleViewMixin, views.BaseSubTableView):
194
    template_name = 'authentic2/manager/role_children.html'
195
    table_class = tables.RoleChildrenTable
196
    form_class = forms.ChooseRoleForm
197
    search_form_class = forms.RoleSearchForm
198
    success_url = '.'
199
    permissions = ['a2_rbac.view_role']
200

  
201
    def get_table_queryset(self):
202
        return self.object.children(include_self=False, annotate=True)
203

  
204
    def form_valid(self, form):
205
        RoleParenting = get_role_parenting_model()
206
        role = form.cleaned_data['role']
207
        action = form.cleaned_data['action']
208
        if self.can_change:
209
            if action == 'add':
210
                if RoleParenting.objects.filter(parent=self.object, child=role,
211
                                                direct=True).exists():
212
                    messages.warning(self.request, _('Role "%s" is already a '
213
                                     'child of this role.') % role.name)
214
                else:
215
                    self.object.add_child(role)
216
                    hooks.call_hooks('event', name='manager-add-child-role',
217
                                     user=self.request.user, parent=self.object, child=role)
218
            elif action == 'remove':
219
                hooks.call_hooks('event', name='manager-remove-child-role',
220
                                 user=self.request.user, parent=self.object, child=role)
221
                self.object.remove_child(role)
222
        else:
223
            messages.warning(self.request, _('You are not authorized'))
224
        return super(RoleChildrenView, self).form_valid(form)
225

  
226
children = RoleChildrenView.as_view()
227

  
228

  
229 193
class RoleDeleteView(RoleViewMixin, views.BaseDeleteView):
230 194
    title = _('Delete role')
231 195
    template_name = 'authentic2/manager/role_delete.html'
src/authentic2/manager/templates/authentic2/manager/ous_table.html
1
{% extends "authentic2/manager/table.html" %}
2

  
3
{% load i18n %}
4

  
5
{% block table.head.last.column %}
6
  {% if perms.a2_rbac.delete_organizationalunit %}
7
    <th></th>
8
  {% endif %}
9
{% endblock %}
10
{% block table.tbody.last.column %}
11
  {% if perms.a2_rbac.delete_organizationalunit %}
12
    {% if row.record.default %}
13
    <td><a class="icon-remove-sign disabled" 
14
           title="{% trans "You cannot delete the default organizational unit, you must first set another default organiational unit." %}"></a></td>
15
    {% else %}
16
       <td><a class="icon-remove-sign" rel="popup" href="{% url "a2-manager-ou-delete" pk=row.record.pk %}"></a></td>
17
    {% endif %}
18
  {% endif %}
19
{% endblock %}
src/authentic2/manager/templates/authentic2/manager/role_children_table.html
1
{% extends "authentic2/manager/table.html" %}
2

  
3
{% load i18n %}
4

  
5
{% if perms.auth.change_group %}
6
  {% block table.head.last.column %}
7
    <th></th>
8
  {% endblock %}
9
  {% block table.tbody.last.column %}
10
    <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>
11
  {% endblock %}
12
{% endif %}
13
-