models.py 1.72 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
13
14
15
16
17
18
19
20
21
22

class Program(BaseModel):

    isBA = models.BooleanField()
    # geneds are different if BA or BS 
   
    class Meta:
        ordering = ('name',)

    def __unicode__(self):
        return self.name

Daniel W Bond's avatar
Daniel W Bond committed
23
24
25
26
27
28
29
30
31
class Course(BaseModel):

    department = models.CharField(max_length = 5)
    courseNumber = models.CharField(max_length = 3)

    # available next semester?
    # CRN
    # section number
    
32
33
    # Course may need Program-specific information

Daniel W Bond's avatar
Daniel W Bond committed
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
66
67
68
69
70
71
72
73
74
75
76
77
    slug = models.SlugField(max_length = 50)

    # ordering
    prerequisites = models.ManyToManyField()
    corequisites = models.ManyToManyField()

    # 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