Skip to content

Commit

Permalink
fix: no submissions before start (#440)
Browse files Browse the repository at this point in the history
* fix: no submissions before start

* chore: move project startdate

* chore: demo

* chore: demo

* chore: allow joining group after start

* chore: git merge
  • Loading branch information
Topvennie committed May 23, 2024
1 parent 62b897f commit 8091fdf
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 30 deletions.
17 changes: 13 additions & 4 deletions backend/api/fixtures/realistic/realistic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
visible: true
archived: false
locked_groups: false
start_date: 2024-12-12T00:00:00Z
start_date: 2023-12-12T00:00:00Z
deadline: 2025-01-01T00:00:00Z
max_score: 100
score_visible: false
Expand Down Expand Up @@ -134,9 +134,18 @@
project: 0
obligated_extensions:
- 0
blocked_extensions: []
blocked_extensions:
- 1
- model: api.structurecheck
pk: 1
fields:
path: "verslag/"
project: 0
obligated_extensions:
- 3
blocked_extensions: []
- model: api.structurecheck
pk: 2
fields:
path: src/
project: 1
Expand All @@ -145,15 +154,15 @@
blocked_extensions:
- 2
- model: api.structurecheck
pk: 2
pk: 3
fields:
path: verslag/
project: 1
obligated_extensions:
- 3
blocked_extensions: []
- model: api.structurecheck
pk: 3
pk: 4
fields:
path: ""
project: 3
Expand Down
44 changes: 24 additions & 20 deletions backend/api/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-15 19:49+0200\n"
"POT-Creation-Date: 2024-05-20 12:24+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -188,39 +188,43 @@ msgstr "The student is already in the group."
msgid "group.errors.not_present"
msgstr "The student is currently not in the group."

#: serializers/project_serializer.py:22
#: serializers/project_serializer.py:23
msgid "project.errors.invalid_instance"
msgstr "Error while parsing the provided zip."

#: serializers/project_serializer.py:81
#: serializers/project_serializer.py:122
msgid "project.errors.context"
msgstr "The project is not supplied in the context."

#: serializers/project_serializer.py:86
#: serializers/project_serializer.py:127
msgid "project.errors.start_date_in_past"
msgstr "The start date of the project lies in the past."

#: serializers/project_serializer.py:100
#: serializers/project_serializer.py:141
msgid "project.errors.deadline_before_start_date"
msgstr "The deadline of the project lies before the start date of the project."

#: serializers/project_serializer.py:142
#: serializers/project_serializer.py:183
msgid "project.errors.zip_structure"
msgstr "Error while parsing the provided zip."

#: serializers/submission_serializer.py:96 tests/test_submission.py:275
#: serializers/submission_serializer.py:98
msgid "project.error.submissions.project_not_started"
msgstr "The project hasn't started yet."

#: serializers/submission_serializer.py:102 tests/test_submission.py:275
msgid "project.error.submissions.past_project"
msgstr "The deadline of the project has already passed."

#: serializers/submission_serializer.py:99 tests/test_submission.py:346
#: serializers/submission_serializer.py:105 tests/test_submission.py:346
msgid "project.error.submissions.non_visible_project"
msgstr "The project is currently in a non-visible state."

#: serializers/submission_serializer.py:102 tests/test_submission.py:376
#: serializers/submission_serializer.py:108 tests/test_submission.py:376
msgid "project.error.submissions.archived_project"
msgstr "The project is archived."

#: serializers/submission_serializer.py:105
#: serializers/submission_serializer.py:111
msgid "project.error.submissions.no_files"
msgstr "The submission is empty."

Expand All @@ -236,39 +240,39 @@ msgstr "The teacher was successfully added."
msgid "teachers.success.destroy"
msgstr "The teacher was successfully destroyed."

#: views/course_view.py:137
#: views/course_view.py:136
msgid "courses.success.assistants.add"
msgstr "The assistant was successfully added to the course."

#: views/course_view.py:164
#: views/course_view.py:163
msgid "courses.success.assistants.remove"
msgstr "The assistant was successfully removed from the course."

#: views/course_view.py:226
#: views/course_view.py:225
msgid "courses.success.students.add"
msgstr "The student was successfully added to the course."

#: views/course_view.py:247
#: views/course_view.py:246
msgid "courses.success.students.remove"
msgstr "The student was successfully removed from the course."

#: views/course_view.py:292
#: views/course_view.py:291
msgid "courses.success.teachers.add"
msgstr "The teacher was successfully added to the course."

#: views/course_view.py:316
#: views/course_view.py:315
msgid "courses.success.teachers.remove"
msgstr "The teacher was successfully removed from the course."

#: views/group_view.py:74
#: views/group_view.py:73
msgid "group.success.students.add"
msgstr "The student was successfully added to the group."

#: views/group_view.py:94
#: views/group_view.py:93
msgid "group.success.students.remove"
msgstr "The student was successfully removed from the group."

#: views/group_view.py:113
#: views/group_view.py:112
msgid "group.success.submissions.add"
msgstr "The submission was successfully added to the group."

Expand Down Expand Up @@ -296,6 +300,6 @@ msgstr "No zip file available."
msgid "extra_check_result.download.log"
msgstr "No log file available."

#: views/submission_view.py:60
#: views/submission_view.py:59
msgid "extra_check_result.download.artifact"
msgstr "No artifact available."
5 changes: 5 additions & 0 deletions backend/api/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def deadline_passed(self):
now = timezone.now()
return now > self.deadline

def has_started(self):
"""Returns True if the project has started."""
now = timezone.now()
return now >= self.start_date

def is_archived(self):
"""Returns True if a project is archived."""
return self.archived
Expand Down
4 changes: 0 additions & 4 deletions backend/api/serializers/group_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ def validate(self, attrs):
group: Group = self.context["group"]
student: Student = attrs["student"]

# Make sure a student can't join if groups are locked
if group.project.is_groups_locked():
raise ValidationError(gettext("group.errors.locked"))

# Make sure the group is not already full
if group.is_full():
raise ValidationError(gettext("group.errors.full"))
Expand Down
3 changes: 3 additions & 0 deletions backend/api/serializers/submission_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def validate(self, attrs):
group: Group = self.context["group"]
project: Project = group.project

if not project.has_started():
raise ValidationError(_("project.error.submissions.project_not_started"))

# Check if the project's deadline is not passed.
if project.deadline_passed():
raise ValidationError(_("project.error.submissions.past_project"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ done

# Generate an artifact

wget https://golang.org/doc/gopher/modelsheet.jpg -P artifacts
wget https://upload.wikimedia.org/wikipedia/commons/5/5e/Logo_UGent_NL_RGB_2400_kleur-op-wit.png -P artifacts
1 change: 0 additions & 1 deletion development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ if [ "$data" != "" ]; then
docker-compose -f development.yml up -d backend redis celery

echo "Clearing, Migrating & Populating the database"
# We have nog fixtures for notification yet.
docker-compose -f development.yml run backend sh -c "python manage.py flush --no-input; python manage.py migrate; python manage.py loaddata notifications/fixtures/$data/*; python manage.py loaddata authentication/fixtures/$data/*; python manage.py loaddata api/fixtures/$data/*;"

echo "Stopping the services"
Expand Down

0 comments on commit 8091fdf

Please sign in to comment.