ajout boat insurance, sailson
This commit is contained in:
parent
8a31d698b5
commit
2c6c6cdc15
|
@ -1,6 +1,6 @@
|
|||
from django.db import models
|
||||
from django.db.models import Model, CharField, EmailField, \
|
||||
DateTimeField, DecimalField, ForeignKey
|
||||
DateTimeField, DecimalField, ForeignKey, ManyToManyField
|
||||
|
||||
class Address(Model):
|
||||
address = CharField(max_length=200)
|
||||
|
@ -11,7 +11,6 @@ class Address(Model):
|
|||
class Person(Model):
|
||||
name = CharField(max_length=50)
|
||||
surname = CharField(max_length=50)
|
||||
address = Address()
|
||||
nationality = CharField(max_length=200)
|
||||
email = EmailField(max_length=254)
|
||||
phone = CharField(max_length=20)
|
||||
|
@ -21,10 +20,9 @@ class Person(Model):
|
|||
|
||||
class Company(Model):
|
||||
name = CharField(max_length=50)
|
||||
address = CharField(max_length=254)
|
||||
nationality = CharField(max_length=50)
|
||||
email = EmailField(max_length=200)
|
||||
phone = CharField(max_length=20)
|
||||
registration_num = CharField(max_length=50)
|
||||
|
||||
# Foreign keys
|
||||
address = ForeignKey(Address)
|
||||
|
@ -44,12 +42,33 @@ class Boat(Model):
|
|||
model = CharField(max_length=50)
|
||||
heating = CharField(max_length=50)
|
||||
passenger_capacity = IntegerField()
|
||||
picture = ImageField(upload_to=None, height_field=None, width_field=None, max_length=100)
|
||||
picture = ImageField(upload_to='uploads/', height_field=None, width_field=None, max_length=100)
|
||||
|
||||
# Foreign keys
|
||||
boat_insurance = ForeignKey(BoatInsurance)
|
||||
company = ForeignKey(Company)
|
||||
|
||||
boat_insurance = ManyToManyField(
|
||||
Insurance,
|
||||
through='BoatInsurance',
|
||||
through_fields=('boat', 'insurance')
|
||||
)
|
||||
persons = ManyToManyField(
|
||||
Person,
|
||||
through='SailsOn',
|
||||
through_fields=('boat', 'person')
|
||||
)
|
||||
|
||||
class SailsOn(Model):
|
||||
boat = ForeignKey(Boat)
|
||||
person = ForeignKey(Person)
|
||||
|
||||
is_captain = BooleanField()
|
||||
is_crew = BooleanField()
|
||||
is_owner = BooleanField()
|
||||
is_guest = BooleanField()
|
||||
is_pet = BooleanField()
|
||||
|
||||
|
||||
class BoatInsurance(Model)
|
||||
contract = IntegerField()
|
||||
date = DateTimeField()
|
||||
|
|
Loading…
Reference in New Issue