Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
kbecker42 committed Mar 3, 2023
1 parent 9490cbc commit 72b951c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pybossa/api/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def _preprocess_post_data(self, data):

def _preprocess_request(self, request):
"""Method to be overridden by inheriting classes that will
perform preprocessong on the POST request"""
perform preprocessong on the POST and PUT request"""
pass

def _create_instance_from_request(self, data):
Expand Down
4 changes: 2 additions & 2 deletions pybossa/api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class ProjectAPI(APIBase):

def _preprocess_request(self, request):
# Limit maximum post data size.
content_length = request.content_length if request else None
content_length = request.content_length if request else 0
max_length_mb = current_app.config.get('TASK_PRESENTER_MAX_SIZE_MB', 2) if current_app and current_app.config else 0
max_length_bytes = max_length_mb * 1024 * 1024 # Maximum POST data size (MB)
if content_length is not None and max_length_bytes > 0 and content_length > max_length_bytes:
if content_length and max_length_bytes and content_length > max_length_bytes:
raise BadRequest('The task presenter/guidelines content exceeds ' +
str(max_length_mb) +
' MB. Please move large content to an external file.')
Expand Down
2 changes: 1 addition & 1 deletion pybossa/view/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def task_presenter_editor(short_name):
flash(gettext('Ooops! Only project owners can update.'),
'error')
errors = True
elif content_length is not None and content_length > max_length_bytes:
elif content_length and content_length > max_length_bytes:
flash(gettext('The task presenter/guidelines content exceeds ' + str(max_length_mb) +
' MB. Please move large content to an external file.'),
'error')
Expand Down

0 comments on commit 72b951c

Please sign in to comment.