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

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Seller( models.Model ):

    user = models.OneToOneField(User)
    #    name = models.CharField(max_length = 200, primary_key=True)
    #    username = models.CharField(max_length = 200)
    #    email = models.CharField(max_length = 200)
    rating = models.IntegerField(null=True,default=0)

    # object call
    def __unicode__(self):
        return '%s' % self.user

    def get_absolute_url(self):
        from django.core.urlresolvers import reverse
        return reverse('profile', args=[self.user.username])

def create_user_profile(sender, instance, created, **kwargs):
    if created:
        Seller.objects.create(user=instance)

Daniel W Bond's avatar
Daniel W Bond committed
27
#post_save.connect(create_user_profile, sender=User)
28

29
30
31
class Course(TimeStampedModel):
	name = models.CharField(max_length=255)
	department = models.CharField(max_length=255)
32
33
34
        departmentAbbreviation = models.CharField(max_length=4)
	#number = models.CharField(max_length=255, validators=RegexValidator('[0-9]{3,}'))
	number = models.CharField(max_length=3)
35
36

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