diff --git a/ietf/secr/roles/__init__.py b/ietf/secr/roles/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ietf/secr/roles/tests.py b/ietf/secr/roles/tests.py deleted file mode 100644 index 8c14ec239d..0000000000 --- a/ietf/secr/roles/tests.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright The IETF Trust 2013-2020, All Rights Reserved -# -*- coding: utf-8 -*- - - -from django.urls import reverse -from ietf.utils.test_utils import TestCase - -from ietf.group.factories import GroupFactory, RoleFactory -from ietf.person.models import Person - -import debug # pyflakes:ignore - -SECR_USER='secretary' - -class SecrRolesMainTestCase(TestCase): - - def setUp(self): - super().setUp() - GroupFactory(type_id='sdo') # need this for the RoleForm initialization - - def test_main(self): - "Main Test" - url = reverse('ietf.secr.roles.views.main') - self.client.login(username="secretary", password="secretary+password") - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - - def test_roles_delete(self): - role = RoleFactory(name_id='chair',group__acronym='mars') - group = role.group - id = role.id - url = reverse('ietf.secr.roles.views.delete_role', kwargs={'acronym':group.acronym,'id':role.id}) - target = reverse('ietf.secr.roles.views.main') - self.client.login(username="secretary", password="secretary+password") - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - response = self.client.post(url, {'post':'yes'}) - self.assertRedirects(response, target) - self.assertFalse(group.role_set.filter(id=id)) - - def test_roles_add(self): - person = Person.objects.get(name='AreaĆ° Irector') - group = GroupFactory() - url = reverse('ietf.secr.roles.views.main') - target = reverse('ietf.secr.roles.views.main') + '?group=%s' % group.acronym - post_data = {'group_acronym':group.acronym, - 'name':'chair', - 'person':'Joe Smith - (%s)' % person.id, - 'email':person.email_set.all()[0].address, - 'submit':'Add'} - self.client.login(username="secretary", password="secretary+password") - response = self.client.post(url,post_data,follow=True) - self.assertRedirects(response, target) - self.assertContains(response, 'added successfully') - - def test_roles_add_no_group(self): - person = Person.objects.get(name='AreaĆ° Irector') - url = reverse('ietf.secr.roles.views.main') - post_data = {'group_acronym':'', - 'name':'chair', - 'person':'Joe Smith - (%s)' % person.id, - 'email':person.email_set.all()[0].address, - 'submit':'Add'} - self.client.login(username="secretary", password="secretary+password") - response = self.client.post(url,post_data,follow=True) - self.assertEqual(response.status_code, 200) - self.assertContains(response, 'You must select a group') diff --git a/ietf/secr/roles/urls.py b/ietf/secr/roles/urls.py deleted file mode 100644 index 34f0fd6464..0000000000 --- a/ietf/secr/roles/urls.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.conf import settings - -from ietf.secr.roles import views -from ietf.utils.urls import url - -urlpatterns = [ - url(r'^$', views.main), - url(r'^ajax/get-roles/%(acronym)s/$' % settings.URL_REGEXPS, views.ajax_get_roles), - url(r'^%(acronym)s/delete/(?P\d{1,6})/$' % settings.URL_REGEXPS, views.delete_role), -] diff --git a/ietf/secr/roles/views.py b/ietf/secr/roles/views.py deleted file mode 100644 index 1063b92715..0000000000 --- a/ietf/secr/roles/views.py +++ /dev/null @@ -1,113 +0,0 @@ -from django.contrib import messages -from django.urls import reverse -from django.http import HttpResponseRedirect -from django.shortcuts import render, get_object_or_404, redirect - -from ietf.group.models import Group, Role -from ietf.group.utils import save_group_in_history -from ietf.ietfauth.utils import role_required -from ietf.secr.groups.forms import RoleForm -from ietf.secr.sreq.forms import GroupSelectForm - - -# ------------------------------------------------- -# Helper Functions -# ------------------------------------------------- - -def build_choices(queryset): - ''' - This function takes a queryset (or list) of Groups and builds a list of tuples for use - as choices in a select widget. Using acronym for both value and label. - ''' - choices = [ (g.acronym,g.acronym) for g in queryset ] - return sorted(choices, key=lambda choices: choices[1]) - -# ------------------------------------------------- -# AJAX Functions -# ------------------------------------------------- -def ajax_get_roles(request, acronym): - ''' - Ajax function which takes a group acronym and returns the - roles for the group in the form of a table - ''' - group = get_object_or_404(Group, acronym=acronym) - - return render(request, 'roles/roles.html', { - 'group': group, - 'roles': group.role_set.all()}, - ) -# -------------------------------------------------- -# STANDARD VIEW FUNCTIONS -# -------------------------------------------------- -@role_required('Secretariat') -def delete_role(request, acronym, id): - """ - Handle deleting roles - - **Templates:** - - * none - - """ - role = get_object_or_404(Role, id=id) - group = get_object_or_404(Group, acronym=acronym) - - if request.method == 'POST' and request.POST['post'] == 'yes': - # save group - save_group_in_history(group) - - role.delete() - messages.success(request, 'The entry was deleted successfully') - return redirect('ietf.secr.roles.views.main') - - return render(request, 'confirm_delete.html', {'object': role}) - -@role_required('Secretariat') -def main(request): - ''' - Main view for generic Roles App - ''' - groups = Group.objects.filter(type__in=('sdo','ietf')).order_by('acronym') - choices=build_choices(groups) - choices.insert(0,('','------------')) - group_form = GroupSelectForm(choices=choices) - - # prime form with random sdo group so all roles are available - group = Group.objects.filter(type='sdo')[0] - - if request.method == 'POST': - role_form = RoleForm(request.POST,group=group) - if role_form.is_valid(): - name = role_form.cleaned_data['name'] - person = role_form.cleaned_data['person'] - email = role_form.cleaned_data['email'] - acronym = role_form.cleaned_data['group_acronym'] - - group = Group.objects.get(acronym=acronym) - - # save group - save_group_in_history(group) - - Role.objects.create(name=name, - person=person, - email=email, - group=group) - - if not email.origin or email.origin == person.user.username: - email.origin = "role: %s %s" % (group.acronym, name.slug) - email.save() - - messages.success(request, 'New %s added successfully!' % name) - url = reverse('ietf.secr.roles.views.main') + '?group=%s' % group.acronym - return HttpResponseRedirect(url) - - else: - role_form = RoleForm(initial={'name':'chair'},group=group) - # accept get argument to select group if we're returning after a change - if 'group' in request.GET: - group_form = GroupSelectForm(choices=choices,initial={'group':request.GET['group']}) - - return render(request, 'roles/main.html', { - 'group_form': group_form, - 'role_form': role_form}, - ) diff --git a/ietf/secr/templates/main.html b/ietf/secr/templates/main.html index c10721c665..64cd063b83 100644 --- a/ietf/secr/templates/main.html +++ b/ietf/secr/templates/main.html @@ -23,7 +23,6 @@

