From 8a31d698b5d058f77753a270de80437ca4a1384e Mon Sep 17 00:00:00 2001 From: maxime Date: Sat, 1 Jun 2019 15:12:23 +0200 Subject: [PATCH] ajout des foreignKey --- port/models.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/port/models.py b/port/models.py index 69fda08..478cd18 100644 --- a/port/models.py +++ b/port/models.py @@ -25,6 +25,7 @@ class Company(Model): nationality = CharField(max_length=50) email = EmailField(max_length=200) phone = CharField(max_length=20) + # Foreign keys address = ForeignKey(Address) @@ -46,7 +47,16 @@ class Boat(Model): picture = ImageField(upload_to=None, height_field=None, width_field=None, max_length=100) # Foreign keys - insurance = Insurance() + boat_insurance = ForeignKey(BoatInsurance) + company = ForeignKey(Company) + +class BoatInsurance(Model) + contract = IntegerField() + date = DateTimeField() + + # Foreign keys + insurance = ForeignKey(Insurance) + boat = ForeignKey(Boat) class Port(Model): @@ -54,6 +64,7 @@ class Port(Model): # Foreign keys address = ForeignKey(Address) + company = ForeignKey(Company) class Dock(Model): num = CharField(max_length=10) @@ -61,21 +72,34 @@ class Dock(Model): width = DecimalField() depth = DecimalField() + # Foreign keys + port = ForeignKey(Port) + class Plug(Model): num = CharField(max_length=10) amperage = DecimalField() voltage = DecimalField() + # Foreign keys + port = ForeignKey(Port) + class Tap(Model): num = CharField(max_length=10) + # Foreign keys + port = ForeignKey(Port) + class Stay(Model): arrival = DateTimeField() departure = DateTimeField('date published') coming_from = CharField(max_length=200) going_to = CharField(max_length=200) + # Foreign keys + boat = ForeignKey(Boat) + bill = ForeignKey(Bill) + class PaymentType(Model): name = CharField(max_length=20) @@ -84,11 +108,37 @@ class Payment(Model): date = DateTimeField() amount = DecimalField() + # Foreign keys pay_type = ForeignKey(PaymentType) class Service(Model): service_type = CharField(max_length=50) -class Bill_line(Model): - service = ForeignKey(Service) +class BillLine(Model): quantity = DecimalField() + + # Foreign keys + service = ForeignKey(Service) + bill = ForeignKey(Bill) + +class Bill(Model): + num = IntegerField() + date = DateTimeField() + total = DecimalField() + +class BillPayment(Model): + amount = DecimalField() + + # Foreign keys + bill = ForeignKey(Bill) + payment = ForeignKey(Payment) + + +class Mooring(Model): + date = DateTimeField() + + # Foreign keys + stay = ForeignKey(Stay) + dock = ForeignKey(Dock) + tap = ForeignKey(Tap) + plug = ForeignKey(Plug)