finish model relations

This commit is contained in:
maxime 2019-06-02 11:31:53 +02:00
parent 2c6c6cdc15
commit 16d90b9551
1 changed files with 23 additions and 3 deletions

View File

@ -84,6 +84,18 @@ class Port(Model):
# Foreign keys
address = ForeignKey(Address)
company = ForeignKey(Company)
employees = ManyToManyField(
Person,
through='Employee',
through_fields=('port', 'person')
)
class Employee(Model):
position = CharField('Job', max_length=20)
# Foreign keys
port = ForeignKey(Port)
person = ForeignKey(Person)
class Dock(Model):
num = CharField(max_length=10)
@ -111,7 +123,7 @@ class Tap(Model):
class Stay(Model):
arrival = DateTimeField()
departure = DateTimeField('date published')
departure = DateTimeField()
coming_from = CharField(max_length=200)
going_to = CharField(max_length=200)
@ -131,12 +143,12 @@ class Payment(Model):
pay_type = ForeignKey(PaymentType)
class Service(Model):
service_type = CharField(max_length=50)
name = CharField(max_length=50)
class BillLine(Model):
quantity = DecimalField()
# Foreign keys
# Foreign keyks
service = ForeignKey(Service)
bill = ForeignKey(Bill)
@ -145,6 +157,14 @@ class Bill(Model):
date = DateTimeField()
total = DecimalField()
# Foreign keys
payments = ManyToManyField(
Payment,
through='BillPayment',
through_fields=('bill', 'payment')
)
class BillPayment(Model):
amount = DecimalField()