Skip to content
This repository was archived by the owner on May 12, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions edx_notifications/stores/sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from edx_notifications import const
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from django.utils.translation import get_language,ugettext_lazy as _
from django.utils.translation import ugettext_lazy as _


class SQLNotificationType(models.Model):
Expand Down Expand Up @@ -124,7 +124,8 @@ def to_data_object(self, options=None): # pylint: disable=unused-argument
deliver_no_earlier_than=self.deliver_no_earlier_than,
expires_at=self.expires_at,
expires_secs_after_read=self.expires_secs_after_read,
payload=self.translate_payload_title(DictField.from_json(self.payload)), # special case, dict<-->JSON string
payload=self.translate_payload_title
(DictField.from_json(self.payload)), # special case, dict<-->JSON string
created=self.created,
resolve_links=DictField.from_json(self.resolve_links), # special case, dict<-->JSON string
object_id=self.object_id
Expand All @@ -133,9 +134,14 @@ def to_data_object(self, options=None): # pylint: disable=unused-argument
return msg

def translate_payload_title(self, payload):
"""
translate a the title of any announcement to the current course language
:param payload:
:return:
"""
if payload and 'notification_type' in payload and payload['notification_type'] == "courseannouncement":
announcement_date = payload['announcement_date']
title = _('Announcement on {annoucement_date}').format(annoucement_date=announcement_date)
title = _('Announcement on {annoucement_date}').format(annoucement_date=announcement_date) # pylint: disable=line-too-long, no-member
payload['title'] = title
return payload

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def load_requirements(*requirements_paths):

setup(
name='edx-notifications',
version='0.6.8',
version='0.6.9',
description='Notification subsystem for Open edX',
long_description=open('README.md').read(),
author='edX',
Expand Down