Skip to content

Commit

Permalink
Fix typo and code style
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed Jan 12, 2017
1 parent 8f79f69 commit 22f9583
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cadasta/xforms/mixins/model_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _check_perm(self, user, project):
roles = [superuser, org_admin, prj_manager, data_collector]
assigned_policies = user.assigned_policies()
if not any(role in assigned_policies for role in roles):
raise PermissionDenied(_("You don't have permission do contribute"
raise PermissionDenied(_("You don't have permission to contribute"
" data to this project."))

def create_models(self, data, user):
Expand Down
2 changes: 1 addition & 1 deletion cadasta/xforms/tests/test_views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def test_unauthorized_user(self):
response = self.request(method='POST', post_data=data, user=user,
content_type='multipart/form-data')
assert response.status_code == 403
assert ("You don't have permission do contribute data to this project."
assert ("You don't have permission to contribute data to this project."
in response.content)

def test_questionnaire_not_found(self):
Expand Down
10 changes: 6 additions & 4 deletions cadasta/xforms/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def create(self, request, *args, **kwargs):
instance = ModelHelper().upload_submission_data(request)
except InvalidXMLSubmission as e:
logger.debug(str(e))
return self._sendErrorResponse(request, e, 'HTTP_400_BAD_REQUEST')
return self._sendErrorResponse(request, e,
status.HTTP_400_BAD_REQUEST)
except PermissionDenied as e:
return self._sendErrorResponse(request, e, 'HTTP_403_FORBIDDEN')
return self._sendErrorResponse(request, e,
status.HTTP_403_FORBIDDEN)

# If an already existing XFormSummission is sent back
# don't create another.
Expand Down Expand Up @@ -88,12 +90,12 @@ def create(self, request, *args, **kwargs):
content_type='application/xml'
)

def _sendErrorResponse(self, request, e, code):
def _sendErrorResponse(self, request, e, status):
message = _(OPEN_ROSA_ENVELOPE.format(message=str(e)))
headers = self.get_openrosa_headers(
request, location=False, content_length=False)
return Response(
message, status=getattr(status, code),
message, status=status,
headers=headers, content_type='application/xml'
)

Expand Down

0 comments on commit 22f9583

Please sign in to comment.