Skip to content

Commit 055202d

Browse files
committed
Reworked logic flow for editing shepherds. Added message to inform the user when the shepherd is not changed. Fixes bug ietf-tools#1508. Commit ready for merge.
- Legacy-Id: 8498
1 parent ad27779 commit 055202d

1 file changed

Lines changed: 19 additions & 13 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

0 commit comments

Comments
 (0)