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