Skip to content

Commit

Permalink
fix: accidental delets with solution submission form
Browse files Browse the repository at this point in the history
  • Loading branch information
xaralis committed Jan 11, 2021
1 parent c7d6611 commit 7231796
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
17 changes: 5 additions & 12 deletions ksicht/core/views/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@
from ksicht import pdf
from ksicht.pdf import ensure_file_valid
from .. import forms
from ..models import (
Grade,
GradeApplication,
GradeSeries,
Participant,
Sticker,
Task,
TaskSolutionSubmission,
)
from ..models import Grade, GradeApplication, GradeSeries, Participant, Sticker, Task, TaskSolutionSubmission
from .decorators import current_grade_exists, is_participant


Expand Down Expand Up @@ -173,7 +165,8 @@ def get_form_kwargs(self):
submission_map[participant.user_id][task.id] = None

for s in TaskSolutionSubmission.objects.filter(
application__grade=self.grade
application__grade=self.grade,
task__series=self.series,
).select_related("task", "application"):
submission_map[s.application.participant_id][s.task.id] = s

Expand Down Expand Up @@ -207,7 +200,8 @@ def _build_initial(participant):

def form_valid(self, form):
submissions = TaskSolutionSubmission.objects.filter(
application__grade=self.grade
application__grade=self.grade,
task__series=self.series,
)
applications = GradeApplication.objects.filter(grade=self.grade)

Expand Down Expand Up @@ -235,7 +229,6 @@ def form_valid(self, form):
overdue_submissions = saved_submissions - desired_submissions

to_create = []
to_remove = []

# Handle submissions to create
for s in missing_submissions:
Expand Down
17 changes: 2 additions & 15 deletions ksicht/forms.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
from crispy_forms.helper import FormHelper
from cuser.forms import AuthenticationForm, UserChangeForm, UserCreationForm
from django import forms
from django.contrib.auth.forms import (
PasswordChangeForm,
PasswordResetForm,
SetPasswordForm,
)
from django.contrib.auth.forms import PasswordChangeForm, PasswordResetForm, SetPasswordForm
from django.core import validators
from django_registration import validators as reg_validators
import pydash as py_
from webpack_loader.templatetags.webpack_loader import webpack_static

from ksicht.bulma.layout import (
Column,
Field,
FormActions,
FormControl,
Layout,
Link,
Row,
Submit,
)
from ksicht.bulma.layout import Column, Field, FormActions, FormControl, Layout, Link, Row, Submit
from ksicht.core import constants
from ksicht.core.models import Grade, Participant, User

Expand Down

0 comments on commit 7231796

Please sign in to comment.