PageRenderTime 32ms CodeModel.GetById 8ms app.highlight 9ms RepoModel.GetById 13ms app.codeStats 0ms

/tests/regressiontests/admin_widgets/models.py

https://code.google.com/p/mango-py/
Python | 69 lines | 49 code | 16 blank | 4 comment | 0 complexity | 262ea4668b04f3df9524c9549922817d MD5 | raw file
 1from django.db import models
 2from django.contrib.auth.models import User
 3
 4
 5class MyFileField(models.FileField):
 6    pass
 7
 8class Member(models.Model):
 9    name = models.CharField(max_length=100)
10    birthdate = models.DateTimeField(blank=True, null=True)
11    gender = models.CharField(max_length=1, blank=True, choices=[('M','Male'), ('F', 'Female')])
12
13    def __unicode__(self):
14        return self.name
15
16class Band(models.Model):
17    name = models.CharField(max_length=100)
18    members = models.ManyToManyField(Member)
19
20    def __unicode__(self):
21        return self.name
22
23class Album(models.Model):
24    band = models.ForeignKey(Band)
25    name = models.CharField(max_length=100)
26    cover_art = models.FileField(upload_to='albums')
27    backside_art = MyFileField(upload_to='albums_back', null=True)
28
29    def __unicode__(self):
30        return self.name
31
32class HiddenInventoryManager(models.Manager):
33    def get_query_set(self):
34        return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False)
35
36class Inventory(models.Model):
37   barcode = models.PositiveIntegerField(unique=True)
38   parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
39   name = models.CharField(blank=False, max_length=20)
40   hidden = models.BooleanField(default=False)
41
42   # see #9258
43   default_manager = models.Manager()
44   objects = HiddenInventoryManager()
45
46   def __unicode__(self):
47      return self.name
48
49class Event(models.Model):
50    band = models.ForeignKey(Band, limit_choices_to=models.Q(pk__gt=0))
51    start_date = models.DateField(blank=True, null=True)
52    start_time = models.TimeField(blank=True, null=True)
53    description = models.TextField(blank=True)
54    link = models.URLField(blank=True)
55    min_age = models.IntegerField(blank=True, null=True)
56
57class Car(models.Model):
58    owner = models.ForeignKey(User)
59    make = models.CharField(max_length=30)
60    model = models.CharField(max_length=30)
61
62    def __unicode__(self):
63        return u"%s %s" % (self.make, self.model)
64
65class CarTire(models.Model):
66    """
67    A single car tire. This to test that a user can only select their own cars.
68    """
69    car = models.ForeignKey(Car)