refactor: remove unused secr/areas app (#6509)

* refactor: remove unused secr/areas app
This commit is contained in:
Ryan Cross 2023-10-23 07:55:54 -07:00 committed by GitHub
parent 16c876b24d
commit 4575864bfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1 additions and 456 deletions

View file

@ -1,49 +0,0 @@
from django import forms
from ietf.person.models import Person, Email
import re
STATE_CHOICES = (
(1, 'Active'),
(2, 'Concluded')
)
class AreaDirectorForm(forms.Form):
ad_name = forms.CharField(max_length=100,label='Name',help_text="To see a list of people type the first name, or last name, or both.")
#login = forms.EmailField(max_length=75,help_text="This should be the person's primary email address.")
#email = forms.ChoiceField(help_text="This should be the person's primary email address.")
email = forms.CharField(help_text="Select the email address to associate with this AD Role")
# set css class=name-autocomplete for name field (to provide select list)
def __init__(self, *args, **kwargs):
super(AreaDirectorForm, self).__init__(*args, **kwargs)
self.fields['ad_name'].widget.attrs['class'] = 'name-autocomplete'
self.fields['email'].widget = forms.Select(choices=[])
def clean_ad_name(self):
name = self.cleaned_data.get('ad_name', '')
# check for tag within parenthesis to ensure name was selected from the list
m = re.search(r'\((\d+)\)', name)
if not name or not m:
raise forms.ValidationError("You must select an entry from the list!")
try:
id = m.group(1)
person = Person.objects.get(id=id)
except Person.DoesNotExist:
raise forms.ValidationError("ERROR finding Person with ID: %s" % id)
return person
def clean_email(self):
# this ChoiceField gets populated by javascript so skip regular validation
# which raises an error
email = self.cleaned_data['email']
if not email:
raise forms.ValidationError("You must select an email. If none are listed you'll need to add one first.")
try:
obj = Email.objects.get(address=email)
except Email.DoesNotExist:
raise forms.ValidationError("Can't find this email.")
return obj

View file

@ -1,34 +0,0 @@
from django.urls import reverse
from ietf.group.factories import GroupFactory, GroupEventFactory
from ietf.group.models import Group, GroupEvent
from ietf.person.models import Person
from ietf.utils.test_utils import TestCase
SECR_USER='secretary'
def augment_data():
system = Person.objects.get(name="(System)")
area = Group.objects.get(acronym='farfut')
GroupEvent.objects.create(group=area,
type='started',
by=system)
class SecrAreasTestCase(TestCase):
def test_main(self):
"Main Test"
GroupFactory(type_id='area')
url = reverse('ietf.secr.areas.views.list_areas')
self.client.login(username="secretary", password="secretary+password")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
def test_view(self):
"View Test"
area = GroupEventFactory(type='started',group__type_id='area').group
url = reverse('ietf.secr.areas.views.view', kwargs={'name':area.acronym})
self.client.login(username="secretary", password="secretary+password")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

View file

@ -1,12 +0,0 @@
from ietf.secr.areas import views
from ietf.utils.urls import url
urlpatterns = [
url(r'^$', views.list_areas),
url(r'^getemails', views.getemails),
url(r'^getpeople', views.getpeople),
url(r'^(?P<name>[A-Za-z0-9.-]+)/$', views.view),
url(r'^(?P<name>[A-Za-z0-9.-]+)/people/$', views.people),
url(r'^(?P<name>[A-Za-z0-9.-]+)/people/modify/$', views.modify),
]

View file

@ -1,205 +0,0 @@
import json
from django.contrib import messages
from django.http import HttpResponse, HttpResponseBadRequest
from django.shortcuts import render, get_object_or_404, redirect
from ietf.group.models import Group, GroupEvent, Role
from ietf.group.utils import save_group_in_history
from ietf.ietfauth.utils import role_required
from ietf.person.models import Person
from ietf.secr.areas.forms import AreaDirectorForm
# --------------------------------------------------
# AJAX FUNCTIONS
# --------------------------------------------------
def getpeople(request):
"""
Ajax function to find people. Takes one or two terms (ignores rest) and
returns JSON format response: first name, last name, primary email, tag
"""
result = []
term = request.GET.get('term','')
qs = Person.objects.filter(name__icontains=term)
for item in qs:
full = '%s - (%s)' % (item.name,item.id)
result.append(full)
return HttpResponse(json.dumps(result), content_type='application/javascript')
def getemails(request):
"""
Ajax function to get emails for given Person Id. Used for adding Area ADs.
returns JSON format response: [{id:email, value:email},...]
"""
results=[]
id = request.GET.get('id','')
person = Person.objects.get(id=id)
for item in person.email_set.filter(active=True):
d = {'id': item.address, 'value': item.address}
results.append(d)
return HttpResponse(json.dumps(results), content_type='application/javascript')
# --------------------------------------------------
# STANDARD VIEW FUNCTIONS
# --------------------------------------------------
@role_required('Secretariat')
def list_areas(request):
"""
List IETF Areas
**Templates:**
* ``areas/list.html``
**Template Variables:**
* results
"""
results = Group.objects.filter(type="area").order_by('name')
return render(request, 'areas/list.html', { 'results': results} )
@role_required('Secretariat')
def people(request, name):
"""
Edit People associated with Areas, Area Directors.
# Legacy ------------------
When a new Director is first added they get a user_level of 4, read-only.
Then, when Director is made active (Enable Voting) user_level = 1.
# New ---------------------
First Director's are assigned the Role 'pre-ad' Incoming Area director
Then they get 'ad' role
**Templates:**
* ``areas/people.html``
**Template Variables:**
* directors, area
"""
area = get_object_or_404(Group, type='area', acronym=name)
if request.method == 'POST':
if request.POST.get('submit', '') == "Add":
form = AreaDirectorForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
person = form.cleaned_data['ad_name']
# save group
save_group_in_history(area)
# create role
Role.objects.create(name_id='pre-ad',group=area,email=email,person=person)
if not email.origin or email.origin == person.user.username:
email.origin = "role: %s %s" % (area.acronym, 'pre-ad')
email.save()
messages.success(request, 'New Area Director added successfully!')
return redirect('ietf.secr.areas.views.view', name=name)
else:
return HttpResponseBadRequest('Invalid action')
else:
form = AreaDirectorForm()
directors = area.role_set.filter(name__slug__in=('ad','pre-ad'))
return render(request, 'areas/people.html', {
'area': area,
'form': form,
'directors': directors},
)
@role_required('Secretariat')
def modify(request, name):
"""
Handle state changes of Area Directors (enable voting, retire)
# Legacy --------------------------
Enable Voting actions
- user_level = 1
- create TelechatUser object
Per requirements, the Retire button shall perform the following DB updates
- update iesg_login row, user_level = 2 (per Matt Feb 7, 2011)
- remove telechat_user row (to revoke voting rights)
- update IETFWG(groups) set area_director = TBD
- remove area_director row
# New ------------------------------
Enable Voting: change Role from 'pre-ad' to 'ad'
Retire: save in history, delete role record, set group assn to TBD
**Templates:**
* none
Redirects to view page on success.
"""
area = get_object_or_404(Group, type='area', acronym=name)
# should only get here with POST method
if request.method == 'POST':
# setup common request variables
tag = request.POST.get('tag', '')
person = Person.objects.get(id=tag)
# save group
save_group_in_history(area)
# handle retire request
if request.POST.get('submit', '') == "Retire":
role = Role.objects.get(group=area,name__in=('ad','pre-ad'),person=person)
role.delete()
# update groups that have this AD as primary AD
Role.objects.filter(name__in=('ad','pre-ad'),person=person,group__type='wg',group__state__in=('active','bof')).delete()
messages.success(request, 'The Area Director has been retired successfully!')
# handle voting request
if request.POST.get('submit', '') == "Enable Voting":
role = Role.objects.get(group=area,name__slug='pre-ad',person=person)
role.name_id = 'ad'
role.save()
messages.success(request, 'Voting rights have been granted successfully!')
return redirect('ietf.secr.areas.views.view', name=name)
@role_required('Secretariat')
def view(request, name):
"""
View Area information.
**Templates:**
* ``areas/view.html``
**Template Variables:**
* area, directors
"""
area = get_object_or_404(Group, type='area', acronym=name)
try:
area.start_date = area.groupevent_set.order_by('time')[0].time
area.concluded_date = area.groupevent_set.get(type='concluded').time
except GroupEvent.DoesNotExist:
pass
directors = area.role_set.filter(name__slug__in=('ad','pre-ad'))
return render(request, 'areas/view.html', {
'area': area,
'directors': directors},
)

View file

@ -1,42 +0,0 @@
{% extends "base_site.html" %}
{% load static %}
{% block title %}Areas{% endblock %}
{% block extrahead %}{{ block.super }}
<script src="{% static 'secr/js/utils.js' %}"></script>
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
&raquo; Areas
{% endblock %}
{% block content %}
<div class="module">
<h2>Areas</h2>
<table id="areas-list-table" class="full-width">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Acronym</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
{% for item in results %}
<tr class="{% cycle 'row1' 'row2' %} {{ item.state|lower }}">
<td><a href="{% url "ietf.secr.areas.views.view" name=item.acronym %}">{{ item.name }}</a></td>
<td>{{ item.acronym }}</td>
<td>{{ item.state }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="button-group">
<ul id="areas-button-list">
</ul>
</div> <!-- button-group -->
</div> <!-- module -->
{% endblock %}

View file

@ -1,60 +0,0 @@
{% extends "base_site.html" %}
{% load static %}
{% block title %}Areas - People{% endblock %}
{% block extrahead %}{{ block.super }}
<script src="{% static 'secr/js/utils.js' %}"></script>
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
&raquo; <a href="../../">Areas</a>
&raquo; <a href="../">{{ area.acronym }}</a>
&raquo; People
{% endblock %}
{% block content %}
<div class="module">
<h2>Area Directors ({{ area.acronym }})</h2>
<table class="center">
{% for director in directors %}
<form action="modify/" method="post">{% csrf_token %}
<input type="hidden" name="tag" value="{{ director.person.id }}">
<tr>
<td id="id-ad-name"><a href="#">{{ director.person.name }}</a></td>
<td>{% if director.name.slug == "ad" %}
Voting Enabled
{% else %}
<button type="submit" name="submit" value="Enable Voting">Enable Voting</button></td>
{% endif %}
<td><button type="submit" name="submit" value="Retire">Retire</button></td>
</tr>
</form>
{% endfor %}
</table>
<div class="inline-related">
<h3><b>Add new Director</b></h3>
<p>
<form action="." method="post">{% csrf_token %}
<table class="center">
<tbody>
<!-- [html-validate-disable-block wcag/h63 -- FIXME: as_table renders without scope] -->
{{ form.as_table }}
<tr>
<td></td>
<td><button type="submit" name="submit" value="Add">Add</button></td>
</tr>
</tbody>
</table>
</form>
</div> <!-- iniline-related -->
<div class="button-group">
<ul>
<li><button type="button" onclick="history.go(-1);return true">Back</button></li>
</ul>
</div> <!-- button-group -->
</div> <!-- module -->
{% endblock %}

View file

@ -1,50 +0,0 @@
{% extends "base_site.html" %}
{% load static %}
{% block title %}Areas - View{% endblock %}
{% block extrahead %}{{ block.super }}
<script src="{% static 'secr/js/utils.js' %}"></script>
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
&raquo; <a href="../">Areas</a>
&raquo; {{ area.acronym }}
{% endblock %}
{% block content %}
<div class="module">
<h2>Area - View</h2>
<table class="full-width">
<tbody>
<tr><td>Area Acronym:</td><td>{{ area.acronym }}</td></tr>
<tr><td>Area Name:</td><td>{{ area.name }}</td></tr>
<tr><td>Status:</td><td>{{ area.state }}</td></tr>
<tr><td>Start Date:</td><td>{{ area.start_date|date:"Y-m-d" }}</td></tr>
<tr><td>Concluded Date:</td><td>{{ area.concluded_date|date:"Y-m-d" }}</td></tr>
<tr><td>Last Modified Date:</td><td>{{ area.time|date:"Y-m-d" }}</td></tr>
<tr><td>Comments:</td><td>{{ area.comments}}</td></tr>
</tbody>
</table>
<div class="inline-related">
<h2>Directors</h2>
<table class="full-width">
<tbody>
{% for director in directors %}
<tr><td><a href="{% url 'ietf.secr.rolodex.views.view' id=director.person.id %}">{{ director.person.name }}</a>{% if director.name.slug == "pre-ad" %} (Incoming){% endif %}</td></tr>
{% endfor %}
</tbody>
</table>
</div> <!-- inline-group -->
<div class="button-group">
<ul>
<!-- <li><button type="button" onclick="window.location='../../'">Back</button></li> -->
<li><button type="button" onclick="window.location='edit/'">Edit</button></li>
<li><button type="button" onclick="window.location='people/'">People</button></li>
</ul>
</div> <!-- button-group -->
</div> <!-- module -->
{% endblock %}

View file

@ -19,7 +19,6 @@
<td>
<h2>IDs and WGs Process</h2>
<ul>
<li> <a href="{% url "ietf.secr.areas.views.list_areas" %}"><b>Areas</b></a></li>
<li> <a href="{% url 'ietf.secr.rolodex.views.search' %}"><b>Rolodex</b></a></li>
</ul>
</td>

View file

@ -44,7 +44,7 @@
<td>{{ role.name }} </td>
<td>
{% if role.group.type.slug == "area" %}
<a href="{% url "ietf.secr.areas.views.view" name=role.group.acronym %}">{{ role.group.acronym }}{% if role.group.state.slug == "conclude" %} (concluded){% endif %}</a>
{{ role.group.acronym }}{% if role.group.state.slug == "conclude" %} (concluded){% endif %}
{% else %}
<a href="{% url 'ietf.group.views.group_home' acronym=role.group.acronym %}">{{ role.group.acronym }}{% if role.group.state.slug == "conclude" %} (concluded){% endif %}</a>
{% endif %}

View file

@ -4,7 +4,6 @@ from django.views.generic import TemplateView
urlpatterns = [
re_path(r'^$', TemplateView.as_view(template_name='main.html')),
re_path(r'^announcement/', include('ietf.secr.announcement.urls')),
re_path(r'^areas/', include('ietf.secr.areas.urls')),
re_path(r'^meetings/', include('ietf.secr.meetings.urls')),
re_path(r'^rolodex/', include('ietf.secr.rolodex.urls')),
re_path(r'^sreq/', include('ietf.secr.sreq.urls')),

View file

@ -488,7 +488,6 @@ INSTALLED_APPS = [
'ietf.utils',
# IETF Secretariat apps
'ietf.secr.announcement',
'ietf.secr.areas',
'ietf.secr.meetings',
'ietf.secr.rolodex',
'ietf.secr.sreq',