-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmodels.py
More file actions
65 lines (56 loc) · 1.89 KB
/
models.py
File metadata and controls
65 lines (56 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from textwrap import dedent
from django.contrib.auth import get_user_model
from django.db import models
from courses.models import Section
class Schedule(models.Model):
"""
Used to save schedules created by users on PCP
"""
person = models.ForeignKey(
get_user_model(),
on_delete=models.CASCADE,
help_text="The person (user) to which the schedule belongs.",
)
sections = models.ManyToManyField(
Section,
help_text=dedent(
"""
The class sections which comprise the schedule. The semester of each of these sections is
assumed to match the semester defined by the semester field below.
"""
),
)
semester = models.CharField(
max_length=5,
help_text=dedent(
"""
The academic semester planned out by the schedule (of the form YYYYx where x is A
[for spring], B [summer], or C [fall]), e.g. `2019C` for fall 2019.
"""
),
)
name = models.CharField(
max_length=255,
help_text=dedent(
"""
The user's nick-name for the schedule. No two schedules can match in all of the fields
`[name, semester, person]`
"""
),
)
advanced_registration = models.BooleanField(
blank=False,
default=False,
help_text=dedent(
"""
A label to denote whether the user's schedule was made for advanced registration.
"""
),
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
unique_together = (("name", "semester", "person"),)
unique_together = (("name", "semester", "person", "advanced_registration"), ("semester", "person", "advanced_registration"))
def __str__(self):
return "User: %s, Schedule ID: %s" % (self.person, self.id)