Skip to content

Commit

Permalink
Merge 0aeb772 into b4242c0
Browse files Browse the repository at this point in the history
  • Loading branch information
kimbugp committed Oct 20, 2018
2 parents b4242c0 + 0aeb772 commit fc141bc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
17 changes: 17 additions & 0 deletions authors/apps/comments/migrations/0008_auto_20181020_1526.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.1.1 on 2018-10-20 12:26

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('comments', '0007_merge_20181017_1744'),
]

operations = [
migrations.AlterModelOptions(
name='comment',
options={'ordering': ['-created_at']},
),
]
14 changes: 9 additions & 5 deletions authors/apps/comments/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import models
from django.db.models.signals import post_save

from authors.apps.articles.models import Article,LikeArticle
from authors.apps.articles.models import Article, LikeArticle
from authors.apps.authentication.models import User

# Create your models here.
Expand All @@ -23,11 +23,14 @@ class Comment(models.Model):

created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
article_section=models.TextField(blank=True,null=True)
start_position=models.CharField(max_length=500,blank=True,null=True)
end_position=models.CharField(max_length=500,blank=True,null=True)
article_section = models.TextField(blank=True, null=True)
start_position = models.CharField(max_length=500, blank=True, null=True)
end_position = models.CharField(max_length=500, blank=True, null=True)
likes_count = models.IntegerField(default=0)


class Meta:
ordering = ['-created_at']

def children(self):
return Comment.objects.filter(parent=self)

Expand All @@ -51,6 +54,7 @@ def create_history(sender, **kwargs):

post_save.connect(create_history, sender=Comment)


class LikeComment(models.Model):
"""
This model is responsble for creating relationship between user
Expand Down
7 changes: 4 additions & 3 deletions authors/apps/comments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def get(self, request, *args, **kwargs):
slug = get_object_or_404(Article, slug=article_slug)
comment = self.queryset.filter(slug=article_slug)
serializer = self.serializer_class(comment, many=True)
return Response(serializer.data)
return self.list(request, *args, **kwargs)



class CommentsView(generics.RetrieveUpdateDestroyAPIView):
Expand Down Expand Up @@ -101,7 +102,7 @@ def get_object(self):
return get_object_or_404(queryset, **filter)


class CommentThreadListCreateView(generics.RetrieveAPIView):
class CommentThreadListCreateView(generics.ListCreateAPIView):
permission_classes = (IsAuthenticated,)
serializer_class = CommentChildSerializer
renderer_classes = (CommentThreadJSONRenderer,)
Expand All @@ -124,7 +125,7 @@ def get(self, request, *args, **kwargs):
comment = self.queryset.filter(
slug=article_slug, parent=self.kwargs['id'])
serializer = self.serializer_class(comment, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)
return self.list(request, *args, **kwargs)


class CommentHistoryView(generics.ListAPIView):
Expand Down

0 comments on commit fc141bc

Please sign in to comment.