IDs and WGs Process

  • Areas
  • Groups
  • Rolodex
  • -
  • Roles
  • diff --git a/ietf/secr/templates/roles/main.html b/ietf/secr/templates/roles/main.html deleted file mode 100755 index 88be7cdccf..0000000000 --- a/ietf/secr/templates/roles/main.html +++ /dev/null @@ -1,84 +0,0 @@ -{% extends "base_site.html" %} -{% load staticfiles %} - -{% block title %}Roles{% endblock %} - -{% block extrahead %}{{ block.super }} - - - - - -{% endblock %} - -{% block breadcrumbs %}{{ block.super }} - » Roles -{% endblock %} -{% block instructions %} - Instructions -{% endblock %} - -{% block content %} - -
    -
    {% csrf_token %} -

    Role Tool

    - -
    - - - - -
    - -
    -
      -
    • -
    -
    - -
    - -{% endblock %} \ No newline at end of file diff --git a/ietf/secr/templates/roles/roles.html b/ietf/secr/templates/roles/roles.html deleted file mode 100644 index 615452a486..0000000000 --- a/ietf/secr/templates/roles/roles.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - {% for role in roles %} - - - - - - - {% endfor %} - -
    RoleNameEmailAction
    {{ role.name }}{{ role.person }}{{ role.email }}Delete
    diff --git a/ietf/secr/urls.py b/ietf/secr/urls.py index a0f8bfcbf5..21c575cf62 100644 --- a/ietf/secr/urls.py +++ b/ietf/secr/urls.py @@ -8,7 +8,6 @@ url(r'^console/', include('ietf.secr.console.urls')), url(r'^groups/', include('ietf.secr.groups.urls')), url(r'^meetings/', include('ietf.secr.meetings.urls')), - url(r'^roles/', include('ietf.secr.roles.urls')), url(r'^rolodex/', include('ietf.secr.rolodex.urls')), url(r'^sreq/', include('ietf.secr.sreq.urls')), url(r'^telechat/', include('ietf.secr.telechat.urls')), diff --git a/ietf/settings.py b/ietf/settings.py index 261e17a417..a91eb8bc1c 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -478,8 +478,6 @@ def skip_unreadable_post(record): 'ietf.secr.areas', 'ietf.secr.groups', 'ietf.secr.meetings', - 'ietf.secr.proceedings', - 'ietf.secr.roles', 'ietf.secr.rolodex', 'ietf.secr.sreq', 'ietf.secr.telechat',