From 0b303b2a91c526fa736ce08c10714eb92a0c0ee6 Mon Sep 17 00:00:00 2001 From: maxime Date: Sun, 2 Jun 2019 18:07:37 +0200 Subject: [PATCH] ajout des premiers templates ,des methodes "str", et des premieres vues pour port --- gpp/settings.py | 1 + port/admin.py | 17 +- port/migrations/0001_initial.py | 242 ++++++++++++++++++++++++++ port/models.py | 197 ++++++++++++--------- port/models.py.orig | 160 +++++++++++++++++ port/templates/port/add_person.html | 19 ++ port/templates/port/ports_status.html | 13 ++ port/urls.py | 4 +- port/views.py | 14 ++ 9 files changed, 586 insertions(+), 81 deletions(-) create mode 100644 port/migrations/0001_initial.py create mode 100644 port/models.py.orig create mode 100644 port/templates/port/add_person.html create mode 100644 port/templates/port/ports_status.html diff --git a/gpp/settings.py b/gpp/settings.py index f06900d..309467f 100644 --- a/gpp/settings.py +++ b/gpp/settings.py @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'port.apps.PortConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/port/admin.py b/port/admin.py index 8c38f3f..469cd5b 100644 --- a/port/admin.py +++ b/port/admin.py @@ -1,3 +1,18 @@ 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) diff --git a/port/migrations/0001_initial.py b/port/migrations/0001_initial.py new file mode 100644 index 0000000..df5b3e6 --- /dev/null +++ b/port/migrations/0001_initial.py @@ -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'), + ), + ] diff --git a/port/models.py b/port/models.py index 580c80f..f5c69bd 100644 --- a/port/models.py +++ b/port/models.py @@ -1,6 +1,8 @@ from django.db import models 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): address = CharField(max_length=200) @@ -8,44 +10,53 @@ class Address(Model): city = 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): - name = CharField(max_length=50) - surname = CharField(max_length=50) - nationality = CharField(max_length=200) - email = EmailField(max_length=254) - phone = CharField(max_length=20) + name = CharField(max_length=50,null=True) + surname = CharField(max_length=50,null=True) + nationality = CharField(max_length=200,null=True) + email = EmailField(max_length=254,null=True) + phone = CharField(max_length=20,null=True) # 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): name = CharField(max_length=50) - email = EmailField(max_length=200) - phone = CharField(max_length=20) - registration_num = CharField(max_length=50) + email = EmailField(max_length=200,null=True) + phone = CharField(max_length=20,null=True) + registration_num = CharField(max_length=50,null=True) # Foreign keys - address = ForeignKey(Address) - + address = ForeignKey(Address,on_delete=SET_NULL,null=True) + def __str__(self): + return '{}'.format(self.name) class Insurance(Company): pass 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) - passenger_capacity = IntegerField() - picture = ImageField(upload_to='uploads/', height_field=None, width_field=None, max_length=100) + registration_num = CharField(max_length=20,null=True) + length = DecimalField(max_digits=7, decimal_places=2, null=True) + beam = DecimalField(max_digits=7, decimal_places=2, null=True) + water_draught = DecimalField(max_digits=7, decimal_places=2, null=True) + tonnage = DecimalField(max_digits=7, decimal_places=2, null=True) + water_tank = DecimalField(max_digits=7, decimal_places=2, null=True) + model = CharField(max_length=50,null=True) + heating = CharField(max_length=50,null=True) + passenger_capacity = IntegerField(null=True) + picture = ImageField(upload_to='uploads/', height_field=None, + width_field=None, max_length=100, null=True) # Foreign keys - company = ForeignKey(Company) + company = ForeignKey(Company,on_delete=SET_NULL,null=True,related_name='+') boat_insurance = ManyToManyField( Insurance, @@ -57,10 +68,12 @@ class Boat(Model): through='SailsOn', through_fields=('boat', 'person') ) + def __str__(self): + return '{}'.format(self.name) class SailsOn(Model): - boat = ForeignKey(Boat) - person = ForeignKey(Person) + boat = ForeignKey(Boat,on_delete=PROTECT) + person = ForeignKey(Person,on_delete=PROTECT) is_captain = BooleanField() is_crew = BooleanField() @@ -68,94 +81,95 @@ class SailsOn(Model): is_guest = BooleanField() is_pet = BooleanField() - -class BoatInsurance(Model) - contract = IntegerField() - date = DateTimeField() +class BoatInsurance(Model): + contract = IntegerField(null=True) + date = DateTimeField(auto_now_add=True) # Foreign keys - insurance = ForeignKey(Insurance) - boat = ForeignKey(Boat) - + insurance = ForeignKey(Insurance,on_delete=PROTECT) + boat = ForeignKey(Boat,on_delete=PROTECT) class Port(Model): name = CharField(max_length=50) # Foreign keys - address = ForeignKey(Address) - company = ForeignKey(Company) + address = ForeignKey(Address,on_delete=PROTECT) + company = ForeignKey(Company,on_delete=PROTECT) employees = ManyToManyField( Person, through='Employee', through_fields=('port', 'person') ) + def __str__(self): + return '{}'.format(self.name) + class Employee(Model): - position = CharField('Job', max_length=20) + position = CharField('Job', max_length=20, null=True) # Foreign keys - port = ForeignKey(Port) - person = ForeignKey(Person) + port = ForeignKey(Port,on_delete=PROTECT) + person = ForeignKey(Person,on_delete=PROTECT) + def __str__(self): + return '{}, {} at {}'.format(str(self.person), self.position, + str(self.port)) + class Dock(Model): num = CharField(max_length=10) - length = DecimalField() - width = DecimalField() - depth = DecimalField() + length = DecimalField(max_digits=7, decimal_places=2, null=True) + width = DecimalField(max_digits=7, decimal_places=2, null=True) + depth = DecimalField(max_digits=7, decimal_places=2, null=True) # Foreign keys - port = ForeignKey(Port) + port = ForeignKey(Port,on_delete=PROTECT) + def __str__(self): + return '{} : {}'.format(str(self.port), self.num) class Plug(Model): num = CharField(max_length=10) - amperage = DecimalField() - voltage = DecimalField() + amperage = DecimalField(max_digits=7, decimal_places=2) + voltage = DecimalField(max_digits=7, decimal_places=2) # Foreign keys - port = ForeignKey(Port) - + port = ForeignKey(Port,on_delete=PROTECT) + def __str__(self): + return '{} : {}'.format(str(self.port), self.num) class Tap(Model): num = CharField(max_length=10) # Foreign keys - port = ForeignKey(Port) - -class Stay(Model): - 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) + port = ForeignKey(Port,on_delete=PROTECT) + def __str__(self): + return '{} : {}'.format(str(self.port), self.num) class Payment(Model): num = CharField(max_length=40) date = DateTimeField() - amount = DecimalField() - - # Foreign keys - pay_type = ForeignKey(PaymentType) + amount = DecimalField(max_digits=7, decimal_places=2) + pay_type = CharField( + max_length=3, + 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): name = CharField(max_length=50) - -class BillLine(Model): - quantity = DecimalField() - - # Foreign keyks - service = ForeignKey(Service) - bill = ForeignKey(Bill) + def __str__(self): + return '{}'.format(self.name) class Bill(Model): num = IntegerField() date = DateTimeField() - total = DecimalField() + total = DecimalField(max_digits=7, decimal_places=2) # Foreign keys payments = ManyToManyField( @@ -163,21 +177,48 @@ class Bill(Model): through='BillPayment', 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): - amount = DecimalField() + amount = DecimalField(max_digits=7, decimal_places=2) # Foreign keys - bill = ForeignKey(Bill) - payment = ForeignKey(Payment) + bill = ForeignKey(Bill,on_delete=PROTECT) + 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): date = DateTimeField() # Foreign keys - stay = ForeignKey(Stay) - dock = ForeignKey(Dock) - tap = ForeignKey(Tap) - plug = ForeignKey(Plug) + stay = ForeignKey(Stay,on_delete=CASCADE) + dock = ForeignKey(Dock,on_delete=PROTECT) + tap = ForeignKey(Tap,on_delete=PROTECT,null=True) + 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)) diff --git a/port/models.py.orig b/port/models.py.orig new file mode 100644 index 0000000..6fd44cc --- /dev/null +++ b/port/models.py.orig @@ -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 diff --git a/port/templates/port/add_person.html b/port/templates/port/add_person.html new file mode 100644 index 0000000..3479370 --- /dev/null +++ b/port/templates/port/add_person.html @@ -0,0 +1,19 @@ +
+ + +
+ + +
+ + +
+ + + + + + + + +
diff --git a/port/templates/port/ports_status.html b/port/templates/port/ports_status.html new file mode 100644 index 0000000..fbc1b0e --- /dev/null +++ b/port/templates/port/ports_status.html @@ -0,0 +1,13 @@ + + + + List of current ports + + + + + diff --git a/port/urls.py b/port/urls.py index 6a67140..fc2fe44 100644 --- a/port/urls.py +++ b/port/urls.py @@ -4,6 +4,6 @@ from . import views urlpatterns = [ path('', views.index, name='index'), + path('port', views.ports_status, name='ports'), + path('/new/person', views.add_person, name='person'), ] - - diff --git a/port/views.py b/port/views.py index b24cf82..092b061 100644 --- a/port/views.py +++ b/port/views.py @@ -1,5 +1,19 @@ from django.shortcuts import render from django.http import HttpResponse +from .models import * + def index(request): return HttpResponse("Hello, world.") + +def ports_status(request): + """ + res = '' + ports = Port.objects.all() + li = lambda x: '
  • ' + str(x) + res = ''.join(map(li, ports)) + res = '' + return HttpResponse(res) + """ + + return render(request, 'port/ports_status.html', {'ports': Port.objects})