2012-06-07 18:08:47 +02:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2006-06-20 07:29:19 +02:00
|
|
|
from django.db import models
|
2012-08-12 12:32:08 +02:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2006-06-20 07:29:19 +02:00
|
|
|
|
2011-10-13 23:34:56 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2006-06-20 07:29:19 +02:00
|
|
|
class Place(models.Model):
|
2007-08-05 07:14:46 +02:00
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
address = models.CharField(max_length=80)
|
2006-06-20 07:29:19 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return "%s the place" % self.name
|
2006-06-20 07:29:19 +02:00
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2006-06-20 07:29:19 +02:00
|
|
|
class Restaurant(models.Model):
|
|
|
|
place = models.OneToOneField(Place)
|
2013-08-11 22:19:09 +02:00
|
|
|
serves_hot_dogs = models.BooleanField(default=False)
|
|
|
|
serves_pizza = models.BooleanField(default=False)
|
2006-06-20 07:29:19 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return "%s the restaurant" % self.place.name
|
2006-06-20 07:29:19 +02:00
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-05-29 14:17:03 +02:00
|
|
|
class Bar(models.Model):
|
|
|
|
place = models.OneToOneField(Place)
|
2013-03-24 15:27:27 +01:00
|
|
|
serves_cocktails = models.BooleanField(default=True)
|
2008-05-29 14:17:03 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return "%s the bar" % self.place.name
|
2008-05-29 14:17:03 +02:00
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
2008-08-02 01:16:59 +02:00
|
|
|
class UndergroundBar(models.Model):
|
|
|
|
place = models.OneToOneField(Place, null=True)
|
2013-03-24 15:27:27 +01:00
|
|
|
serves_cocktails = models.BooleanField(default=True)
|
2008-08-02 01:16:59 +02:00
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2006-06-20 07:29:19 +02:00
|
|
|
class Favorites(models.Model):
|
2013-08-20 07:52:32 +02:00
|
|
|
name = models.CharField(max_length=50)
|
2006-06-20 07:29:19 +02:00
|
|
|
restaurants = models.ManyToManyField(Restaurant)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return "Favorites for %s" % self.name
|
2006-06-20 07:29:19 +02:00
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
2009-03-06 03:02:09 +01:00
|
|
|
class Target(models.Model):
|
|
|
|
pass
|
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
2009-03-06 03:02:09 +01:00
|
|
|
class Pointer(models.Model):
|
|
|
|
other = models.OneToOneField(Target, primary_key=True)
|
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
2009-03-06 03:02:09 +01:00
|
|
|
class Pointer2(models.Model):
|
2013-08-20 07:52:32 +02:00
|
|
|
other = models.OneToOneField(Target, related_name='second_pointer')
|
|
|
|
|
|
|
|
|
|
|
|
class HiddenPointer(models.Model):
|
|
|
|
target = models.OneToOneField(Target, related_name='hidden+')
|