models.py 2.02 KB
Newer Older
Daniel Warren Bond's avatar
Daniel Warren Bond committed
1
2
from django.db import models

Daniel W Bond's avatar
Daniel W Bond committed
3
4
5
6
7
8
9
10
class BaseModel(models.Model):
    created = models.DateTimeField('Created', auto_now_add=True, editable=False)_
    last_modified = models.DateTimeField('Last Modified', auto_now=True)
    name = models.CharField(max_length = 100)

    class Meta:
        abstract = True

11
12
class Program(BaseModel):

Daniel W Bond's avatar
Daniel W Bond committed
13
14
15
16
17
18
19
20
21
22
    # major or minor or gened
    programType = models.CharField()

    # is BA, there are these geneds, if BA, those
    degreeType = models.CharField()

    # unless they're in the honors program
    # and then there are separate geneds
    honors = models.BooleanField()

23
24
25
26
27
28
    class Meta:
        ordering = ('name',)

    def __unicode__(self):
        return self.name

Daniel W Bond's avatar
Daniel W Bond committed
29
30
class Course(BaseModel):

Daniel W Bond's avatar
Daniel W Bond committed
31
32
33
34
35
36
37
    # ordering
    prerequisites = models.ManyToManyField()
    corequisites = models.ManyToManyField()

    # basic course information
    department = models.CharField(max_length = 150)
    departmentAbbr = models.CharField(max_length = 5)
Daniel W Bond's avatar
Daniel W Bond committed
38
39
40
41
42
    courseNumber = models.CharField(max_length = 3)

    # available next semester?
    # CRN
    # section number
Daniel W Bond's avatar
Daniel W Bond committed
43
    # professor
Daniel W Bond's avatar
Daniel W Bond committed
44
    
Daniel W Bond's avatar
Daniel W Bond committed
45
    # Course may need program-specific information
46

Daniel W Bond's avatar
Daniel W Bond committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    slug = models.SlugField(max_length = 50)

    # default sorting order in admin
    class Meta:
        ordering = ('name',)

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return '/courses/%s/' % self.slug

class Trajectory(BaseModel):

    # Unsure how to represent this 

    # Kind of want to overwrite "name" as optional

    # Takes courses
    potentialTrajectory = models.ManyToManyField()

    def get_absolute_url(self):
        return 'my-trajectories/%s/' % self.slug

# should inherit from the standard Django User Model
class Student(BaseModel):

    alreadyTaken = models.ManyToManyField()
    trajectory = models.ManyToField()

    slug = models.SlugField(max_length = 50)

    class Meta:
        ordering = ('name',)

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return '/%s/' % self.slug