Skip to content

Commit

Permalink
Fixes #542
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel committed Mar 28, 2018
1 parent 4cbc41b commit 6598453
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from google.appengine.api import urlfetch
from google.appengine.api import taskqueue

from django.utils.html import escape
from django.utils.html import conditional_escape as escape

import common
import settings
Expand Down Expand Up @@ -93,9 +93,9 @@ def email_feature_subscribers(feature, is_update=False, changes=[]):
<ul>%s</ul>
</li>""" % moz_links

intro = 'You are listed as an owner for web platform features under "{component_name}"'.format(component_name=escape(component_name))
intro = 'You are listed as an owner for web platform features under "{component_name}"'.format(component_name=component_name)
if not owners:
intro = 'Just letting you know that there\'s a new feature under "{component_name}"'.format(component_name=escape(component_name))
intro = 'Just letting you know that there\'s a new feature under "{component_name}"'.format(component_name=component_name)

created_on = datetime.datetime.strptime(str(feature.created), "%Y-%m-%d %H:%M:%S.%f").date()
new_msg = """
Expand Down Expand Up @@ -130,13 +130,21 @@ def email_feature_subscribers(feature, is_update=False, changes=[]):
updated_on = datetime.datetime.strptime(str(feature.updated), "%Y-%m-%d %H:%M:%S.%f").date()
formatted_changes = ''
for prop in changes:
formatted_changes += '<li>%s: %s &gt; %s</li>' % (escape(prop['prop_name']), escape(prop['old_val']), escape(prop['new_val']))
prop_name = prop['prop_name']
new_val = prop['new_val']
old_val = prop['old_val']

if prop_name == 'category':
new_val = models.FEATURE_CATEGORIES[new_val]
old_val = models.FEATURE_CATEGORIES[old_val]

formatted_changes += '<li>%s: %s &gt; %s</li>' % (prop_name, escape(old_val), escape(new_val))
if not formatted_changes:
formatted_changes = '<li>None</li>'

intro = 'You are listed as an owner for web platform features under "{component_name}"'.format(component_name=escape(component_name))
intro = 'You are listed as an owner for web platform features under "{component_name}"'
if not owners:
intro = 'Just letting you know that a feature under "{component_name}" has changed'.format(component_name=escape(component_name))
intro = 'Just letting you know that a feature under "{component_name}" has changed'

update_msg = """<html><body>
<p>Hi <b>{owners}</b>,</p>
Expand Down Expand Up @@ -170,7 +178,7 @@ def email_feature_subscribers(feature, is_update=False, changes=[]):
updated_by=escape(feature.updated_by), intro=escape(intro),
owners=escape(', '.join([o.name for o in owners])), milestone=escape(milestone_str),
status=escape(models.IMPLEMENTATION_STATUS[feature.impl_status_chrome]),
formatted_changes=escape(formatted_changes),
formatted_changes=formatted_changes,
wf_content=create_wf_content_list(component_name), moz_links=moz_links,
component_name=escape(component_name))

Expand Down

0 comments on commit 6598453

Please sign in to comment.