-
-
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.
Templated routes/views to be fulfilled. Added dotenv functionality. U…
…pdated requirements.
- Loading branch information
1 parent
37b589a
commit 7afe104
Showing
22 changed files
with
301 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
*/__pycache__/ | ||
|
||
/books | ||
/covers |
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
Binary file modified
BIN
+4.31 KB
(330%)
alttextbackend/views/__pycache__/books_bookid.cpython-311.pyc
Binary file not shown.
Binary file modified
BIN
+747 Bytes
(150%)
alttextbackend/views/__pycache__/books_bookid_export.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+751 Bytes
(150%)
alttextbackend/views/__pycache__/books_bookid_images.cpython-311.pyc
Binary file not shown.
Binary file modified
BIN
+3.05 KB
(270%)
alttextbackend/views/__pycache__/books_bookid_src.cpython-311.pyc
Binary file not shown.
Binary file modified
BIN
+728 Bytes
(150%)
alttextbackend/views/__pycache__/images_hash.cpython-311.pyc
Binary file not shown.
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,74 @@ | ||
from rest_framework.views import APIView | ||
from rest_framework.response import Response | ||
from rest_framework import status, permissions, serializers | ||
from rest_framework.exceptions import ValidationError | ||
from rest_framework.parsers import FormParser, MultiPartParser | ||
from django.core.files.storage import default_storage | ||
from django.core.files.base import ContentFile | ||
from uuid import uuid4 | ||
|
||
class GetImageBySrc(serializers.Serializer): | ||
bookid = serializers.CharField(required=True) | ||
src = serializers.CharField(required=True) | ||
|
||
class UpdateImageBySrc(serializers.Serializer): | ||
bookid = serializers.CharField(required=True) | ||
src = serializers.CharField(required=True) | ||
alt = serializers.CharField(required=True) | ||
beforeContext = serializers.CharField(required=False) | ||
afterContext = serializers.CharField(required=False) | ||
|
||
class AnalyzeImageBySrc(serializers.Serializer): | ||
bookid = serializers.CharField(required=True) | ||
src = serializers.CharField(required=True) | ||
|
||
class BooksBookidImageView(APIView): | ||
parser_classes = (FormParser, MultiPartParser) | ||
def get_serializer_class(self): | ||
if self.request.method == 'GET': | ||
return GetImageBySrc | ||
elif self.request.method == 'PATCH': | ||
return UpdateImageBySrc | ||
elif self.request.method == 'PUT': | ||
return AnalyzeImageBySrc | ||
return super().get_serializer_class() | ||
|
||
def get(self, request, *args, **kwargs): | ||
serializer_class = self.get_serializer_class() | ||
data = request.query_params | ||
data['bookid'] = kwargs.get('bookid') | ||
serializer = serializer_class(data=data) | ||
if not serializer.is_valid(): | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
validated_data = serializer.validated_data | ||
|
||
# TODO: IMPLEMENT LOGIC | ||
|
||
return Response(validated_data, status=status.HTTP_200_OK) | ||
|
||
def patch(self, request, *args, **kwargs): | ||
serializer_class = self.get_serializer_class() | ||
data = request.data | ||
data.update(request.query_params) | ||
data['bookid'] = kwargs.get('bookid') | ||
serializer = serializer_class(data=data) | ||
if not serializer.is_valid(): | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
validated_data = serializer.validated_data | ||
|
||
# TODO: IMPLEMENT LOGIC | ||
|
||
return Response(validated_data, status=status.HTTP_200_OK) | ||
|
||
def put(self, request, *args, **kwargs): | ||
serializer_class = self.get_serializer_class() | ||
data = request.query_params | ||
data['bookid'] = kwargs.get('bookid') | ||
serializer = serializer_class(data=data) | ||
if not serializer.is_valid(): | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
validated_data = serializer.validated_data | ||
|
||
# TODO: IMPLEMENT LOGIC | ||
|
||
return Response(validated_data, status=status.HTTP_200_OK) |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.