Skip to content

Commit

Permalink
Add degree plan unique constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
AaDalal committed Nov 11, 2023
1 parent 2533d0b commit 707ef16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/degree/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.contrib import admin
from degree.models import *

# Register your models here.
admin.site.register(DegreePlan)
admin.site.register(Rule)
5 changes: 5 additions & 0 deletions backend/degree/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class DegreePlan(models.Model):
)
)

class Meta:
constraints = [
models.UniqueConstraint(fields=['year', 'program', 'major', 'concentration'], name='unique degreeplan')
]

def __str__(self) -> str:
return f"{self.program} {self.degree} in {self.major} with conc. {self.concentration} ({self.year})"

Expand Down

0 comments on commit 707ef16

Please sign in to comment.