refactor: Remove secr roles (#5257)

* refactor: remove import_audio_files() and related code

* refactor: move functions from proc_utils to meeting/utils

* refactor: remove secr/proceedings

* refactor: remove secr/roles

---------

Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
This commit is contained in:
Ryan Cross 2023-03-10 13:35:14 -08:00 committed by GitHub
parent b654b49d6b
commit f884e07387
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 0 additions and 298 deletions

View file

@ -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')

View file

@ -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<id>\d{1,6})/$' % settings.URL_REGEXPS, views.delete_role),
]

View file

@ -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},
)

View file

@ -23,7 +23,6 @@
<li> <a href="{% url "ietf.secr.areas.views.list_areas" %}"><b>Areas</b></a></li>
<li> <a href="{% url 'ietf.secr.groups.views.search' %}"><b>Groups</b></a></li>
<li> <a href="{% url 'ietf.secr.rolodex.views.search' %}"><b>Rolodex</b></a></li>
<li> <a href="{% url 'ietf.secr.roles.views.main' %}"><b>Roles</b></a></li>
</ul>
</td>
</tr>

View file

@ -1,84 +0,0 @@
{% extends "base_site.html" %}
{% load staticfiles %}
{% block title %}Roles{% endblock %}
{% block extrahead %}{{ block.super }}
<link rel="stylesheet" href="{% static 'ietf/css/jquery-ui.css' %}">
<script src="{% static 'ietf/js/jquery-ui.js' %}"></script>
<script src="{% static 'secr/js/utils.js' %}"></script>
<script>
$(document).ready(function() {
$.ajaxSetup ({
cache: false
});
$('#id_group').change(function(){
var loadUrl = "/secr/roles/ajax/get-roles/" + $(this).val() + "/";
var ajax_load = '<img class="loading" src="{% static "secr/images/ajax-loader.webp" %}" alt="loading...">';
var text = $(this).val();
$("#id_group_acronym").val(text);
$("#roles-list").html(ajax_load).load(loadUrl);
});
var sel = $('#id_group').val();
if (sel != '') { $('#id_group').change(); }
});
</script>
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
&raquo; Roles
{% endblock %}
{% block instructions %}
<a href="#" target="_blank">Instructions</a>
{% endblock %}
{% block content %}
<div class="module interim-container">
<form id="roles-form" method="post">{% csrf_token %}
<h2>Role Tool</h2>
<div class="inline-related">
<h3><b>Select Group</b></h3>
<p>Select a Group to change roles.</p>
{{ group_form.as_p }}
</div> <!-- inline-related -->
<br>
<div class="inline-related">
<h3>Role Details</h3>
<div id="roles-list"></div>
</div> <!-- inline-related -->
<div class="inline-related">
<h3>Add Role</h3>
{% with role_form as form %}
{{ role_form.non_field_errors }}
<table class="full-width">
<tbody>
<tr>
<td>{{ form.group_acronym.errors }}{{ form.group_acronym }}</td>
<td>{{ form.name.errors }}{{ form.name }}</td>
<td>{{ form.person.errors }}{{ form.person }}{% if form.person.help_text %}<br>{{ form.person.help_text }}{% endif %}</td>
<td>{{ form.email.errors }}{{ form.email }}{% if form.email.help_text %}<br>{{ form.email.help_text }}{% endif %}</td>
<td><button type="submit" name="submit">Add</button></td>
</tr>
</tbody>
</table>
{% endwith %}
</div> <!-- inline-related -->
</form>
<div class="button-group">
<ul>
<li><button type="button" onclick="window.location='../'">Back</button></li>
</ul>
</div> <!-- button-group -->
</div> <!-- module -->
{% endblock %}

View file

@ -1,20 +0,0 @@
<table class="full-width">
<thead>
<tr>
<th scope="col">Role</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
{% for role in roles %}
<tr class="{% cycle 'row1' 'row2' %}">
<td>{{ role.name }}</td>
<td>{{ role.person }}</td>
<td>{{ role.email }}</td>
<td><a href="{% url 'ietf.secr.roles.views.delete_role' acronym=group.acronym id=role.id %}">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>

View file

@ -8,7 +8,6 @@ urlpatterns = [
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')),

View file

@ -478,8 +478,6 @@ INSTALLED_APPS = [
'ietf.secr.areas',
'ietf.secr.groups',
'ietf.secr.meetings',
'ietf.secr.proceedings',
'ietf.secr.roles',
'ietf.secr.rolodex',
'ietf.secr.sreq',
'ietf.secr.telechat',