2008-12-17 01:42:18 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-12-23 02:29:00 +08:00
|
|
|
import datetime
|
2009-04-19 04:29:55 +08:00
|
|
|
import tempfile
|
|
|
|
import os
|
2009-12-23 02:29:00 +08:00
|
|
|
|
|
|
|
from django.core.files.storage import FileSystemStorage
|
|
|
|
from django.db import models
|
2010-02-16 20:17:37 +08:00
|
|
|
from django import forms
|
2010-08-06 22:58:05 +08:00
|
|
|
from django.contrib.auth.models import User
|
2010-02-26 21:17:43 +08:00
|
|
|
from django.contrib.contenttypes import generic
|
|
|
|
from django.contrib.contenttypes.models import ContentType
|
2008-07-19 07:54:34 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
class Section(models.Model):
|
|
|
|
"""
|
2008-08-09 02:07:33 +08:00
|
|
|
A simple section that links to articles, to test linking to related items
|
2008-07-19 07:54:34 +08:00
|
|
|
in admin views.
|
|
|
|
"""
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
class Article(models.Model):
|
|
|
|
"""
|
|
|
|
A simple article to test admin views. Test backwards compatibility.
|
|
|
|
"""
|
2008-08-09 02:07:33 +08:00
|
|
|
title = models.CharField(max_length=100)
|
2008-07-19 07:54:34 +08:00
|
|
|
content = models.TextField()
|
|
|
|
date = models.DateTimeField()
|
2010-03-17 03:01:40 +08:00
|
|
|
section = models.ForeignKey(Section, null=True, blank=True)
|
2008-07-19 07:54:34 +08:00
|
|
|
|
2008-08-09 02:07:33 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
2009-03-10 19:19:26 +08:00
|
|
|
|
2008-10-08 22:47:01 +08:00
|
|
|
def model_year(self):
|
|
|
|
return self.date.year
|
|
|
|
model_year.admin_order_field = 'date'
|
2010-03-17 00:10:27 +08:00
|
|
|
model_year.short_description = ''
|
2008-10-08 22:47:01 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-12-16 23:04:47 +08:00
|
|
|
class Book(models.Model):
|
|
|
|
"""
|
|
|
|
A simple book that has chapters.
|
|
|
|
"""
|
2008-12-17 01:42:18 +08:00
|
|
|
name = models.CharField(max_length=100, verbose_name=u'¿Name?')
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-12-17 01:42:18 +08:00
|
|
|
class Promo(models.Model):
|
|
|
|
name = models.CharField(max_length=100, verbose_name=u'¿Name?')
|
|
|
|
book = models.ForeignKey(Book)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
2008-12-16 23:04:47 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-12-16 23:04:47 +08:00
|
|
|
class Chapter(models.Model):
|
2008-12-17 01:42:18 +08:00
|
|
|
title = models.CharField(max_length=100, verbose_name=u'¿Title?')
|
2008-12-16 23:04:47 +08:00
|
|
|
content = models.TextField()
|
|
|
|
book = models.ForeignKey(Book)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
|
|
|
|
2008-12-17 01:42:18 +08:00
|
|
|
class Meta:
|
2010-03-02 11:28:48 +08:00
|
|
|
# Use a utf-8 bytestring to ensure it works (see #11710)
|
|
|
|
verbose_name = '¿Chapter?'
|
2008-12-17 01:42:18 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-12-17 01:42:18 +08:00
|
|
|
class ChapterXtra1(models.Model):
|
|
|
|
chap = models.OneToOneField(Chapter, verbose_name=u'¿Chap?')
|
2009-03-10 19:19:26 +08:00
|
|
|
xtra = models.CharField(max_length=100, verbose_name=u'¿Xtra?')
|
2008-12-17 01:42:18 +08:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return u'¿Xtra1: %s' % self.xtra
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-12-17 01:42:18 +08:00
|
|
|
class ChapterXtra2(models.Model):
|
|
|
|
chap = models.OneToOneField(Chapter, verbose_name=u'¿Chap?')
|
2009-03-10 19:19:26 +08:00
|
|
|
xtra = models.CharField(max_length=100, verbose_name=u'¿Xtra?')
|
2008-12-17 01:42:18 +08:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return u'¿Xtra2: %s' % self.xtra
|
|
|
|
|
2010-11-22 03:00:40 +08:00
|
|
|
|
2011-02-19 22:05:07 +08:00
|
|
|
class RowLevelChangePermissionModel(models.Model):
|
|
|
|
name = models.CharField(max_length=100, blank=True)
|
|
|
|
|
2010-11-22 03:00:40 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
class CustomArticle(models.Model):
|
|
|
|
content = models.TextField()
|
|
|
|
date = models.DateTimeField()
|
|
|
|
|
|
|
|
|
|
|
|
class ModelWithStringPrimaryKey(models.Model):
|
|
|
|
id = models.CharField(max_length=255, primary_key=True)
|
2008-08-09 02:07:33 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.id
|
2008-08-09 02:07:33 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-10-22 03:03:21 +08:00
|
|
|
class Color(models.Model):
|
|
|
|
value = models.CharField(max_length=10)
|
2009-03-10 19:19:26 +08:00
|
|
|
warm = models.BooleanField()
|
2008-10-22 03:03:21 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.value
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2008-10-22 03:03:21 +08:00
|
|
|
class Thing(models.Model):
|
|
|
|
title = models.CharField(max_length=20)
|
|
|
|
color = models.ForeignKey(Color, limit_choices_to={'warm': True})
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
|
2011-01-28 22:08:25 +08:00
|
|
|
class Actor(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
age = models.IntegerField()
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2011-01-28 22:08:25 +08:00
|
|
|
class Inquisition(models.Model):
|
|
|
|
expected = models.BooleanField()
|
|
|
|
leader = models.ForeignKey(Actor)
|
2011-01-28 22:08:42 +08:00
|
|
|
country = models.CharField(max_length=20)
|
|
|
|
|
2011-01-28 22:08:25 +08:00
|
|
|
def __unicode__(self):
|
2011-01-28 22:08:42 +08:00
|
|
|
return u"by %s from %s" % (self.leader, self.country)
|
|
|
|
|
2011-01-28 22:08:25 +08:00
|
|
|
|
|
|
|
class Sketch(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
inquisition = models.ForeignKey(Inquisition, limit_choices_to={'leader__name': 'Palin',
|
|
|
|
'leader__age': 27,
|
2011-01-28 22:08:42 +08:00
|
|
|
'expected': False,
|
2011-01-28 22:08:25 +08:00
|
|
|
})
|
2011-01-28 22:08:42 +08:00
|
|
|
|
2011-01-28 22:08:25 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
|
|
|
|
2011-01-28 22:08:42 +08:00
|
|
|
|
2009-04-01 22:14:20 +08:00
|
|
|
class Fabric(models.Model):
|
|
|
|
NG_CHOICES = (
|
|
|
|
('Textured', (
|
|
|
|
('x', 'Horizontal'),
|
|
|
|
('y', 'Vertical'),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
('plain', 'Smooth'),
|
|
|
|
)
|
|
|
|
surface = models.CharField(max_length=20, choices=NG_CHOICES)
|
|
|
|
|
|
|
|
|
2009-03-18 04:51:47 +08:00
|
|
|
class Person(models.Model):
|
|
|
|
GENDER_CHOICES = (
|
|
|
|
(1, "Male"),
|
|
|
|
(2, "Female"),
|
|
|
|
)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
gender = models.IntegerField(choices=GENDER_CHOICES)
|
2011-01-03 21:56:31 +08:00
|
|
|
age = models.IntegerField(default=21)
|
2009-03-18 04:51:47 +08:00
|
|
|
alive = models.BooleanField()
|
2009-03-30 02:52:38 +08:00
|
|
|
|
2009-03-18 04:51:47 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
2009-03-30 02:52:38 +08:00
|
|
|
|
2010-02-16 20:17:37 +08:00
|
|
|
|
2009-03-10 19:19:26 +08:00
|
|
|
class Persona(models.Model):
|
|
|
|
"""
|
|
|
|
A simple persona associated with accounts, to test inlining of related
|
|
|
|
accounts which inherit from a common accounts class.
|
|
|
|
"""
|
|
|
|
name = models.CharField(blank=False, max_length=80)
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-03-10 19:19:26 +08:00
|
|
|
class Account(models.Model):
|
|
|
|
"""
|
|
|
|
A simple, generic account encapsulating the information shared by all
|
|
|
|
types of accounts.
|
|
|
|
"""
|
|
|
|
username = models.CharField(blank=False, max_length=80)
|
|
|
|
persona = models.ForeignKey(Persona, related_name="accounts")
|
|
|
|
servicename = u'generic service'
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return "%s: %s" % (self.servicename, self.username)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-03-10 19:19:26 +08:00
|
|
|
class FooAccount(Account):
|
|
|
|
"""A service-specific account of type Foo."""
|
|
|
|
servicename = u'foo'
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-03-10 19:19:26 +08:00
|
|
|
class BarAccount(Account):
|
|
|
|
"""A service-specific account of type Bar."""
|
|
|
|
servicename = u'bar'
|
|
|
|
|
|
|
|
|
2009-03-24 04:22:56 +08:00
|
|
|
class Subscriber(models.Model):
|
|
|
|
name = models.CharField(blank=False, max_length=80)
|
|
|
|
email = models.EmailField(blank=False, max_length=175)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return "%s (%s)" % (self.name, self.email)
|
|
|
|
|
|
|
|
|
|
|
|
class ExternalSubscriber(Subscriber):
|
|
|
|
pass
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-04-07 04:23:33 +08:00
|
|
|
class OldSubscriber(Subscriber):
|
|
|
|
pass
|
|
|
|
|
2009-03-18 04:51:47 +08:00
|
|
|
|
2009-03-30 02:52:38 +08:00
|
|
|
class Media(models.Model):
|
|
|
|
name = models.CharField(max_length=60)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-03-30 02:52:38 +08:00
|
|
|
class Podcast(Media):
|
|
|
|
release_date = models.DateField()
|
|
|
|
|
2011-06-03 00:18:47 +08:00
|
|
|
class Meta:
|
|
|
|
ordering = ('release_date',) # overridden in PodcastAdmin
|
|
|
|
|
2009-03-30 02:52:38 +08:00
|
|
|
|
2009-04-19 05:03:29 +08:00
|
|
|
class Vodcast(Media):
|
|
|
|
media = models.OneToOneField(Media, primary_key=True, parent_link=True)
|
|
|
|
released = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
|
2009-03-31 08:03:34 +08:00
|
|
|
class Parent(models.Model):
|
|
|
|
name = models.CharField(max_length=128)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-03-31 08:03:34 +08:00
|
|
|
class Child(models.Model):
|
|
|
|
parent = models.ForeignKey(Parent, editable=False)
|
|
|
|
name = models.CharField(max_length=30, blank=True)
|
|
|
|
|
|
|
|
|
2009-04-01 11:11:58 +08:00
|
|
|
class EmptyModel(models.Model):
|
|
|
|
def __unicode__(self):
|
|
|
|
return "Primary key = %s" % self.id
|
|
|
|
|
2009-04-07 04:23:33 +08:00
|
|
|
|
2009-04-19 04:29:55 +08:00
|
|
|
temp_storage = FileSystemStorage(tempfile.mkdtemp())
|
|
|
|
UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload')
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-04-19 04:29:55 +08:00
|
|
|
class Gallery(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-04-19 04:29:55 +08:00
|
|
|
class Picture(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
image = models.FileField(storage=temp_storage, upload_to='test_upload')
|
|
|
|
gallery = models.ForeignKey(Gallery, related_name="pictures")
|
|
|
|
|
|
|
|
|
2009-05-07 19:56:10 +08:00
|
|
|
class Language(models.Model):
|
|
|
|
iso = models.CharField(max_length=5, primary_key=True)
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
english_name = models.CharField(max_length=50)
|
|
|
|
shortlist = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('iso',)
|
|
|
|
|
|
|
|
|
2009-05-07 20:52:43 +08:00
|
|
|
# a base class for Recommender and Recommendation
|
|
|
|
class Title(models.Model):
|
|
|
|
pass
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-07 20:52:43 +08:00
|
|
|
class TitleTranslation(models.Model):
|
|
|
|
title = models.ForeignKey(Title)
|
|
|
|
text = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-07 20:52:43 +08:00
|
|
|
class Recommender(Title):
|
|
|
|
pass
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-07 20:52:43 +08:00
|
|
|
class Recommendation(Title):
|
|
|
|
recommender = models.ForeignKey(Recommender)
|
|
|
|
|
|
|
|
|
2009-05-09 19:40:13 +08:00
|
|
|
class Collector(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-09 19:40:13 +08:00
|
|
|
class Widget(models.Model):
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-09 19:40:13 +08:00
|
|
|
class DooHickey(models.Model):
|
|
|
|
code = models.CharField(max_length=10, primary_key=True)
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-09 19:40:13 +08:00
|
|
|
class Grommet(models.Model):
|
|
|
|
code = models.AutoField(primary_key=True)
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-09 19:40:13 +08:00
|
|
|
class Whatsit(models.Model):
|
|
|
|
index = models.IntegerField(primary_key=True)
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-09 19:40:13 +08:00
|
|
|
class Doodad(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-09 19:40:13 +08:00
|
|
|
class FancyDoodad(Doodad):
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
expensive = models.BooleanField(default=True)
|
|
|
|
|
|
|
|
|
2009-07-03 11:05:17 +08:00
|
|
|
class Category(models.Model):
|
|
|
|
collector = models.ForeignKey(Collector)
|
|
|
|
order = models.PositiveIntegerField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('order',)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return u'%s:o%s' % (self.id, self.order)
|
|
|
|
|
2009-12-23 02:29:00 +08:00
|
|
|
|
|
|
|
class Link(models.Model):
|
|
|
|
posted = models.DateField(
|
|
|
|
default=lambda: datetime.date.today() - datetime.timedelta(days=7)
|
|
|
|
)
|
|
|
|
url = models.URLField()
|
|
|
|
post = models.ForeignKey("Post")
|
|
|
|
|
|
|
|
|
2011-04-22 20:02:25 +08:00
|
|
|
class PrePopulatedPost(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
published = models.BooleanField()
|
|
|
|
slug = models.SlugField()
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2011-04-22 20:02:25 +08:00
|
|
|
class PrePopulatedSubPost(models.Model):
|
|
|
|
post = models.ForeignKey(PrePopulatedPost)
|
|
|
|
subtitle = models.CharField(max_length=100)
|
|
|
|
subslug = models.SlugField()
|
|
|
|
|
|
|
|
|
2009-12-23 02:29:00 +08:00
|
|
|
class Post(models.Model):
|
2011-02-19 20:55:09 +08:00
|
|
|
title = models.CharField(max_length=100, help_text="Some help text for the title (with unicode ŠĐĆŽćžšđ)")
|
|
|
|
content = models.TextField(help_text="Some help text for the content (with unicode ŠĐĆŽćžšđ)")
|
|
|
|
posted = models.DateField(
|
|
|
|
default=datetime.date.today,
|
|
|
|
help_text="Some help text for the date (with unicode ŠĐĆŽćžšđ)"
|
|
|
|
)
|
2010-03-10 16:37:17 +08:00
|
|
|
public = models.NullBooleanField()
|
2009-12-23 02:29:00 +08:00
|
|
|
|
|
|
|
def awesomeness_level(self):
|
|
|
|
return "Very awesome."
|
|
|
|
|
2009-05-07 20:52:43 +08:00
|
|
|
|
2009-12-18 18:08:05 +08:00
|
|
|
class Gadget(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class Villain(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class SuperVillain(Villain):
|
|
|
|
pass
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class FunkyTag(models.Model):
|
|
|
|
"Because we all know there's only one real use case for GFKs."
|
|
|
|
name = models.CharField(max_length=25)
|
|
|
|
content_type = models.ForeignKey(ContentType)
|
|
|
|
object_id = models.PositiveIntegerField()
|
|
|
|
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class Plot(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
team_leader = models.ForeignKey(Villain, related_name='lead_plots')
|
|
|
|
contact = models.ForeignKey(Villain, related_name='contact_plots')
|
|
|
|
tags = generic.GenericRelation(FunkyTag)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class PlotDetails(models.Model):
|
|
|
|
details = models.CharField(max_length=100)
|
|
|
|
plot = models.OneToOneField(Plot)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.details
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class SecretHideout(models.Model):
|
|
|
|
""" Secret! Not registered with the admin! """
|
|
|
|
location = models.CharField(max_length=100)
|
|
|
|
villain = models.ForeignKey(Villain)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.location
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class SuperSecretHideout(models.Model):
|
|
|
|
""" Secret! Not registered with the admin! """
|
|
|
|
location = models.CharField(max_length=100)
|
|
|
|
supervillain = models.ForeignKey(SuperVillain)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.location
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class CyclicOne(models.Model):
|
|
|
|
name = models.CharField(max_length=25)
|
|
|
|
two = models.ForeignKey('CyclicTwo')
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-02-26 21:17:43 +08:00
|
|
|
class CyclicTwo(models.Model):
|
|
|
|
name = models.CharField(max_length=25)
|
|
|
|
one = models.ForeignKey(CyclicOne)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-03-21 22:23:25 +08:00
|
|
|
class Topping(models.Model):
|
2010-04-11 16:35:04 +08:00
|
|
|
name = models.CharField(max_length=20)
|
2010-03-21 22:23:25 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-03-21 22:23:25 +08:00
|
|
|
class Pizza(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
toppings = models.ManyToManyField('Topping')
|
|
|
|
|
|
|
|
|
2010-08-06 22:58:05 +08:00
|
|
|
class Album(models.Model):
|
|
|
|
owner = models.ForeignKey(User)
|
|
|
|
title = models.CharField(max_length=30)
|
|
|
|
|
2010-12-23 11:44:38 +08:00
|
|
|
|
2011-01-13 07:30:47 +08:00
|
|
|
class Employee(Person):
|
|
|
|
code = models.CharField(max_length=20)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2011-01-13 07:30:47 +08:00
|
|
|
class WorkHour(models.Model):
|
|
|
|
datum = models.DateField()
|
|
|
|
employee = models.ForeignKey(Employee)
|
|
|
|
|
|
|
|
|
2011-01-20 08:33:32 +08:00
|
|
|
class Question(models.Model):
|
|
|
|
question = models.CharField(max_length=20)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2011-01-20 08:33:32 +08:00
|
|
|
class Answer(models.Model):
|
|
|
|
question = models.ForeignKey(Question, on_delete=models.PROTECT)
|
|
|
|
answer = models.CharField(max_length=20)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.answer
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2011-02-08 20:00:21 +08:00
|
|
|
class Reservation(models.Model):
|
|
|
|
start_date = models.DateTimeField()
|
|
|
|
price = models.IntegerField()
|
2011-02-19 19:48:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
DRIVER_CHOICES = (
|
|
|
|
(u'bill', 'Bill G'),
|
|
|
|
(u'steve', 'Steve J'),
|
|
|
|
)
|
|
|
|
|
|
|
|
RESTAURANT_CHOICES = (
|
|
|
|
(u'indian', u'A Taste of India'),
|
|
|
|
(u'thai', u'Thai Pography'),
|
|
|
|
(u'pizza', u'Pizza Mama'),
|
|
|
|
)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2011-02-19 19:48:42 +08:00
|
|
|
class FoodDelivery(models.Model):
|
|
|
|
reference = models.CharField(max_length=100)
|
|
|
|
driver = models.CharField(max_length=100, choices=DRIVER_CHOICES, blank=True)
|
|
|
|
restaurant = models.CharField(max_length=100, choices=RESTAURANT_CHOICES, blank=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = (("driver", "restaurant"),)
|
|
|
|
|
|
|
|
|
2011-02-21 07:09:25 +08:00
|
|
|
class Paper(models.Model):
|
|
|
|
title = models.CharField(max_length=30)
|
|
|
|
author = models.CharField(max_length=30, blank=True, null=True)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2011-02-21 07:09:25 +08:00
|
|
|
class CoverLetter(models.Model):
|
|
|
|
author = models.CharField(max_length=30)
|
2011-03-09 03:26:32 +08:00
|
|
|
date_written = models.DateField(null=True, blank=True)
|
2011-02-21 07:09:25 +08:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.author
|
|
|
|
|
|
|
|
|
2011-03-03 21:20:45 +08:00
|
|
|
class Story(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
content = models.TextField()
|
|
|
|
|
|
|
|
|
|
|
|
class OtherStory(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
content = models.TextField()
|
|
|
|
|
2011-02-19 19:48:42 +08:00
|
|
|
|
2011-06-03 19:54:29 +08:00
|
|
|
class ComplexSortedPerson(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
age = models.PositiveIntegerField()
|
|
|
|
is_employee = models.NullBooleanField()
|
|
|
|
|