Skip to content

Commit

Permalink
refactor(dash)!: enforce uniqueness pset
Browse files Browse the repository at this point in the history
Add the constraint unique_together = ("student", "unit") at a database
level
  • Loading branch information
vEnhance committed Sep 12, 2023
1 parent df5f5b6 commit 8d04f99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dashboard/migrations/0087_alter_pset_unique_together.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.5 on 2023-09-12 01:43

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("roster", "0103_alter_assistant_user_alter_invoice_created_at_and_more"),
("core", "0057_userprofile_show_portal_instructions"),
("dashboard", "0086_alter_uploadedfile_created_at"),
]

operations = [
migrations.AlterUniqueTogether(
name="pset",
unique_together={("student", "unit")},
),
]
1 change: 1 addition & 0 deletions dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class PSet(models.Model):
class Meta:
verbose_name = "PSet submission"
verbose_name_plural = "PSet submissions"
unique_together = ("student", "unit")

def __str__(self):
return f"{self.student.name} submits {self.unit}"
Expand Down

0 comments on commit 8d04f99

Please sign in to comment.