-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into NiedielnitsevIvan/FC-0047/feature/implemen…
…t-push-notifications-chanel
- Loading branch information
Showing
9 changed files
with
123 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
openedx/core/djangoapps/notifications/notification_content.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Helper functions for overriding notification content for given notification type. | ||
""" | ||
|
||
|
||
def get_notification_type_content_function(notification_type): | ||
""" | ||
Returns the content function for the given notification if it exists. | ||
""" | ||
try: | ||
return globals()[f"get_{notification_type}_notification_content"] | ||
except KeyError: | ||
return None | ||
|
||
|
||
def get_notification_content_with_author_pronoun(notification_type, context): | ||
""" | ||
Helper function to get notification content with author's pronoun. | ||
""" | ||
html_tags_context = { | ||
'strong': 'strong', | ||
'p': 'p', | ||
} | ||
notification_type_content_template = notification_type.get('content_template', None) | ||
if 'author_pronoun' in context: | ||
context['author_name'] = context['author_pronoun'] | ||
if notification_type_content_template: | ||
return notification_type_content_template.format(**context, **html_tags_context) | ||
return '' | ||
|
||
|
||
# Returns notification content for the new_comment notification. | ||
get_new_comment_notification_content = get_notification_content_with_author_pronoun | ||
# Returns notification content for the comment_on_followed_post notification. | ||
get_comment_on_followed_post_notification_content = get_notification_content_with_author_pronoun |