Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions ietf/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from ietf.group.factories import RoleFactory
from ietf.meeting.factories import MeetingFactory, SessionFactory
from ietf.meeting.models import Session
from ietf.nomcom.models import Volunteer, NomCom
from ietf.nomcom.factories import NomComFactory, nomcom_kwargs_for_year
from ietf.person.factories import PersonFactory, random_faker
from ietf.person.models import User
from ietf.person.models import PersonalApiKey
Expand Down Expand Up @@ -630,6 +632,7 @@ def test_api_new_meeting_registration(self):
'reg_type': 'hackathon',
'ticket_type': '',
'checkedin': 'False',
'is_nomcom_volunteer': 'False',
}
url = urlreverse('ietf.api.views.api_new_meeting_registration')
r = self.client.post(url, reg)
Expand Down Expand Up @@ -691,6 +694,50 @@ def test_api_new_meeting_registration(self):
missing_fields = [f.strip() for f in fields.split(',')]
self.assertEqual(set(missing_fields), set(drop_fields))

def test_api_new_meeting_registration_nomcom_volunteer(self):
'''Test that Volunteer is created if is_nomcom_volunteer=True
is submitted to API
'''
meeting = MeetingFactory(type_id='ietf')
reg = {
'apikey': 'invalid',
'affiliation': "Alguma Corporação",
'country_code': 'PT',
'meeting': meeting.number,
'reg_type': 'onsite',
'ticket_type': '',
'checkedin': 'False',
'is_nomcom_volunteer': 'True',
}
person = PersonFactory()
reg['email'] = person.email().address
reg['first_name'] = person.first_name()
reg['last_name'] = person.last_name()
now = datetime.datetime.now()
if now.month > 10:
year = now.year + 1
else:
year = now.year
# create appropriate group and nomcom objects
nomcom = NomComFactory.create(is_accepting_volunteers=True, **nomcom_kwargs_for_year(year))
url = urlreverse('ietf.api.views.api_new_meeting_registration')
r = self.client.post(url, reg)
self.assertContains(r, 'Invalid apikey', status_code=403)
oidcp = PersonFactory(user__is_staff=True)
# Make sure 'oidcp' has an acceptable role
RoleFactory(name_id='robot', person=oidcp, email=oidcp.email(), group__acronym='secretariat')
key = PersonalApiKey.objects.create(person=oidcp, endpoint=url)
reg['apikey'] = key.hash()
r = self.client.post(url, reg)
nomcom = NomCom.objects.last()
self.assertContains(r, "Accepted, New registration", status_code=202)
# assert Volunteer exists
self.assertEqual(Volunteer.objects.count(), 1)
volunteer = Volunteer.objects.last()
self.assertEqual(volunteer.person, person)
self.assertEqual(volunteer.nomcom, nomcom)
self.assertEqual(volunteer.origin, 'registration')

def test_api_version(self):
DumpInfo.objects.create(date=timezone.datetime(2022,8,31,7,10,1,tzinfo=datetime.timezone.utc), host='testapi.example.com',tz='UTC')
url = urlreverse('ietf.api.views.version')
Expand Down
17 changes: 15 additions & 2 deletions ietf/api/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright The IETF Trust 2017-2020, All Rights Reserved
# -*- coding: utf-8 -*-


import json
import pytz
import re
Expand Down Expand Up @@ -38,6 +37,7 @@
from ietf.ietfauth.views import send_account_creation_email
from ietf.ietfauth.utils import role_required
from ietf.meeting.models import Meeting
from ietf.nomcom.models import Volunteer, NomCom
from ietf.stats.models import MeetingRegistration
from ietf.utils import log
from ietf.utils.decorators import require_api_key
Expand Down Expand Up @@ -140,7 +140,7 @@ def api_new_meeting_registration(request):
def err(code, text):
return HttpResponse(text, status=code, content_type='text/plain')
required_fields = [ 'meeting', 'first_name', 'last_name', 'affiliation', 'country_code',
'email', 'reg_type', 'ticket_type', 'checkedin']
'email', 'reg_type', 'ticket_type', 'checkedin', 'is_nomcom_volunteer']
fields = required_fields + []
if request.method == 'POST':
# parameters:
Expand Down Expand Up @@ -202,6 +202,19 @@ def err(code, text):
else:
send_account_creation_email(request, email)
response += ", Email sent"

# handle nomcom volunteer
if data['is_nomcom_volunteer'] and object.person:
try:
nomcom = NomCom.objects.get(is_accepting_volunteers=True)
except (NomCom.DoesNotExist, NomCom.MultipleObjectsReturned):
nomcom = None
if nomcom:
Volunteer.objects.create(
nomcom=nomcom,
person=object.person,
affiliation=data['affiliation'],
origin='registration')
return HttpResponse(response, status=202, content_type='text/plain')
else:
return HttpResponse(status=405)
Expand Down
4 changes: 4 additions & 0 deletions ietf/doc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@ def is_downref(self):

