From 16d90b9551be1227e11fb8e15b5761b7de93dfdf Mon Sep 17 00:00:00 2001 From: maxime Date: Sun, 2 Jun 2019 11:31:53 +0200 Subject: [PATCH] finish model relations --- port/models.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/port/models.py b/port/models.py index 6ad5c45..580c80f 100644 --- a/port/models.py +++ b/port/models.py @@ -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()