Skip to content
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

Fix submission deletion endpoint error #2060

Merged
merged 5 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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