Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
reverts all the commits
Browse files Browse the repository at this point in the history
  • Loading branch information
attiyaIshaque committed Jun 1, 2020
1 parent e745d12 commit 8869ed1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
17 changes: 3 additions & 14 deletions edx_notifications/digests.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def send_notifications_digest(from_timestamp, to_timestamp, preference_name, sub
unread_only=unread_only
)

log.info("digests_sent ....... %s", digests_sent)
return digests_sent


Expand Down Expand Up @@ -324,7 +323,7 @@ def send_notifications_namespace_digest(namespace, from_timestamp, to_timestamp,
pass

if user_wants_digest:
log.info(
log.debug(
'Sending digest email from namespace "%s" to user_id = %s at email %s...',
namespace, user_id, email
)
Expand All @@ -342,7 +341,6 @@ def send_notifications_namespace_digest(namespace, from_timestamp, to_timestamp,
unread_only=unread_only
)

log.info("digests_sent2 ............ %s", digests_sent)
return digests_sent


Expand Down Expand Up @@ -376,7 +374,6 @@ def _send_user_digest(namespace_info, from_timestamp, to_timestamp, user_id,
"""

# query all unread notifications for this user since the timestamp
log.info("fetching user notificaitons..........")
notifications = get_notifications_for_user(
user_id,
filters={
Expand All @@ -390,31 +387,26 @@ def _send_user_digest(namespace_info, from_timestamp, to_timestamp, user_id,
'select_related': True, # make sure we do JOINs on the initial query
}
)
log.info("fetching notification_groups..........")

notification_groups = render_notifications_by_type(notifications)

# As an option, don't send an email at all if there are no
# unread notifications
if not notification_groups and const.NOTIFICATION_DONT_SEND_EMPTY_DIGEST:
log.info('Digest email for %s is empty. Not sending...', email)
log.debug('Digest email for %s is empty. Not sending...', email)
return 0
else:
log.info("NOT empty ..... proceeding")

context = {
'namespace_display_name': namespace_info['display_name'],
'grouped_user_notifications': notification_groups
}

# render the notifications html template
log.info("notifications_html ... checking ..... ")
notifications_html = render_to_string("django/digests/unread_notifications_inner.html", context)
log.info("notifications_html ... checked ..... proceeding")

# create the image dictionary to store the
# img_path, unique id and title for the image.
branded_logo = dict(title='Logo', path=const.NOTIFICATION_BRANDED_DEFAULT_LOGO, cid=str(uuid.uuid4()))
log.info("branded_logo ....... %s", branded_logo)

context = {
'branded_logo': branded_logo['cid'],
Expand All @@ -425,13 +417,10 @@ def _send_user_digest(namespace_info, from_timestamp, to_timestamp, user_id,
'rendered_notifications': notifications_html
}
# render the mail digest template.
log.info("email_body .......checking ....")
email_body = with_inline_css(
render_to_string("django/digests/branded_notifications_outer.html", context)
)

log.info("email_body ....... checked ... processing")

html_part = MIMEMultipart(_subtype='related')
html_part.attach(MIMEText(email_body, _subtype='html'))
logo_image = attach_image(branded_logo, 'Header Logo')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
# Have all logging go to stdout with management commands
# this must be up at the top otherwise the
# configuration does not appear to take affect
# LOGGING = {
# 'version': 1,
# 'handlers': {
# 'console': {
# 'class': 'logging.StreamHandler',
# 'stream': sys.stdout,
# }
# },
# 'root': {
# 'handlers': ['console'],
# 'level': 'INFO'
# }
# }
# logging.config.dictConfig(LOGGING)
LOGGING = {
'version': 1,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'stream': sys.stdout,
}
},
'root': {
'handlers': ['console'],
'level': 'INFO'
}
}
logging.config.dictConfig(LOGGING)


log = logging.getLogger(__file__)
Expand Down

0 comments on commit 8869ed1

Please sign in to comment.