-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:rkshaon/BookShelf into 124-add-bo…
…ok-upload-feature
- Loading branch information
Showing
10 changed files
with
99 additions
and
9 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from publisher_api.serializers.v1 import PublisherSerializer | ||
|
||
|
||
__all__ = [ | ||
'PublisherSerializer', | ||
] |
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,8 @@ | ||
from django.urls import path, include | ||
|
||
from publisher_api.urls.v1 import urlpatterns as v1 | ||
|
||
|
||
urlpatterns = [ | ||
path('v1/', include(v1)), | ||
] |
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,15 @@ | ||
# from django.urls import path | ||
from rest_framework.routers import DefaultRouter | ||
|
||
from publisher_api.views.v1 import PublisherViewSet | ||
|
||
|
||
router = DefaultRouter() | ||
|
||
|
||
router.register('', PublisherViewSet, basename='publishers') | ||
|
||
|
||
urlpatterns = [] | ||
|
||
urlpatterns += router.urls |
This file was deleted.
Oops, something went wrong.
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,60 @@ | ||
from rest_framework.response import Response | ||
from rest_framework.viewsets import ModelViewSet | ||
from rest_framework import status | ||
|
||
from BookShelf.utilities.permissions import IsAdminOrModerator | ||
|
||
from publisher_api.models import Publisher | ||
|
||
from publisher_api.serializers import PublisherSerializer | ||
|
||
|
||
class PublisherViewSet(ModelViewSet): | ||
queryset = Publisher.objects.filter(is_deleted=False) | ||
serializer_class = PublisherSerializer | ||
permission_classes = [ | ||
IsAdminOrModerator, | ||
] | ||
# authentication_classes = [TokenAuthentication] | ||
|
||
def perform_create(self, serializer): | ||
""" | ||
Custom logic when creating a book instance. | ||
""" | ||
serializer.save(added_by=self.request.user) | ||
|
||
def perform_update(self, serializer): | ||
""" | ||
Custom logic when updating a book instance. | ||
""" | ||
serializer.save(updated_by=self.request.user) | ||
|
||
def perform_destroy(self, instance): | ||
""" | ||
Custom logic when deleting a book instance. | ||
""" | ||
instance.is_deleted = True | ||
instance.save() | ||
|
||
def destroy(self, request, *args, **kwargs): | ||
""" | ||
Custom response after soft deleting an instance. | ||
""" | ||
instance = self.get_object() | ||
self.perform_destroy(instance) | ||
return Response( | ||
{"message": f"Publication '{instance.name}' has been successfully deleted."}, # noqa | ||
status=status.HTTP_200_OK, | ||
) | ||
|
||
# def get_queryset(self): | ||
# return Publisher.objects.all().order_by('name') | ||
|
||
# def get_serializer_class(self): | ||
# return PublisherSerializer | ||
|
||
# def get_permissions(self): | ||
# return [IsAuthenticatedOrReadOnly()] | ||
|
||
# def get_authentication_classes(self): | ||
# return [TokenAuthentication] |