-
Notifications
You must be signed in to change notification settings - Fork 12
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
RDISCROWD-5567 enhance task guidelines images #801
Conversation
Pull Request Test Coverage Report for Build 3959929636
💛 - Coveralls |
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.
The update to the themes pointer (static/..., templates/..., etc) would probably need to be done after the templates PR has been merged. This way, this PR can point to themes in the main branch.
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.
This looks good!
I'm wondering if we should consider avoiding increasing the size of the repo with the large binary image (14.8MB) in the unit test, with two options:
- Use a smaller image that is just over 5MB in size to trigger the error condition.
- Skip the large image upload and instead refactor the file size calculation into a separate method and mock this method to return True in the unit test, thus triggering the error condition without actually uploading a large image. preferable
In this case, the large image could then be deleted from the commit. Thank you.
Adding @XiChenn for comment as well.
I'm with Kory not to upload large files to the repo. How about using a a small file (~10k) for the "test_task_presenter_image_upload" and using Mock as Kory suggested to test this function "upload_task_guidelines_image" specifically with mock of large file? Some reference with "mock" could be found here. |
pybossa/view/projects.py
Outdated
file_size_mb = file.seek(0, os.SEEK_END) / 1024 / 1024 | ||
file.seek(0, os.SEEK_SET) | ||
file.filename = secure_filename(file.filename) | ||
if file_size_mb < 5: |
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.
How about putting the magic number "5" to the configuration (e.g. settings_local.py)? It will not only be easier for future changes, but also the unit test could be beneficial from it (you can configure a much smaller value for the unit test). It will add some one-time complexity for the code deployment. At minimum, we can consider use a const variable.
pybossa/view/projects.py
Outdated
current_app.config.get('AVATAR_ABSOLUTE') | ||
)) | ||
else: | ||
flash(gettext('File must be smaller than 5 MB.')) |
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.
Same here for the magic number.
pybossa/view/projects.py
Outdated
file_size_mb = file.seek(0, os.SEEK_END) / 1024 / 1024 | ||
file.seek(0, os.SEEK_SET) | ||
file.filename = secure_filename(file.filename) | ||
if file_size_mb < current_app.config.get('MAX_IMAGE_UPLOAD_SIZE_MB'): |
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.
It would be a good idea to also include a default value in case a dev does not have this setting. Otherwise, if the setting is missing, the upload will always fail.
current_app.config.get('MAX_IMAGE_UPLOAD_SIZE_MB', 5)
pybossa/view/projects.py
Outdated
current_app.config.get('AVATAR_ABSOLUTE') | ||
)) | ||
else: | ||
flash(gettext('File must be smaller than ' + str(current_app.config.get('MAX_IMAGE_UPLOAD_SIZE_MB')) + ' MB.')) |
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.
current_app.config.get('MAX_IMAGE_UPLOAD_SIZE_MB', 5)
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.
great job! Thank you
Re: bloomberg/pybossa-default-theme#386