Skip to content

Commit

Permalink
Feat: Add Forum Page in Discussion Backend (Views, urls, services)
Browse files Browse the repository at this point in the history
  • Loading branch information
frclba committed Jun 30, 2020
1 parent 9a19ec1 commit 64dc2da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions discussion/static/js/discussion-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
{'id' : '@id'},
{'update': {'method': 'PUT'} });
}]);

app.factory('ForumPage', ['$resource', function($resource){
return $resource('/discussion/api/forum_page/:id',
{'id' : '@id'},
{'update': {'method': 'PUT'} });
}]);


app.factory('Topic', ['$resource', function($resource){
return $resource('/discussion/api/topic/:id',
Expand Down
3 changes: 2 additions & 1 deletion discussion/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ContentFileViewSet, ForumCreateView, ForumDeleteView, ForumFileViewSet,
ForumListView, ForumSearchViewSet, ForumUpdateView, ForumView, ForumViewSet,
TagViewSet, TopicFileViewSet, TopicLikeViewSet, TopicNotificationViewSet,
TopicPageViewSet, TopicReadViewSet, TopicTypeaheadViewSet, TopicViewSet
TopicPageViewSet, TopicReadViewSet, TopicTypeaheadViewSet, TopicViewSet, ForumPageViewSet
)

from rest_framework import routers
Expand All @@ -19,6 +19,7 @@
router = routers.SimpleRouter(trailing_slash=False)
router.register(r'category', CategoryViewSet)
router.register(r'forum', ForumViewSet)
router.register(r'forum_page', ForumPageViewSet)
router.register(r'topic', TopicViewSet)
router.register(r'topic_page', TopicPageViewSet)
router.register(r'comment', CommentViewSet)
Expand Down
8 changes: 8 additions & 0 deletions discussion/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ def perform_create(self, serializer):
def perform_update(self, serializer):
serializer.save(author=self.request.user)

class ForumPagination(PageNumberPagination):
page_size = 2
page_size_query_param = 'page_size'
max_page_size = 50

class ForumPageViewSet(ForumViewSet):
pagination_class = ForumPagination


class ForumSearchViewSet(viewsets.ReadOnlyModelViewSet):
"""
Expand Down

0 comments on commit 64dc2da

Please sign in to comment.