ajout des premiers templates ,des methodes "str", et des premieres vues pour port

This commit is contained in:
maxime 2019-06-02 18:07:37 +02:00
parent 16d90b9551
commit 0b303b2a91
9 changed files with 586 additions and 81 deletions

View File

@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'port.apps.PortConfig',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',

View File

@ -1,3 +1,18 @@
from django.contrib import admin from django.contrib import admin
# Register your models here. from .models import *
admin.site.register(Address)
admin.site.register(Person)
admin.site.register(Company)
admin.site.register(Employee)
admin.site.register(Boat)
admin.site.register(Port)
admin.site.register(Dock)
admin.site.register(Plug)
admin.site.register(Tap)
admin.site.register(Payment)
admin.site.register(Service)
admin.site.register(Bill)
admin.site.register(Stay)
admin.site.register(Mooring)

View File

@ -0,0 +1,242 @@
# Generated by Django 2.2.1 on 2019-06-02 10:22
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Address',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('address', models.CharField(max_length=200)),
('zip_code', models.CharField(max_length=10)),
('city', models.CharField(max_length=200)),
('country', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='Bill',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('num', models.IntegerField()),
('date', models.DateTimeField()),
('total', models.DecimalField(decimal_places=2, max_digits=7)),
],
),
migrations.CreateModel(
name='Boat',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('registration_num', models.CharField(max_length=20, null=True)),
('length', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
('beam', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
('water_draught', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
('tonnage', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
('water_tank', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
('model', models.CharField(max_length=50, null=True)),
('heating', models.CharField(max_length=50, null=True)),
('passenger_capacity', models.IntegerField(null=True)),
('picture', models.ImageField(null=True, upload_to='uploads/')),
],
),
migrations.CreateModel(
name='Company',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('email', models.EmailField(max_length=200, null=True)),
('phone', models.CharField(max_length=20, null=True)),
('registration_num', models.CharField(max_length=50, null=True)),
('address', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='port.Address')),
],
),
migrations.CreateModel(
name='Dock',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('num', models.CharField(max_length=10)),
('length', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
('width', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
('depth', models.DecimalField(decimal_places=2, max_digits=7, null=True)),
],
),
migrations.CreateModel(
name='Employee',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('position', models.CharField(max_length=20, null=True, verbose_name='Job')),
],
),
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('num', models.CharField(max_length=40)),
('date', models.DateTimeField()),
('amount', models.DecimalField(decimal_places=2, max_digits=7)),
('pay_type', models.CharField(choices=[('CSH', 'Cash'), ('CHK', 'Check'), ('TSF', 'Transfer'), ('CRD', 'Credit Card')], default='CSH', max_length=3)),
],
),
migrations.CreateModel(
name='Person',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, null=True)),
('surname', models.CharField(max_length=50, null=True)),
('nationality', models.CharField(max_length=200, null=True)),
('email', models.EmailField(max_length=254, null=True)),
('phone', models.CharField(max_length=20, null=True)),
('address', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='port.Address')),
],
),
migrations.CreateModel(
name='Port',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('address', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Address')),
('company', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Company')),
('employees', models.ManyToManyField(through='port.Employee', to='port.Person')),
],
),
migrations.CreateModel(
name='Service',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Insurance',
fields=[
('company_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='port.Company')),
],
bases=('port.company',),
),
migrations.CreateModel(
name='Tap',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('num', models.CharField(max_length=10)),
('port', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Port')),
],
),
migrations.CreateModel(
name='Stay',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('arrival', models.DateTimeField()),
('departure', models.DateTimeField(null=True)),
('coming_from', models.CharField(max_length=200, null=True)),
('going_to', models.CharField(max_length=200, null=True)),
('bill', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='port.Bill')),
('boat', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Boat')),
],
),
migrations.CreateModel(
name='SailsOn',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('is_captain', models.BooleanField()),
('is_crew', models.BooleanField()),
('is_owner', models.BooleanField()),
('is_guest', models.BooleanField()),
('is_pet', models.BooleanField()),
('boat', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Boat')),
('person', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Person')),
],
),
migrations.CreateModel(
name='Plug',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('num', models.CharField(max_length=10)),
('amperage', models.DecimalField(decimal_places=2, max_digits=7)),
('voltage', models.DecimalField(decimal_places=2, max_digits=7)),
('port', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Port')),
],
),
migrations.CreateModel(
name='Mooring',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateTimeField()),
('dock', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Dock')),
('plug', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='port.Plug')),
('stay', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='port.Stay')),
('tap', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='port.Tap')),
],
),
migrations.AddField(
model_name='employee',
name='person',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Person'),
),
migrations.AddField(
model_name='employee',
name='port',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Port'),
),
migrations.AddField(
model_name='dock',
name='port',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Port'),
),
migrations.AddField(
model_name='boat',
name='company',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='port.Company'),
),
migrations.AddField(
model_name='boat',
name='persons',
field=models.ManyToManyField(through='port.SailsOn', to='port.Person'),
),
migrations.CreateModel(
name='BillPayment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('amount', models.DecimalField(decimal_places=2, max_digits=7)),
('bill', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Bill')),
('payment', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Payment')),
],
),
migrations.CreateModel(
name='BillLine',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.DecimalField(decimal_places=2, max_digits=7)),
('bill', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Bill')),
('service', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Service')),
],
),
migrations.AddField(
model_name='bill',
name='payments',
field=models.ManyToManyField(through='port.BillPayment', to='port.Payment'),
),
migrations.CreateModel(
name='BoatInsurance',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('contract', models.IntegerField(null=True)),
('date', models.DateTimeField(auto_now_add=True)),
('boat', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Boat')),
('insurance', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='port.Insurance')),
],
),
migrations.AddField(
model_name='boat',
name='boat_insurance',
field=models.ManyToManyField(through='port.BoatInsurance', to='port.Insurance'),
),
]

