models.py 1.01 KB
Newer Older
1
from django.db import models
Daniel W Bond's avatar
Daniel W Bond committed
2
from django.contrib.auth.models import User
3
from autoslug import AutoSlugField
4
5
6
from model_utils.models import TimeStampedModel
from django.core.validators import RegexValidator

7
class Student(TimeStampedModel):
8
    user = models.OneToOneField(User)
9
    # django user includes username, password, first name, and last name
Daniel W Bond's avatar
Daniel W Bond committed
10
11
12

# implement ratings later
#    rating = models.IntegerField(null=True,default=0)
13

14
    slug = AutoSlugField(populate_from='user', unique=True)
Daniel W Bond's avatar
Daniel W Bond committed
15
    # populate from user.username, no?
16

Daniel W Bond's avatar
Daniel W Bond committed
17
18
    # needs a get_absolute_url ?

19
20
    def __unicode__(self):
        return '%s' % self.user.username
21

22
23
24
class Course(TimeStampedModel):
	name = models.CharField(max_length=255)
	department = models.CharField(max_length=255)
25
26
27
        departmentAbbreviation = models.CharField(max_length=4)
	#number = models.CharField(max_length=255, validators=RegexValidator('[0-9]{3,}'))
	number = models.CharField(max_length=3)
28
29

	def __unicode__(self):
30
		return "%s:%s  %s", self.department, self.number, self.name