-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#163463708 Add article image uploading #45
Conversation
authors/apps/articles/views.py
Outdated
|
||
except Exception as error: | ||
print("The error is : {}".format(error)) | ||
return Response({'error': 'I cant do that !!! '},status.HTTP_400_BAD_REQUEST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (89 > 79 characters)
missing whitespace after ','
authors/apps/articles/views.py
Outdated
},status.HTTP_200_OK) | ||
else: | ||
return Response({'error': 'Could not get file from posted data'},status.HTTP_404_NOT_FOUND) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
authors/apps/articles/views.py
Outdated
'link': result['secure_url'], | ||
},status.HTTP_200_OK) | ||
else: | ||
return Response({'error': 'Could not get file from posted data'},status.HTTP_404_NOT_FOUND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (107 > 79 characters)
missing whitespace after ','
authors/apps/articles/views.py
Outdated
return Response({ | ||
'success': 'file posted', | ||
'link': result['secure_url'], | ||
},status.HTTP_200_OK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
authors/apps/articles/views.py
Outdated
cloudinary.config( | ||
cloud_name = os.getenv('CLOUD_NAME'), | ||
api_key = os.getenv('API_KEY'), | ||
api_secret = os.getenv('API_SECRET') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line missing indentation or outdented
trailing whitespace
unexpected spaces around keyword / parameter equals
authors/apps/articles/views.py
Outdated
if request.method == 'POST' and request.FILES['image_file']: | ||
myfile = request.FILES['image_file'] | ||
|
||
cloudinary.config( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
authors/apps/articles/views.py
Outdated
try: | ||
if request.method == 'POST' and request.FILES['image_file']: | ||
myfile = request.FILES['image_file'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
authors/apps/articles/views.py
Outdated
|
||
class ImageUpload(APIView): | ||
serializer_class = ArticleSerializer | ||
"""Upload image to cloudinary""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
@@ -197,3 +203,28 @@ def delete(self, request, slug, **kwargs): | |||
logger.debug("Error is : ".format(what_now)) | |||
return Response({"message": "Could not find that article"}, | |||
status.HTTP_404_NOT_FOUND) | |||
|
|||
class ImageUpload(APIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
authors/apps/articles/views.py
Outdated
@@ -2,10 +2,16 @@ | |||
import random | |||
import readtime | |||
import uuid | |||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'json' imported but unused
4062056
to
9e435f0
Compare
authors/apps/articles/views.py
Outdated
|
||
except Exception as error: | ||
print("The error is : {}".format(error)) | ||
return Response({'error': 'I cant do that !!! '}, status.HTTP_400_BAD_REQUEST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (90 > 79 characters)
authors/apps/articles/views.py
Outdated
if request.method == 'POST' and request.FILES['image_file']: | ||
myfile = request.FILES['image_file'] | ||
cloudinary.config( | ||
cloud_name=os.getenv('CLOUD_NAME'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line missing indentation or outdented
9e435f0
to
1e742c6
Compare
authors/apps/articles/views.py
Outdated
}, status.HTTP_200_OK) | ||
else: | ||
return Response({'error': 'Could not get file from posted data'}, | ||
status.HTTP_404_NOT_FOUND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
authors/apps/articles/views.py
Outdated
'link': result['secure_url'], | ||
}, status.HTTP_200_OK) | ||
else: | ||
return Response({'error': 'Could not get file from posted data'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
1e742c6
to
2971054
Compare
except Exception as error: | ||
print("The error is : {}".format(error)) | ||
return Response({'error': 'I cant do that !!! '}, | ||
status.HTTP_400_BAD_REQUEST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
2971054
to
465c97d
Compare
- uploads image when user add it to the editor - show upload progress - parse and return image data as required by editor [Finishes #163463708]
465c97d
to
8ad33bf
Compare
@@ -2,10 +2,15 @@ | |||
import random | |||
import readtime | |||
import uuid | |||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'os' imported but unused
What does this PR do?
Add a view function for uploading the articles images to cloudinary
Description of Task to be completed?
Any image added to the article editor should be automatically uploaded and the return data should be in a particular format
Any background context you want to provide?
Cloudinary is an image and media files storage cloud service that allows for posting of images whose URLs can then be used to display them anywhere
What are the relevant pivotal tracker stories?
#163463708
Screenshots (if appropriate)
Questions:
Checklist: