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

Delete submission creation event(NEW SUBMISSION) on submission deletion #3445

Merged
merged 2 commits into from
Aug 31, 2023
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
6 changes: 5 additions & 1 deletion hypha/apply/funds/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.http import HttpRequest

from hypha.apply.activity.messaging import MESSAGES, messenger
from hypha.apply.activity.models import Activity
from hypha.apply.activity.models import Activity, Event
from hypha.apply.funds.models.assigned_reviewers import AssignedReviewers
from hypha.apply.funds.workflow import INITIAL_STATE
from hypha.apply.review.options import DISAGREE, MAYBE
Expand Down Expand Up @@ -58,6 +58,10 @@ def bulk_delete_submissions(
Returns:
QuerySet of submissions that have been archived
"""
# delete NEW_SUBMISSION events for all submissions
submission_ids = submissions.values_list('id', flat=True)
Event.objects.filter(type=MESSAGES.NEW_SUBMISSION, object_id__in=submission_ids).delete()
# delete submissions
submissions.delete()
messenger(
MESSAGES.BATCH_DELETE_SUBMISSION,
Expand Down
4 changes: 4 additions & 0 deletions hypha/apply/funds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from wagtail.models import Page

from hypha.apply.activity.messaging import MESSAGES, messenger
from hypha.apply.activity.models import Event
from hypha.apply.activity.views import (
ActivityContextMixin,
CommentFormView,
Expand Down Expand Up @@ -1411,6 +1412,9 @@ def delete(self, request, *args, **kwargs):
request=request,
source=submission,
)
# delete NEW_SUBMISSION event for this particular submission
Event.objects.filter(type=MESSAGES.NEW_SUBMISSION, object_id=submission.id).delete()
# delete submission
response = super().delete(request, *args, **kwargs)
return response

Expand Down