2012-05-12 15:24:20 +08:00
|
|
|
|
|
|
|
from django.db import models
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2012-05-12 15:24:20 +08:00
|
|
|
|
|
|
|
GENDER_CHOICES = (
|
|
|
|
('M', 'Male'),
|
|
|
|
('F', 'Female'),
|
|
|
|
)
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2012-05-12 15:24:20 +08:00
|
|
|
class Account(models.Model):
|
|
|
|
num = models.IntegerField()
|
|
|
|
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2012-05-12 15:24:20 +08:00
|
|
|
class Person(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
|
2012-08-13 03:17:54 +08:00
|
|
|
pid = models.IntegerField(null=True, default=None)
|
2012-05-12 15:24:20 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2012-05-12 15:24:20 +08:00
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class Employee(Person):
|
|
|
|
employee_num = models.IntegerField(default=0)
|
|
|
|
profile = models.ForeignKey('Profile', related_name='profiles', null=True)
|
|
|
|
accounts = models.ManyToManyField('Account', related_name='employees', blank=True, null=True)
|
|
|
|
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2012-05-12 15:24:20 +08:00
|
|
|
class Profile(models.Model):
|
|
|
|
name = models.CharField(max_length=200)
|
|
|
|
salary = models.FloatField(default=1000.0)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2012-05-12 15:24:20 +08:00
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class ProxyEmployee(Employee):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|