View File

@ -1,6 +1,8 @@
from django.db import models from django.db import models
from django.db.models import Model, CharField, EmailField, \ from django.db.models import Model, CharField, EmailField, \
DateTimeField, DecimalField, ForeignKey, ManyToManyField DateTimeField, DecimalField, ForeignKey, ManyToManyField, \
IntegerField, ImageField, BooleanField, \
CASCADE, SET_NULL, PROTECT
class Address(Model): class Address(Model):
address = CharField(max_length=200) address = CharField(max_length=200)
@ -8,44 +10,53 @@ class Address(Model):
city = CharField(max_length=200) city = CharField(max_length=200)
country = CharField(max_length=200) country = CharField(max_length=200)
def __str__(self):
return '{}, {} - {}, {}'.format(self.address, self.zip_code,
self.city, self.country)
class Person(Model): class Person(Model):
name = CharField(max_length=50) name = CharField(max_length=50,null=True)
surname = CharField(max_length=50) surname = CharField(max_length=50,null=True)
nationality = CharField(max_length=200) nationality = CharField(max_length=200,null=True)
email = EmailField(max_length=254) email = EmailField(max_length=254,null=True)
phone = CharField(max_length=20) phone = CharField(max_length=20,null=True)
# Foreign keys # Foreign keys
address = ForeignKey(Address) address = ForeignKey(Address,on_delete=SET_NULL,null=True)
def __str__(self):
return '{} {}'.format(self.name, self.surname)
class Company(Model): class Company(Model):
name = CharField(max_length=50) name = CharField(max_length=50)
email = EmailField(max_length=200) email = EmailField(max_length=200,null=True)
phone = CharField(max_length=20) phone = CharField(max_length=20,null=True)
registration_num = CharField(max_length=50) registration_num = CharField(max_length=50,null=True)
# Foreign keys # Foreign keys
address = ForeignKey(Address) address = ForeignKey(Address,on_delete=SET_NULL,null=True)
def __str__(self):
return '{}'.format(self.name)
class Insurance(Company): class Insurance(Company):
pass pass
class Boat(Model): class Boat(Model):
name = CharField(max_length=50) name = CharField(max_length=50)
registration_num = CharField(max_length=20) registration_num = CharField(max_length=20,null=True)
length = DecimalField() length = DecimalField(max_digits=7, decimal_places=2, null=True)
beam = DecimalField() beam = DecimalField(max_digits=7, decimal_places=2, null=True)
water_draught = DecimalField() water_draught = DecimalField(max_digits=7, decimal_places=2, null=True)
tonnage = DecimalField() tonnage = DecimalField(max_digits=7, decimal_places=2, null=True)
water_tank = DecimalField() water_tank = DecimalField(max_digits=7, decimal_places=2, null=True)
model = CharField(max_length=50) model = CharField(max_length=50,null=True)
heating = CharField(max_length=50) heating = CharField(max_length=50,null=True)
passenger_capacity = IntegerField() passenger_capacity = IntegerField(null=True)
picture = ImageField(upload_to='uploads/', height_field=None, width_field=None, max_length=100) picture = ImageField(upload_to='uploads/', height_field=None,
width_field=None, max_length=100, null=True)
# Foreign keys # Foreign keys
company = ForeignKey(Company) company = ForeignKey(Company,on_delete=SET_NULL,null=True,related_name='+')
boat_insurance = ManyToManyField( boat_insurance = ManyToManyField(
Insurance, Insurance,
@ -57,10 +68,12 @@ class Boat(Model):
through='SailsOn', through='SailsOn',
through_fields=('boat', 'person') through_fields=('boat', 'person')
) )
def __str__(self):
return '{}'.format(self.name)
class SailsOn(Model): class SailsOn(Model):
boat = ForeignKey(Boat) boat = ForeignKey(Boat,on_delete=PROTECT)
person = ForeignKey(Person) person = ForeignKey(Person,on_delete=PROTECT)
is_captain = BooleanField() is_captain = BooleanField()
is_crew = BooleanField() is_crew = BooleanField()
@ -68,94 +81,95 @@ class SailsOn(Model):
is_guest = BooleanField() is_guest = BooleanField()
is_pet = BooleanField() is_pet = BooleanField()
class BoatInsurance(Model):
class BoatInsurance(Model) contract = IntegerField(null=True)
contract = IntegerField() date = DateTimeField(auto_now_add=True)
date = DateTimeField()
# Foreign keys # Foreign keys
insurance = ForeignKey(Insurance) insurance = ForeignKey(Insurance,on_delete=PROTECT)
boat = ForeignKey(Boat) boat = ForeignKey(Boat,on_delete=PROTECT)
class Port(Model): class Port(Model):
name = CharField(max_length=50) name = CharField(max_length=50)
# Foreign keys # Foreign keys
address = ForeignKey(Address) address = ForeignKey(Address,on_delete=PROTECT)
company = ForeignKey(Company) company = ForeignKey(Company,on_delete=PROTECT)
employees = ManyToManyField( employees = ManyToManyField(
Person, Person,
through='Employee', through='Employee',
through_fields=('port', 'person') through_fields=('port', 'person')
) )
def __str__(self):
return '{}'.format(self.name)
class Employee(Model): class Employee(Model):
position = CharField('Job', max_length=20) position = CharField('Job', max_length=20, null=True)
# Foreign keys # Foreign keys
port = ForeignKey(Port) port = ForeignKey(Port,on_delete=PROTECT)
person = ForeignKey(Person) person = ForeignKey(Person,on_delete=PROTECT)
def __str__(self):
return '{}, {} at {}'.format(str(self.person), self.position,
str(self.port))
class Dock(Model): class Dock(Model):
num = CharField(max_length=10) num = CharField(max_length=10)
length = DecimalField() length = DecimalField(max_digits=7, decimal_places=2, null=True)
width = DecimalField() width = DecimalField(max_digits=7, decimal_places=2, null=True)
depth = DecimalField() depth = DecimalField(max_digits=7, decimal_places=2, null=True)
# Foreign keys # Foreign keys
port = ForeignKey(Port) port = ForeignKey(Port,on_delete=PROTECT)
def __str__(self):
return '{} : {}'.format(str(self.port), self.num)
class Plug(Model): class Plug(Model):
num = CharField(max_length=10) num = CharField(max_length=10)
amperage = DecimalField() amperage = DecimalField(max_digits=7, decimal_places=2)
voltage = DecimalField() voltage = DecimalField(max_digits=7, decimal_places=2)
# Foreign keys # Foreign keys
port = ForeignKey(Port) port = ForeignKey(Port,on_delete=PROTECT)
def __str__(self):
return '{} : {}'.format(str(self.port), self.num)
class Tap(Model): class Tap(Model):
num = CharField(max_length=10) num = CharField(max_length=10)
# Foreign keys # Foreign keys
port = ForeignKey(Port) port = ForeignKey(Port,on_delete=PROTECT)
def __str__(self):
class Stay(Model): return '{} : {}'.format(str(self.port), self.num)
arrival = DateTimeField()
departure = DateTimeField()
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)
class Payment(Model): class Payment(Model):
num = CharField(max_length=40) num = CharField(max_length=40)
date = DateTimeField() date = DateTimeField()
amount = DecimalField() amount = DecimalField(max_digits=7, decimal_places=2)
pay_type = CharField(
# Foreign keys max_length=3,
pay_type = ForeignKey(PaymentType) choices=[
('CSH', 'Cash'),
('CHK', 'Check'),
('TSF', 'Transfer'),
('CRD', 'Credit Card')
],
default='CSH'
)
def __str__(self):
return '{} at {}'.format(self.num, str(self.date))
class Service(Model): class Service(Model):
name = CharField(max_length=50) name = CharField(max_length=50)
def __str__(self):
class BillLine(Model): return '{}'.format(self.name)
quantity = DecimalField()
# Foreign keyks
service = ForeignKey(Service)
bill = ForeignKey(Bill)
class Bill(Model): class Bill(Model):
num = IntegerField() num = IntegerField()
date = DateTimeField() date = DateTimeField()
total = DecimalField() total = DecimalField(max_digits=7, decimal_places=2)
# Foreign keys # Foreign keys
payments = ManyToManyField( payments = ManyToManyField(
@ -163,21 +177,48 @@ class Bill(Model):
through='BillPayment', through='BillPayment',
through_fields=('bill', 'payment') through_fields=('bill', 'payment')
) )
def __str__(self):
return '{} at {}'.format(self.num, str(self.date))
class BillLine(Model):
quantity = DecimalField(max_digits=7, decimal_places=2)
value = DecimalField(max_digits=7, decimal_places=2)
# Foreign keyks
service = ForeignKey(Service,on_delete=PROTECT)
bill = ForeignKey(Bill,on_delete=PROTECT)
def __str__(self):
return '{}x {} - {}'.format(self.quantity, str(self.service),
str(self.value))
class BillPayment(Model): class BillPayment(Model):
amount = DecimalField() amount = DecimalField(max_digits=7, decimal_places=2)
# Foreign keys # Foreign keys
bill = ForeignKey(Bill) bill = ForeignKey(Bill,on_delete=PROTECT)
payment = ForeignKey(Payment) payment = ForeignKey(Payment,on_delete=PROTECT)
class Stay(Model):
arrival = DateTimeField()
departure = DateTimeField(null=True)
coming_from = CharField(max_length=200,null=True)
going_to = CharField(max_length=200,null=True)
# Foreign keys
boat = ForeignKey(Boat,on_delete=PROTECT)
bill = ForeignKey(Bill,on_delete=PROTECT,null=True)
def __str__(self):
return '{} - {} : {}'.format(self.arrival, self.departure, str(self.boat))
class Mooring(Model): class Mooring(Model):
date = DateTimeField() date = DateTimeField()
# Foreign keys # Foreign keys
stay = ForeignKey(Stay) stay = ForeignKey(Stay,on_delete=CASCADE)
dock = ForeignKey(Dock) dock = ForeignKey(Dock,on_delete=PROTECT)
tap = ForeignKey(Tap) tap = ForeignKey(Tap,on_delete=PROTECT,null=True)
plug = ForeignKey(Plug) plug = ForeignKey(Plug,on_delete=PROTECT,null=True)
# Methods
def __str__(self):
return '{} - {} at {}'.format(str(self.date), str(self.stay.boat), str(self.dock))