if self.source.type_id == "rfc":
source_lvl = self.source.std_level_id
elif self.source.type_id in ["bcp","std"]:
source_lvl = self.source.type_id
else:
source_lvl = self.source.intended_std_level_id

Expand All @@ -711,6 +713,8 @@ def is_downref(self):
target_lvl = 'unkn'
else:
target_lvl = self.target.std_level_id
elif self.target.type_id in ["bcp", "std"]:
target_lvl = self.target.type_id
else:
if not self.target.intended_std_level:
target_lvl = 'unkn'
Expand Down
6 changes: 6 additions & 0 deletions ietf/doc/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ def do_fuzzy_find_documents_rfc_test(self, name):
found = fuzzy_find_documents(draft.name, '22')
self.assertCountEqual(found.documents, [draft],
'Should find document even if rev does not exist')

# by rfc name mistakenly trying to provide a revision
found = fuzzy_find_documents(rfc.name+"-22")
self.assertCountEqual(found.documents, [rfc], "Should ignore versions when fuzzyfinding RFCs" )
found = fuzzy_find_documents(rfc.name,"22")
self.assertCountEqual(found.documents, [rfc], "Should ignore versions when fuzzyfinding RFCs" )


def test_fuzzy_find_documents(self):
Expand Down
7 changes: 4 additions & 3 deletions ietf/doc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,14 +1209,15 @@ def fuzzy_find_documents(name, rev=None):

if name.startswith("rfc"):
sought_type = "rfc"
log.assertion("rev is None")
name = name.split("-")[0] # strip any noise (like a revision) at and after the first hyphen
rev = None # If someone is looking for an RFC and supplies a version, ignore it.
else:
sought_type = "draft"

# see if we can find a document using this name
docs = Document.objects.filter(name=name, type_id=sought_type)
if rev and not docs.exists():
# No document found, see if the name/rev split has been misidentified.
if sought_type == "draft" and rev and not docs.exists():
# No draft found, see if the name/rev split has been misidentified.
# Handles some special cases, like draft-ietf-tsvwg-ieee-802-11.
name = '%s-%s' % (name, rev)
docs = Document.objects.filter(name=name, type_id='draft')
Expand Down
53 changes: 29 additions & 24 deletions ietf/doc/views_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,19 @@ def state_name(doc_type, state, shorten=True):
for dt in AD_WORKLOAD
}


def state_to_doc_type(state):
for dt in STATE_SLUGS:
if state in STATE_SLUGS[dt]:
return dt
return None


IESG_STATES = State.objects.filter(type="draft-iesg").values_list("name", flat=True)


def date_to_bucket(date, now, num_buckets):
return num_buckets - min(
num_buckets, int((now.date() - date.date()).total_seconds() / 60 / 60 / 24)
)
return num_buckets - int((now.date() - date.date()).total_seconds() / 60 / 60 / 24)


def ad_workload(request):
Expand Down Expand Up @@ -477,6 +483,7 @@ def ad_workload(request):
to_state = state_name(dt, state, shorten=False)
elif e.desc.endswith("has been replaced"):
# stop tracking
last = e.time
break

if not to_state:
Expand All @@ -501,26 +508,30 @@ def ad_workload(request):
elif to_state == "RFC Published":
to_state = "RFC"

if dt == "rfc":
new_dt = state_to_doc_type(to_state)
if new_dt is not None and new_dt != dt:
dt = new_dt

if to_state not in STATE_SLUGS[dt].keys() or to_state == "Replaced":
# change into a state the AD dashboard doesn't display
if to_state in IESG_STATES or to_state == "Replaced":
# if it's an IESG state we don't display, we're done with this doc
# if it's an IESG state we don't display, record it's time
last = e.time
break
# if it's not an IESG state, keep going with next event
# keep going with next event
continue

sn = STATE_SLUGS[dt][to_state]
buckets_start = date_to_bucket(e.time, now, days)
buckets_end = date_to_bucket(last, now, days)

if buckets_end >= days:
# this event is older than we record in the history
if last == now:
# but since we didn't record any state yet,
# this is the state the doc was in for the
# entire history
for b in range(buckets_start, days):
if dt == "charter" and to_state == "Approved" and buckets_start < 0:
# don't count old charter approvals
break

if buckets_start <= 0:
if buckets_end >= 0:
for b in range(0, buckets_end):
ad.buckets[dt][sn][b].append(doc.name)
sums[dt][sn][b].append(doc.name)
last = e.time
Expand All @@ -532,15 +543,6 @@ def ad_workload(request):
sums[dt][sn][b].append(doc.name)
last = e.time

if last == now:
s = state_name(dt, state, shorten=False)
if s in STATE_SLUGS[dt].keys():
# we didn't have a single event for this doc, assume
# the current state applied throughput the history
for b in range(days):
ad.buckets[dt][state][b].append(doc.name)
sums[dt][state][b].append(doc.name)

