Refactoring the mails sent when state is changed along with annotation tags. Currently there are two emails getting sent. Fixing it to send only one email that rolls up the annotation tag changes into the state change email.
- Legacy-Id: 6640
This commit is contained in:
parent
74c7230842
commit
629816a2cb
|
@ -250,7 +250,7 @@ class DraftTagsStateForm(StreamDraftForm):
|
|||
|
||||
return [(i.pk, i.name) for i in self.workflow.get_states()]
|
||||
|
||||
def save_tags(self):
|
||||
def save_tags(self,send_email=True):
|
||||
comment = self.cleaned_data.get('comment')
|
||||
new_tags = self.cleaned_data.get('tags')
|
||||
|
||||
|
@ -275,7 +275,8 @@ class DraftTagsStateForm(StreamDraftForm):
|
|||
person=self.person,
|
||||
set_tags=set_tags,
|
||||
reset_tags=reset_tags,
|
||||
extra_notify=extra_notify)
|
||||
extra_notify=extra_notify,
|
||||
send_email=send_email)
|
||||
|
||||
def save_state(self):
|
||||
comment = self.cleaned_data.get('comment')
|
||||
|
@ -285,8 +286,15 @@ class DraftTagsStateForm(StreamDraftForm):
|
|||
|
||||
old_state = self.draft.get_state("draft-stream-%s" % self.draft.stream_id)
|
||||
if state==old_state:
|
||||
self.save_tags()
|
||||
return
|
||||
|
||||
self.save_tags(False)
|
||||
new_tags = self.cleaned_data.get('tags')
|
||||
|
||||
set_tags = [tag for tag in self.available_tags if str(tag.pk) in new_tags and tag not in self.tags]
|
||||
reset_tags = [tag for tag in self.available_tags if str(tag.pk) not in new_tags and tag in self.tags]
|
||||
|
||||
weeks = self.cleaned_data.get('weeks')
|
||||
estimated_date = None
|
||||
if weeks:
|
||||
|
@ -297,12 +305,12 @@ class DraftTagsStateForm(StreamDraftForm):
|
|||
comment=comment,
|
||||
person=self.person,
|
||||
to_state=state,
|
||||
estimated_date=estimated_date)
|
||||
estimated_date=estimated_date,
|
||||
added_tags=set_tags,
|
||||
removed_tags=reset_tags)
|
||||
|
||||
def save(self):
|
||||
self.save_tags()
|
||||
if 'only_tags' not in self.data.keys():
|
||||
self.save_state()
|
||||
self.save_state()
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
comment = self.cleaned_data.get('comment').strip()
|
||||
|
|
|
@ -278,7 +278,7 @@ def get_pubreq_cc_receivers(doc):
|
|||
|
||||
return res
|
||||
|
||||
def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra_notify=[]):
|
||||
def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra_notify=[], send_email=True):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
doc = Document.objects.get(pk=obj.pk)
|
||||
save_document_in_history(doc)
|
||||
|
@ -297,8 +297,9 @@ def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra
|
|||
e.desc = " ".join(l)
|
||||
e.save()
|
||||
|
||||
receivers = get_notification_receivers(doc, extra_notify)
|
||||
send_mail(request, receivers, settings.DEFAULT_FROM_EMAIL,
|
||||
if send_email:
|
||||
receivers = get_notification_receivers(doc, extra_notify)
|
||||
send_mail(request, receivers, settings.DEFAULT_FROM_EMAIL,
|
||||
u"Annotations tags changed for draft %s" % doc.name,
|
||||
'ietfworkflows/annotation_tags_updated_mail.txt',
|
||||
dict(doc=doc,
|
||||
|
@ -337,7 +338,7 @@ def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra
|
|||
notify_tag_entry(entry, extra_notify)
|
||||
|
||||
|
||||
def update_state(request, doc, comment, person, to_state, estimated_date=None, extra_notify=[]):
|
||||
def update_state(request, doc, comment, person, to_state, added_tags, removed_tags, estimated_date=None, extra_notify=[]):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
doc = Document.objects.get(pk=doc.pk)
|
||||
save_document_in_history(doc)
|
||||
|
@ -370,6 +371,8 @@ def update_state(request, doc, comment, person, to_state, estimated_date=None, e
|
|||
reminder.active = False
|
||||
reminder.save()
|
||||
|
||||
set_tags=", ".join(x.name for x in added_tags)
|
||||
reset_tags=", ".join(x.name for x in removed_tags)
|
||||
receivers = get_notification_receivers(doc, extra_notify)
|
||||
send_mail(request, receivers, settings.DEFAULT_FROM_EMAIL,
|
||||
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
|
|||
to_state=to_state,
|
||||
transition_date=doc.time,
|
||||
person=person,
|
||||
comment=comment)))
|
||||
comment=comment,
|
||||
set_tags=set_tags,
|
||||
reset_tags=reset_tags)))
|
||||
|
||||
if (to_state.slug=='sub-pub'):
|
||||
receivers = get_pubreq_receivers(doc, extra_notify)
|
||||
|
|
|
@ -5,7 +5,8 @@ Previous state: {{ entry.from_state }}
|
|||
Current state: {{ entry.to_state }}
|
||||
Transition date: {{ entry.transition_date }}
|
||||
Author of the change: {{ entry.person }}
|
||||
|
||||
{% if entry.set_tags %}Annotation tags set: {{ entry.set_tags }}{% endif %}
|
||||
{% if entry.reset_tags %}Annotation tags reset: {{ entry.reset_tags }}{% endif %}
|
||||
Comment:
|
||||
{{ entry.comment }}
|
||||
{% endautoescape %}
|
||||
|
|
Loading…
Reference in a new issue