Skip to content

Commit

Permalink
Merge pull request #85 from andela/bg-fix-get-likes-email-notificatio…
Browse files Browse the repository at this point in the history
…ns-166928452

#166928452 Fix getting likes and dislikes count and fix email notification
  • Loading branch information
charisschomba committed Jun 26, 2019
2 parents 16aa8e0 + 9fea04c commit d0f73bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion authors/apps/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ def ratings(self, article_id, user):
return {
"average_ratings": Article().average_ratings(article_id)
}
return 0
return {
"average_ratings": 0
}


class CommentHistory(models.Model):
Expand Down
3 changes: 2 additions & 1 deletion authors/apps/articles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class Meta:
fields = (
'slug', 'title', 'description', 'body', 'image', 'image_url',
'created_at', 'updated_at', 'author', 'ratings', 'tagList',
'like_info', 'comments', 'favorites', 'readtime', 'bookmarked'
'like_info', 'comments', 'favorites', 'readtime', 'bookmarked',
'num_vote_up', 'num_vote_down'
)
extra_kwargs = {
'image': {'write_only': True, 'required': False}
Expand Down
5 changes: 2 additions & 3 deletions authors/utils/notification_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ def create_article_handler(sender, instance, created, **kwargs):
article_author,
title.upper(),
instance.created_at.strftime('%d-%B-%Y %H:%M'))

url = f"/post/{instance.slug}"
url = f"{settings.DOMAIN}{url}"
if not followers:
return
for user in followers:
if user.user.notification_preferences.in_app_notifications:
url = f"/post/{instance.slug}"
url = f"{settings.DOMAIN}{url}"
notify.send(
article_author,
recipient=user.user,
Expand Down

0 comments on commit d0f73bf

Please sign in to comment.