Skip to content

Commit

Permalink
remove archived field from application submissions (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
rm03 authored Feb 3, 2024
1 parent f75e38a commit aca8e47
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 38 deletions.
3 changes: 1 addition & 2 deletions backend/clubs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ class ZoomMeetingVisitAdmin(admin.ModelAdmin):


class ApplicationSubmissionAdmin(admin.ModelAdmin):
list_display = ("user", "id", "created_at", "status", "archived")
list_filter = ("archived",)
list_display = ("user", "id", "created_at", "status")


admin.site.register(Asset)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.2.18 on 2024-02-03 22:21

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("clubs", "0094_applicationcycle_release_date"),
]

operations = [
migrations.RemoveField(model_name="applicationsubmission", name="archived",),
]
1 change: 0 additions & 1 deletion backend/clubs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,6 @@ class ApplicationSubmission(models.Model):
on_delete=models.SET_NULL,
null=True,
)
archived = models.BooleanField(default=False)
notified = models.BooleanField(default=False)

created_at = models.DateTimeField(auto_now_add=True)
Expand Down
36 changes: 7 additions & 29 deletions backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4445,7 +4445,6 @@ def question_response(self, *args, **kwargs):
user=self.request.user,
committee__isnull=False,
application=application,
archived=False,
)
.values_list("committee__name", flat=True)
.distinct()
Expand Down Expand Up @@ -4480,10 +4479,7 @@ def question_response(self, *args, **kwargs):
}
)
submission, _ = ApplicationSubmission.objects.get_or_create(
user=self.request.user,
application=application,
committee=committee,
archived=False,
user=self.request.user, application=application, committee=committee,
)

key = f"applicationsubmissions:{application.id}"
Expand Down Expand Up @@ -4592,9 +4588,7 @@ def questions(self, *args, **kwargs):

response = (
ApplicationQuestionResponse.objects.filter(
question=question,
submission__user=self.request.user,
submission__archived=False,
question=question, submission__user=self.request.user,
)
.select_related("submission", "multiple_choice", "question")
.prefetch_related("question__committees", "question__multiple_choice")
Expand Down Expand Up @@ -4707,7 +4701,7 @@ def send_emails(self, *args, **kwargs):

# Query for recent submissions with user and committee joined
submissions = ApplicationSubmission.objects.filter(
application=app, archived=False,
application=app
).select_related("user", "committee")

dry_run = self.request.data.get("dry_run")
Expand Down Expand Up @@ -5168,9 +5162,7 @@ def get_operation_id(self, **kwargs):

def get_queryset(self):
return (
ApplicationSubmission.objects.filter(
application__is_wharton_council=True, archived=False,
)
ApplicationSubmission.objects.filter(application__is_wharton_council=True)
.annotate(
annotated_name=F("application__name"),
annotated_committee=F("committee__name"),
Expand Down Expand Up @@ -5212,7 +5204,7 @@ class ApplicationSubmissionViewSet(viewsets.ModelViewSet):
def get_queryset(self):
app_id = self.kwargs["application_pk"]
submissions = (
ApplicationSubmission.objects.filter(application=app_id, archived=False,)
ApplicationSubmission.objects.filter(application=app_id)
.select_related("user__profile", "committee", "application__club")
.prefetch_related(
Prefetch(
Expand Down Expand Up @@ -5277,7 +5269,7 @@ def export(self, *args, **kwargs):
"""
app_id = int(self.kwargs["application_pk"])
data = (
ApplicationSubmission.objects.filter(application=app_id, archived=False,)
ApplicationSubmission.objects.filter(application=app_id)
.select_related("user__profile", "committee", "application__club")
.prefetch_related(
Prefetch(
Expand Down Expand Up @@ -5322,7 +5314,6 @@ def exportall(self, *args, **kwargs):
ApplicationSubmission.objects.filter(
application__is_wharton_council=True,
application__application_cycle=cycle,
archived=False,
)
.select_related("application", "application__application_cycle")
.annotate(
Expand Down Expand Up @@ -5475,9 +5466,7 @@ class ApplicationSubmissionUserViewSet(viewsets.ModelViewSet):

def get_queryset(self):
submissions = (
ApplicationSubmission.objects.filter(
user=self.request.user, archived=False,
)
ApplicationSubmission.objects.filter(user=self.request.user)
.select_related("user__profile", "committee", "application__club")
.prefetch_related(
Prefetch(
Expand All @@ -5492,17 +5481,6 @@ def get_queryset(self):
)
return submissions

def perform_destroy(self, instance):
"""
Set archived boolean to be True so that the submissions
appears to have been deleted
"""

instance.archived = True
instance.archived_by = self.request.user
instance.archived_on = timezone.now()
instance.save()


class ApplicationQuestionViewSet(viewsets.ModelViewSet):
"""
Expand Down
18 changes: 12 additions & 6 deletions frontend/components/Submissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,18 @@ function SubmissionsPage({
<button
onClick={(e) => {
e.stopPropagation()
doApiRequest(`/submissions/${submission.pk}/?format=json`, {
method: 'DELETE',
})
setSubmissions(
submissions.filter((submission) => submission.pk !== id),
)
if (
confirm(
'Are you sure you want to permanently delete this submission?',
)
) {
doApiRequest(`/submissions/${submission.pk}/?format=json`, {
method: 'DELETE',
})
setSubmissions(
submissions.filter((submission) => submission.pk !== id),
)
}
}}
className="button is-danger is-small ml-3"
>
Expand Down

0 comments on commit aca8e47

Please sign in to comment.