models.py 2.47 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
11
12
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

class Course(BaseModel):

Daniel W Bond's avatar
Daniel W Bond committed
13
    # ordering
Daniel W Bond's avatar
Daniel W Bond committed
14
15
    prerequisites = models.ManyToManyField('Course')
    corequisites = models.ManyToManyField('Course')
Daniel W Bond's avatar
Daniel W Bond committed
16
17
18
19

    # basic course information
    department = models.CharField(max_length = 150)
    departmentAbbr = models.CharField(max_length = 5)
Daniel W Bond's avatar
Daniel W Bond committed
20
    courseNumber = models.CharField(max_length = 3)
21
22
    courseDescription = models.TextField()
    credits = models.IntegerField()
Daniel W Bond's avatar
Daniel W Bond committed
23
24
25
26

    # available next semester?
    # CRN
    # section number
Daniel W Bond's avatar
Daniel W Bond committed
27
    # professor
Daniel W Bond's avatar
Daniel W Bond committed
28
    
Daniel W Bond's avatar
Daniel W Bond committed
29
    # Course may need program-specific information
30

Daniel W Bond's avatar
Daniel W Bond committed
31
32
33
34
35
36
37
38
39
40
41
42
    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

Daniel W Bond's avatar
Daniel W Bond committed
43
44
45
46
47
# gen eds are coursecollections in programs
class CourseCollection(BaseModel):

    # a number of courses
    courses = ManyToManyField('Course')
Daniel W Bond's avatar
Daniel W Bond committed
48

Daniel W Bond's avatar
Daniel W Bond committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
    # how many of those are required
    numberOfCoursesReq = IntegerField()

class Program(BaseModel):

    # courseCollections
    courseReqs =  ManyToManyField('CourseCollection')

    # major or minor or gened
    programType = models.CharField()

    # is BA, BS, Honors
    degreeType = models.CharField()

    class Meta:
        ordering = ('name',)

    def __unicode__(self):
        return self.name

Daniel W Bond's avatar
Daniel W Bond committed
69
70
71
# should inherit from the standard Django User Model
class Student(BaseModel):

Daniel W Bond's avatar
Daniel W Bond committed
72
    alreadyTaken = models.ManyToManyField('Course')
73
74
75
    trajectory = models.ManyToField('Trajectory')

    # aka username, etc should all be here
Daniel W Bond's avatar
Daniel W Bond committed
76
77
78
79
80
81
82
83
84
85

    slug = models.SlugField(max_length = 50)

    class Meta:
        ordering = ('name',)

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

class Trajectory(BaseModel):

    # Kind of want to overwrite "name" as optional

    # Takes courses
    potentialTrajectory = models.ManyToManyField('Course')

    # this isn't exactly done correctly-- ideally courses should be elements
    # of a list, not one created for each and every semester
    semester = models.IntegerField()

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

       return '/%s/' % self.slug