160
port/models.py.orig Normal file
View File

@ -0,0 +1,160 @@
from django.db import models
from django.db.models import Model, CharField, EmailField, \
DateTimeField, DecimalField, ForeignKey
<<<<<<< HEAD
class Address(models.Model):
address = models.CharField(max_length=200)
zip_code = models.CharField(max_length=200)
city = models.CharField(max_length=200)
country = models.CharField(max_length=200)
class Person(models.Model):
name = models.CharField(max_length=200)
surname = models.CharField(max_length=200)
address = Address()
nationality = models.CharField(max_length=200)
email = models.EmailField(max_length=254)
phone =
class Company(models.Model):
name = models.CharField(max_length=200)
address = Address()
=======
class Address(Model):
address = CharFIELD(MAX_length=254)
zip_code = CharField(max_length=10)
city = CharField(max_length=200)
country = CharField(max_length=200)
class Person(Model):
name = CharField(max_length=50)
surname = CharField(max_length=50)
nationality = CharField(max_length=200)
email = EmailField(max_length=200)
phone = CharField(max_length=20)
# Foreign keys
address = ForeignKey(Address)
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)
>>>>>>> modif_local
class Insurance(Company):
pass
<<<<<<< HEAD
class Boat(models.Model):
name = models.CharField(max_length=200)
registration_num =
length =
beam =
water_draught =
tonnage =
water_tank =
model = models.CharField(max_length=200)
heating = models.CharField(max_length=200)
passenger_capacity =
picture = models.ImageField(upload_to=None, height_field=None, width_field=None, max_length=100)
class Port(models.Model):
name = models.CharField(max_length=200)
address = Address()
class Dock(models.Model):
num =
length =
width =
depth =
class Plug(models.Model):
num =
amperage =
voltage =
class Tap(models.Model):
num =
class Stay(models.Model):
arrival = models.DateTimeField('date published')
departure = models.DateTimeField('date published')
coming_from = models.CharField(max_length=200)
going_to = models.CharField(max_length=200)
num_passenger =
num_guest =
class Payment(models.Model):
num =
date = models.DateTimeField('date published')
pay_type = models.CharField(max_length=200)
amount =
class Bill_line(models.Model):
service = models.CharField(max_length=200)
quantity =
class Service(models.Model):
service_type = models.CharField(max_length=200)
# Create your models here.
=======
class Boat(Model):
name = CharField(max_length=50)
registration_num = CharField(max_length=20)
length = DecimalField()
beam = DecimalField()
water_draught = DecimalField()
tonnage = DecimalField()
water_tank = DecimalField()
model = CharField(max_length=50)
heating = CharField(max_length=50)
# Foreign keys
insurance = Insurance()
class Port(Model):
name = CharField(max_length=50)
address = CharField(max_length=254)
class Dock(Model):
num = CharField(max_length=4)
length = DecimalField()
width = DecimalField()
depth = DecimalField()
class Plug(Model):
num = CharField(max_length=4)
amperage = DecimalField()
voltage = DecimalField()
class Tap(Model):
num = CharField(max_length=4)
class Stay(Model):
arrival = DateTimeField()
departure = DateTimeField()
coming_from = CharField(max_length=150)
going_to = CharField(max_length=150)
class PaymentType(Model):
name = CharField(max_length=20)
class Payment(Model):
num = CharField(max_length=40)
date = DateTimeField()
pay_type = ForeignKey(PaymentType)
amount = DecimalField()
class Service(Model):
service_type = CharField(max_length=50)
class Bill_line(Model):
service = Service()
quantity = DecimalField()
>>>>>>> modif_local

