Commit 82c9fd8f authored by Jose Semedo's avatar Jose Semedo
Browse files

Changing slice on processor and removing slice on template.

parent 4a42e293
......@@ -56,20 +56,23 @@ class EmailFeedProcessor(Processor):
notification_ids = kwargs["notifications"]
notifications = self.data_source.get_channel_notifications(notification_ids)
for notification in notifications[0:3]:
notification.update(
{('body', BeautifulSoup(notification['body'], "lxml").get_text(" "))}
)
grouped_notifications = itertools.groupby(
notifications[0:3],
lambda n: (n['targetId'], n['channel']['name'], n['channel']['slug'])
)
def prepare_notifications(notifications):
for notification in notifications:
notification.update(
{('body', BeautifulSoup(notification['body'], "lxml").get_text(" "))}
)
return notifications
context = {
"title": title,
"notification_priority": NotificationPriority,
# Jinja2 Renderer Fix https://stackoverflow.com/questions/6906593/itertools-groupby-in-a-django-template
"channel_notifications": [(k, list(g)) for k, g in grouped_notifications],
"channel_notifications": [(k, prepare_notifications(list(g)[0:3])) for k, g in grouped_notifications],
"sender": Config.SERVICE_NAME,
}
......
......@@ -21,7 +21,7 @@
</a>
</td>
</tr>
{% for notification in notifications[:3] %}
{% for notification in notifications %}
<tr>
<td style="padding:10px">
<p><b>{% if notification.priority and notification.priority.upper() ==
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment