Skip to content

Commit a8ddac1

Browse files
committed
Merged in [8498] from rjsparks@nostrum.com:\n Reworked logic flow for editing shepherds. Added message to inform the user when the shepherd is not changed. Fixes bug ietf-tools#1508.
- Legacy-Id: 8499 Note: SVN reference [8498] has been migrated to Git commit 055202d
2 parents f3b8d34 + 055202d commit a8ddac1

2 files changed

Lines changed: 38 additions & 18 deletions

File tree

ietf/doc/views_draft.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from django.forms.util import ErrorList
1212
from django.contrib.auth.decorators import login_required
1313
from django.template.defaultfilters import pluralize
14+
from django.contrib import messages
1415

1516
from ietf.doc.models import ( Document, DocAlias, DocRelationshipName, RelatedDocument, State,
1617
StateType, DocEvent, ConsensusDocEvent, TelechatDocEvent, WriteupDocEvent, IESG_SUBSTATE_TAGS,
@@ -953,27 +954,32 @@ def edit_shepherd(request, name):
953954
if request.method == 'POST':
954955
form = ShepherdForm(request.POST)
955956
if form.is_valid():
956-
save_document_in_history(doc)
957957

958958
if form.cleaned_data['shepherd'] != doc.shepherd:
959+
960+
save_document_in_history(doc)
961+
959962
doc.shepherd = form.cleaned_data['shepherd']
960963
doc.save()
961-
964+
962965
c = DocEvent(type="added_comment", doc=doc, by=request.user.person)
963966
c.desc = "Document shepherd changed to "+ (doc.shepherd.person.name if doc.shepherd else "(None)")
964967
c.save()
968+
969+
if doc.shepherd.formatted_email() not in doc.notify:
970+
login = request.user.person
971+
addrs = doc.notify
972+
if addrs:
973+
addrs += ', '
974+
addrs += doc.shepherd.formatted_email()
975+
make_notify_changed_event(request, doc, login, addrs, c.time)
976+
doc.notify = addrs
977+
978+
doc.time = c.time
979+
doc.save()
965980

966-
if doc.shepherd.formatted_email() not in doc.notify:
967-
login = request.user.person
968-
addrs = doc.notify
969-
if addrs:
970-
addrs += ', '
971-
addrs += doc.shepherd.formatted_email()
972-
make_notify_changed_event(request, doc, login, addrs, c.time)
973-
doc.notify = addrs
974-
975-
doc.time = c.time
976-
doc.save()
981+
else:
982+
messages.info(request,"The selected shepherd was already assigned - no changes have been made.")
977983

978984
return redirect('doc_view', name=doc.name)
979985

ietf/utils/draft.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import sys
4141
import time
4242

43-
version = "0.31"
43+
version = "0.33"
4444
program = os.path.basename(sys.argv[0])
4545
progdir = os.path.dirname(sys.argv[0])
4646

@@ -75,7 +75,10 @@
7575
}
7676
longform = dict([ (short+" ", longform[short]+" ") for short in longform ])
7777

78-
month_names = [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ]
78+
79+
month_names = [ 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december' ]
80+
month_names_abbrev3 = [ n[:3] for n in month_names ]
81+
month_names_abbrev4 = [ n[:4] for n in month_names ]
7982

8083
# ----------------------------------------------------------------------
8184
# Functions
@@ -311,6 +314,8 @@ def get_creation_date(self):
311314
r'\s{3,}(?P<month>\w+)\s+(?P<day>\d{1,2})(,|\s)+(?P<year>\d{4})',
312315
r'\s{3,}(?P<day>\d{1,2})(,|\s)+(?P<month>\w+)\s+(?P<year>\d{4})',
313316
r'\s{3,}(?P<day>\d{1,2})-(?P<month>\w+)-(?P<year>\d{4})',
317+
# RFC 3339 date (also ISO date)
318+
r'\s{3,}(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})',
314319
# 'October 2008' - default day to today's.
315320
r'\s{3,}(?P<month>\w+)\s+(?P<year>\d{4})',
316321
]
@@ -326,11 +331,20 @@ def get_creation_date(self):
326331
dates.sort()
327332
for start, match in dates:
328333
md = match.groupdict()
329-
mon = md['month'][0:3].lower()
334+
mon = md['month'].lower()
330335
day = int( md.get( 'day', 0 ) )
331336
year = int( md['year'] )
332337
try:
333-
month = month_names.index( mon ) + 1
338+
if mon in month_names:
339+
month = month_names.index( mon ) + 1
340+
elif mon in month_names_abbrev3:
341+
month = month_names_abbrev3.index( mon ) + 1
342+
elif mon in month_names_abbrev4:
343+
month = month_names_abbrev4.index( mon ) + 1
344+
elif mon.isdigit() and int(mon) in range(1,13):
345+
month = mon
346+
else:
347+
continue
334348
today = datetime.date.today()
335349
if day==0:
336350
# if the date was given with only month and year, use
@@ -1079,7 +1093,7 @@ def getmeta(fn):
10791093
fields["docaffiliations"] = ", ".join(draft.get_authors_with_firm())
10801094
if opt_debug:
10811095
fields["docheader"] = draft._docheader
1082-
normrefs, rfcrefs, draftrefs, refs = draft.get_refs()
1096+
normrefs, rfcrefs, draftrefs, refs = draft.old_get_refs()
10831097
fields["docrfcrefs"] = ", ".join(rfcrefs)
10841098
fields["docdraftrefs"] = ", ".join(draftrefs)
10851099
fields["doccreationdate"] = str(draft.get_creation_date())

0 commit comments

Comments
 (0)