Skip to content

Commit

Permalink
Merge pull request #2060 from onaio/2056-submission-deletion-error
Browse files Browse the repository at this point in the history
Fix submission deletion endpoint error
  • Loading branch information
DavisRayM authored Apr 30, 2021
2 parents a2406e1 + abec361 commit 709c31f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ecr-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
run: |
ssh-agent -a $SSH_AUTH_SOCK >> /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
ssh-keyscan github.com >> ~/.ssh/known_hosts
mkdir -p ~/.ssh
ssh-keyscan github.com > ~/.ssh/known_hosts
- name: Build and push
id: docker-build
Expand Down
6 changes: 3 additions & 3 deletions onadata/apps/api/tests/viewsets/test_data_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,9 +1439,9 @@ def test_delete_submission(self, send_message_mock):
self.assertEqual(first_xform_instance[0].deleted_by, request.user)
# message sent upon delete
self.assertTrue(send_message_mock.called)
send_message_mock.called_with(
[dataid], formid, XFORM,
request.user, SUBMISSION_DELETED)
send_message_mock.assert_called_with(
instance_id=dataid, target_id=formid, target_type=XFORM,
user=request.user, message_verb=SUBMISSION_DELETED)

# second delete of same submission should return 404
request = self.factory.delete('/', **self.extra)
Expand Down
3 changes: 2 additions & 1 deletion onadata/apps/api/viewsets/data_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,11 @@ def destroy(self, request, *args, **kwargs):

if request.user.has_perm(
CAN_DELETE_SUBMISSION, self.object.xform):
instance_id = self.object.pk
delete_instance(self.object, request.user)
# send message
send_message(
instance_id=self.object, target_id=self.object.xform.id,
instance_id=instance_id, target_id=self.object.xform.id,
target_type=XFORM, user=request.user,
message_verb=SUBMISSION_DELETED)
else:
Expand Down
4 changes: 0 additions & 4 deletions onadata/apps/logger/tests/models/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ def test_instance_json_updated_on_review(self):
self.assertEqual(SubmissionReview.APPROVED,
instance.json[u'_review_status'])
self.assertEqual(SubmissionReview.APPROVED, instance_review.status)
self.assertEqual(instance.date_created.strftime(MONGO_STRFTIME),
instance_review.date_created.strftime(MONGO_STRFTIME))
comment = instance_review.get_note_text()
self.assertEqual(None, comment)
self.assertTrue(instance.has_a_review)
Expand All @@ -273,8 +271,6 @@ def test_instance_json_updated_on_review(self):
self.assertEqual(SubmissionReview.APPROVED,
instance.json[u'_review_status'])
self.assertEqual(SubmissionReview.APPROVED, instance_review.status)
self.assertEqual(instance.date_created.strftime(MONGO_STRFTIME),
instance_review.date_created.strftime(MONGO_STRFTIME))
comment = instance_review.get_note_text()
self.assertEqual("Hey There", comment)
self.assertTrue(instance.has_a_review)
Expand Down
3 changes: 1 addition & 2 deletions onadata/apps/main/tests/test_form_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def test_api_jsonp(self):
start = callback.__len__() + 1
end = content.__len__() - 1
content = content[start: end]
d = dict_for_mongo_without_userform_id(
self.xform.instances.all()[0].parsed_instance)
d = self.xform.instances.all()[0].json
find_d = json.loads(content)[0]
self.assertEqual(find_d, d)

Expand Down

0 comments on commit 709c31f

Please sign in to comment.