metadata = [
{
"type": (dt, doc_type_name(dt)),
Expand All @@ -564,8 +566,11 @@ def ad_workload(request):

def docs_for_ad(request, name):
def sort_key(doc):
key = list(AD_WORKLOAD.keys()).index(doc_type(doc))
return key
dt = doc_type(doc)
dt_key = list(AD_WORKLOAD.keys()).index(dt)
ds = doc_state(doc)
ds_key = AD_WORKLOAD[dt].index(ds) if ds in AD_WORKLOAD[dt] else 99
return dt_key * 100 + ds_key

ad = None
responsible = Document.objects.values_list("ad", flat=True).distinct()
Expand Down
46 changes: 31 additions & 15 deletions ietf/group/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,23 +740,40 @@ def dependencies(request, acronym, group_type=None):
source__type="draft",
relationship__slug__startswith="ref",
)

both_rfcs = Q(source__type_id="rfc", target__type_id="rfc")
inactive = Q(source__states__slug__in=["expired", "repl"])
rfc_or_subseries = {"rfc", "bcp", "fyi", "std"}
both_rfcs = Q(source__type_id="rfc", target__type_id__in=rfc_or_subseries)
pre_rfc_draft_to_rfc = Q(
source__states__type="draft",
source__states__slug="rfc",
target__type_id__in=rfc_or_subseries,
)
both_pre_rfcs = Q(
source__states__type="draft",
source__states__slug="rfc",
target__type_id="draft",
target__states__type="draft",
target__states__slug="rfc",
)
inactive = Q(
source__states__type="draft",
source__states__slug__in=["expired", "repl"],
)
attractor = Q(target__name__in=["rfc5000", "rfc5741"])
removed = Q(source__states__slug__in=["auth-rm", "ietf-rm"])
removed = Q(source__states__type="draft", source__states__slug__in=["auth-rm", "ietf-rm"])
relations = (
RelatedDocument.objects.filter(references)
.exclude(both_rfcs)
.exclude(pre_rfc_draft_to_rfc)
.exclude(both_pre_rfcs)
.exclude(inactive)
.exclude(attractor)
.exclude(removed)
)

links = set()
for x in relations:
target_state = x.target.get_state_slug("draft")
if target_state != "rfc" or x.is_downref():
always_include = x.target.type_id not in rfc_or_subseries and x.target.get_state_slug("draft") != "rfc"
if always_include or x.is_downref():
links.add(x)

replacements = RelatedDocument.objects.filter(
Expand All @@ -771,13 +788,12 @@ def dependencies(request, acronym, group_type=None):
graph = {
"nodes": [
{
"id": x.name,
"rfc": x.get_state("draft").slug == "rfc",
"post-wg": not x.get_state("draft-iesg").slug
in ["idexists", "watching", "dead"],
"expired": x.get_state("draft").slug == "expired",
"replaced": x.get_state("draft").slug == "repl",
"group": x.group.acronym if x.group.acronym != "none" else "",
"id": x.became_rfc().name if x.became_rfc() else x.name,
"rfc": x.type_id == "rfc" or x.became_rfc() is not None,
"post-wg": x.get_state_slug("draft-iesg") not in ["idexists", "watching", "dead"],
"expired": x.get_state_slug("draft") == "expired",
"replaced": x.get_state_slug("draft") == "repl",
"group": x.group.acronym if x.group and x.group.acronym != "none" else "",
"url": x.get_absolute_url(),
"level": x.intended_std_level.name
if x.intended_std_level
Expand All @@ -789,8 +805,8 @@ def dependencies(request, acronym, group_type=None):
],
"links": [
{
"source": x.source.name,
"target": x.target.name,
"source": x.source.became_rfc().name if x.source.became_rfc() else x.source.name,
"target": x.target.became_rfc().name if x.target.became_rfc() else x.target.name,
"rel": "downref" if x.is_downref() else x.relationship.slug,
}
for x in links
Expand Down
10 changes: 8 additions & 2 deletions ietf/meeting/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2016-2020, All Rights Reserved
# Copyright The IETF Trust 2016-2023, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -360,7 +360,13 @@ def save_agenda(self):
class InterimAnnounceForm(forms.ModelForm):
class Meta:
model = Message
fields = ('to', 'frm', 'cc', 'bcc', 'reply_to', 'subject', 'body')
fields = ('to', 'cc', 'frm', 'subject', 'body')

def __init__(self, *args, **kwargs):
super(InterimAnnounceForm, self).__init__(*args, **kwargs)
self.fields['frm'].label='From'
self.fields['frm'].widget.attrs['readonly'] = True
self.fields['to'].widget.attrs['readonly'] = True

def save(self, *args, **kwargs):
user = kwargs.pop('user')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.7 on 2023-11-05 09:45

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("nomcom", "0003_alter_nomination_share_nominator"),
]

operations = [
migrations.AddField(
model_name="volunteer",
name="origin",
field=models.CharField(default="datatracker", max_length=32),
),
migrations.AddField(
model_name="volunteer",
name="time",
field=models.DateTimeField(auto_now_add=True, null=True, blank=True),
),
migrations.AddField(
model_name="volunteer",
name="withdrawn",
field=models.DateTimeField(blank=True, null=True),
),
]
Loading