-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ft(user-read-stat):Get the articles read by user
- user should be able to see the articles they have read - write tests for the funcionality [Delivers #162948931]
- Loading branch information
Erastus Ruiru
authored and
Erastus Ruiru
committed
Feb 4, 2019
1 parent
bf61254
commit 32a8a3a
Showing
15 changed files
with
401 additions
and
10 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
Empty file.
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,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ReadingStartsConfig(AppConfig): | ||
name = 'reading_starts' |
Empty file.
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,20 @@ | ||
from django.db import models | ||
|
||
from authors.apps.authentication.models import User | ||
from authors.apps.articles.models import Article | ||
|
||
|
||
class ReadStats(models.Model): | ||
""" | ||
The model for user read starts | ||
""" | ||
user = models.ForeignKey( | ||
User, on_delete=models.CASCADE, null=False, blank=False) | ||
article = models.ForeignKey( | ||
Article, on_delete=models.CASCADE, null=False, blank=False) | ||
article_read = models.BooleanField(default=False) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
|
||
def __str__(self): | ||
return self.article.title |
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,22 @@ | ||
from rest_framework import serializers | ||
|
||
from .models import ReadStats | ||
|
||
|
||
class ReadStatsSerializers(serializers.ModelSerializer): | ||
"""" | ||
Serializer class for our ReadStats model | ||
""" | ||
|
||
article = serializers.SerializerMethodField() | ||
|
||
class Meta: | ||
model = ReadStats | ||
|
||
fields = '__all__' | ||
|
||
def get_article(self, stats): | ||
return { | ||
"article": stats.article.title, | ||
"slug": stats.article.slug | ||
} |
Empty file.
Oops, something went wrong.