Skip to content

Commit 8ec6c33

Browse files
committed
Merged [6626] and [6640] from suresh.krishnan@ericsson.com:
Refactored the mails sent when state is changed along with annotation tags. Don't send emails for only comment changes, just add a history entry. For state changes and annotation changes, only send one email, containing information about both state changes and annotation tag changes. Fixes issue ietf-tools#1127. - Legacy-Id: 6660 Note: SVN reference [6626] has been migrated to Git commit 74c7230 Note: SVN reference [6640] has been migrated to Git commit 629816a
2 parents 71d797b + 629816a commit 8ec6c33

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

ietf/ietfworkflows/forms.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def get_states(self):
250250

251251
return [(i.pk, i.name) for i in self.workflow.get_states()]
252252

253-
def save_tags(self):
253+
def save_tags(self,send_email=True):
254254
comment = self.cleaned_data.get('comment')
255255
new_tags = self.cleaned_data.get('tags')
256256

@@ -275,13 +275,26 @@ def save_tags(self):
275275
person=self.person,
276276
set_tags=set_tags,
277277
reset_tags=reset_tags,
278-
extra_notify=extra_notify)
278+
extra_notify=extra_notify,
279+
send_email=send_email)
279280

280281
def save_state(self):
281282
comment = self.cleaned_data.get('comment')
282283
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
283284
from ietf.doc.models import State
284285
state = State.objects.get(pk=self.cleaned_data.get('new_state'))
286+
287+
old_state = self.draft.get_state("draft-stream-%s" % self.draft.stream_id)
288+
if state==old_state:
289+
self.save_tags()
290+
return
291+
292+
self.save_tags(False)
293+
new_tags = self.cleaned_data.get('tags')
294+
295+
set_tags = [tag for tag in self.available_tags if str(tag.pk) in new_tags and tag not in self.tags]
296+
reset_tags = [tag for tag in self.available_tags if str(tag.pk) not in new_tags and tag in self.tags]
297+
285298
weeks = self.cleaned_data.get('weeks')
286299
estimated_date = None
287300
if weeks:
@@ -292,12 +305,12 @@ def save_state(self):
292305
comment=comment,
293306
person=self.person,
294307
to_state=state,
295-
estimated_date=estimated_date)
308+
estimated_date=estimated_date,
309+
added_tags=set_tags,
310+
removed_tags=reset_tags)
296311

297312
def save(self):
298-
self.save_tags()
299-
if 'only_tags' not in self.data.keys():
300-
self.save_state()
313+
self.save_state()
301314

302315
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
303316
comment = self.cleaned_data.get('comment').strip()

ietf/ietfworkflows/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def get_pubreq_cc_receivers(doc):
278278

279279
return res
280280

281-
def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra_notify=[]):
281+
def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra_notify=[], send_email=True):
282282
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
283283
doc = Document.objects.get(pk=obj.pk)
284284
save_document_in_history(doc)
@@ -297,8 +297,9 @@ def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra
297297
e.desc = " ".join(l)
298298
e.save()
299299

300-
receivers = get_notification_receivers(doc, extra_notify)
301-
send_mail(request, receivers, settings.DEFAULT_FROM_EMAIL,
300+
if send_email:
301+
receivers = get_notification_receivers(doc, extra_notify)
302+
send_mail(request, receivers, settings.DEFAULT_FROM_EMAIL,
302303
u"Annotations tags changed for draft %s" % doc.name,
303304
'ietfworkflows/annotation_tags_updated_mail.txt',
304305
dict(doc=doc,
@@ -337,7 +338,7 @@ def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra
337338
notify_tag_entry(entry, extra_notify)
338339

339340

340-
def update_state(request, doc, comment, person, to_state, estimated_date=None, extra_notify=[]):
341+
def update_state(request, doc, comment, person, to_state, added_tags, removed_tags, estimated_date=None, extra_notify=[]):
341342
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
342343
doc = Document.objects.get(pk=doc.pk)
343344
save_document_in_history(doc)
@@ -370,6 +371,8 @@ def update_state(request, doc, comment, person, to_state, estimated_date=None, e
370371
reminder.active = False
371372
reminder.save()
372373

374+
set_tags=", ".join(x.name for x in added_tags)
375+
reset_tags=", ".join(x.name for x in removed_tags)
373376
receivers = get_notification_receivers(doc, extra_notify)
374377
send_mail(request, receivers, settings.DEFAULT_FROM_EMAIL,
375378
u"State changed for draft %s" % doc.name,
@@ -379,7 +382,9 @@ def update_state(request, doc, comment, person, to_state, estimated_date=None, e
379382
to_state=to_state,
380383
transition_date=doc.time,
381384
person=person,
382-
comment=comment)))
385+
comment=comment,
386+
set_tags=set_tags,
387+
reset_tags=reset_tags)))
383388

384389
if (to_state.slug=='sub-pub'):
385390
receivers = get_pubreq_receivers(doc, extra_notify)

ietf/templates/ietfworkflows/state_updated_mail.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Previous state: {{ entry.from_state }}
55
Current state: {{ entry.to_state }}
66
Transition date: {{ entry.transition_date }}
77
Author of the change: {{ entry.person }}
8-
8+
{% if entry.set_tags %}Annotation tags set: {{ entry.set_tags }}{% endif %}
9+
{% if entry.reset_tags %}Annotation tags reset: {{ entry.reset_tags }}{% endif %}
910
Comment:
1011
{{ entry.comment }}
1112
{% endautoescape %}

0 commit comments

Comments
 (0)