Skip to content

Commit

Permalink
166872275-bg(Notifications):Fix get notification status
Browse files Browse the repository at this point in the history
-Added endpoint for getting notification status

[starts #166872275]
  • Loading branch information
Philipotieno authored and Abraham Kamau committed Jun 24, 2019
1 parent 81403c9 commit ded6826
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
7 changes: 7 additions & 0 deletions authors/apps/appnotifications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def update(self, request, *args, **kwargs):
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)

def get(self, request, *args, **kwargs):
user = UserNotification.objects.get(user=request.user)
if user:
serializer = self.serializer_class(user, many=False)
print(serializer.data)
return Response(serializer.data, status=status.HTTP_200_OK)


class UnsubscribeEmailAPIView(GenericAPIView):
Expand Down
9 changes: 1 addition & 8 deletions authors/apps/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,8 @@ def ratings(self, article, user):
Model to display rating for users in an articles
"""

try:
article = self.article
user = self.rated_by
except Article.DoesNotExist:
pass

queryset = RatingModel.objects.filter(
article_id=article, rated_by_id=user).first()

article_id=article).first()
if queryset:
return {
"my_ratings": queryset.rate,
Expand Down
19 changes: 19 additions & 0 deletions authors/apps/profiles/migrations/0002_auto_20190620_0920.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2 on 2019-06-20 09:20

import cloudinary.models
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('profiles', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='profile',
name='image',
field=cloudinary.models.CloudinaryField(default='https://res.cloudinary.com/grean/image/upload/v1560445304/default_ddfimn.png', max_length=255, verbose_name='image'),
),
]

0 comments on commit ded6826

Please sign in to comment.