models.py 2.6 KB
Newer Older
1
from django.db import models
Daniel W Bond's avatar
Daniel W Bond committed
2 3 4
from autoslug import AutoSlugField
from model_utils.models import TimeStampedModel

5
from accounts.models import Student
6

7 8
from localflavor.us.models import USStateField

Daniel W Bond's avatar
Daniel W Bond committed
9
class Building(TimeStampedModel):
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
    name = models.CharField(max_length=100)

    NONE = 'na'
    AQUIA = 'aq'
    RAPPAHANNOCK = 'ra'
    SHENANDOAH = 'sh'
    NEIGHBOURHOOD_CHOICES = (
        (NONE, 'None'),
        (AQUIA, 'Aquia'),
        (RAPPAHANNOCK, 'Rappahannock'),
        (SHENANDOAH, 'Shenandoah'),
    )

    neighbourhood = models.CharField(max_length=100, choices=NEIGHBOURHOOD_CHOICES,
    default=NONE)
25 26 27 28 29 30 31 32 33 34 35 36 37
    #address = models.ForeignKey('Address')

    PRINCE_WILLIAM = 'pw'
    MASONVALE = 'mv'
    FAIRFAX = 'ff'
    CAMPUS_CHOICES = (
        (NONE, 'None'),
        (PRINCE_WILLIAM, 'Prince William'),
        (MASONVALE, 'mv'),
        (FAIRFAX, 'Fairfax'),
    )

    campus = models.CharField(max_length=100, choices=CAMPUS_CHOICES, default=NONE)
38

Daniel W Bond's avatar
Daniel W Bond committed
39 40
    slug = AutoSlugField(populate_from='name', unique=True)

41 42 43 44 45
    def __str__(self):              # __unicode__ on Python 2
        return self.name
    def __unicode__(self):              # __unicode__ on Python 2
        return unicode(self.name)

Daniel W Bond's avatar
Daniel W Bond committed
46
class Room(TimeStampedModel):
47 48
    number = models.IntegerField()
    floor = models.IntegerField()
49
    students = models.ManyToManyField(Student)
50 51
    building = models.ForeignKey('Building')

Daniel W Bond's avatar
Daniel W Bond committed
52 53
    slug = AutoSlugField(populate_from='number', unique=True)

54 55 56
    def __str__(self):              # __unicode__ on Python 2
        return self.building.__str__()+" "+self.number.__str__()

57 58
# buildings on campus don't have separate addresses yet
#class Address(TimeStampedModel):
Daniel W Bond's avatar
Daniel W Bond committed
59
    
60 61 62 63
#    street = models.CharField(max_length=120)
#    city = models.CharField(max_length=120)
#    state = USStateField()
#    zip_code = models.IntegerField(max_length=5)
64

65 66
#    class Meta: 
#        verbose_name_plural = 'addresses'
Daniel W Bond's avatar
Daniel W Bond committed
67

68 69
#    def __str__(self):              # __unicode__ on Python 2
#        return self.street
70

Daniel W Bond's avatar
Daniel W Bond committed
71
class Class(TimeStampedModel):
72 73 74 75 76 77 78 79 80 81 82 83 84 85
    year_int = models.IntegerField()
    FRESHMAN = 'FR'
    SOPHOMORE = 'SO'
    JUNIOR = 'JR'
    SENIOR = 'SR'
    YEAR_IN_SCHOOL_CHOICES = (
        (FRESHMAN, 'Freshman'),
        (SOPHOMORE, 'Sophomore'),
        (JUNIOR, 'Junior'),
        (SENIOR, 'Senior'),
    )
    year_in_school = models.CharField(max_length=2,
                                      choices=YEAR_IN_SCHOOL_CHOICES,
                                      default=FRESHMAN)
Daniel W Bond's avatar
Daniel W Bond committed
86 87 88
    class Meta: 
        verbose_name_plural = 'classes'

89
    def __str__(self):              # __unicode__ on Python 2
90
        return str(self.year_int)