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