2009-05-13 22:04:29 +08:00
|
|
|
from django.db import models
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2009-05-13 22:04:29 +08:00
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
|
2009-05-13 22:04:29 +08:00
|
|
|
class User(models.Model):
|
|
|
|
username = models.CharField(max_length=12, unique=True)
|
|
|
|
serial = models.IntegerField()
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2009-05-13 22:04:29 +08:00
|
|
|
class UserSite(models.Model):
|
|
|
|
user = models.ForeignKey(User, to_field="username")
|
|
|
|
data = models.IntegerField()
|
2009-05-15 20:44:51 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2009-05-15 20:44:51 +08:00
|
|
|
class Place(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2009-05-15 20:44:51 +08:00
|
|
|
class Restaurant(Place):
|
|
|
|
pass
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2009-05-15 20:44:51 +08:00
|
|
|
class Manager(models.Model):
|
2014-05-29 08:39:14 +08:00
|
|
|
restaurant = models.ForeignKey(Restaurant)
|
2009-05-15 20:44:51 +08:00
|
|
|
name = models.CharField(max_length=50)
|
2011-01-25 12:52:54 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2011-01-25 12:52:54 +08:00
|
|
|
class Network(models.Model):
|
|
|
|
name = models.CharField(max_length=15)
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2011-01-25 12:52:54 +08:00
|
|
|
class Host(models.Model):
|
|
|
|
network = models.ForeignKey(Network)
|
|
|
|
hostname = models.CharField(max_length=25)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2011-01-25 12:52:54 +08:00
|
|
|
return self.hostname
|