View File

@ -0,0 +1,19 @@
<form action="{% url 'port:addperson' %}" method="post">
<label for="name">Name : </label>
<input type="text" name="name" id="name"/>
<br />
<label for="surname">Surname : </label>
<input type="text" name="surname" id="surname"/>
<br />
<label for="nationality">Nationality : </label>
<input type="text" name="nationality" id="nationality"/>
<br />
<label for="nationality">Nationality : </label>
<label for="email">e-mail : </label>
<input type="text" name="email" id="email"/>
<label for="phone">Phone number : </label>
<input type="countrycode" value="+33"/>
<input type="text" name="phone" id="phone"/>
<input type="submit" value="add"/>
</form>

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>List of current ports</title>
</head>
<body>
<ul>
{% for port in ports.all %}
<li>{{ port }}</li>
{% endfor %}
</ul>
</body>
</html>

View File

@ -4,6 +4,6 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index'), path('', views.index, name='index'),
path('port', views.ports_status, name='ports'),
path('/new/person', views.add_person, name='person'),
] ]

View File

@ -1,5 +1,19 @@
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import *
def index(request): def index(request):
return HttpResponse("Hello, world.") return HttpResponse("Hello, world.")
def ports_status(request):
"""
res = ''
ports = Port.objects.all()
li = lambda x: '<li>' + str(x)
res = ''.join(map(li, ports))
res = '<html><body><ul>' + res + '</ul></body></html>'
return HttpResponse(res)
"""
return render(request, 'port/ports_status.html', {'ports': Port.objects})