diff --git a/gpp/urls.py b/gpp/urls.py index b4ff80a..9a4093b 100644 --- a/gpp/urls.py +++ b/gpp/urls.py @@ -17,8 +17,8 @@ from django.contrib import admin from django.urls import include, path urlpatterns = [ - path('', include('port.urls')), - path('port/', include('port.urls', namespace='port')), - path('person/', include('port.urls', namespace='person')), + #path('', include('port.urls', namespace='index')), + path('port/', include('port.urls.port', namespace='port')), + path('person/', include('port.urls.person', namespace='person')), path('admin/', admin.site.urls), ] diff --git a/port/forms.py b/port/forms.py index 6c301d7..9c2d781 100644 --- a/port/forms.py +++ b/port/forms.py @@ -1,5 +1,5 @@ from django.forms import Form, CharField, IntegerField, DecimalField, \ - BooleanField, EmailField, DateTimeField, ImageField + BooleanField, EmailField, DateTimeField, ImageField, formset_factory from django_countries.fields import CountryField from phonenumber_field.formfields import PhoneNumberField @@ -15,3 +15,49 @@ class AddressForm(Form): zip_code = CharField(label='ZipCode', max_length=10) city = CharField(label='City', max_length=200) country = CountryField().formfield(label='Country') + +class DockForm(Form): + name = CharField(label='Name', max_length=10) + length = DecimalField( + label='Length', min_value=0, + max_digits=7, + decimal_places=2) + width = DecimalField( + label='Width', min_value=0, + max_digits=7, + decimal_places=2) + depth_min = DecimalField( + label='Depth (min.)', min_value=0, + max_digits=7, + decimal_places=2) + depth_max = DecimalField( + label='Depth (max.)', min_value=0, + max_digits=7, + decimal_places=2) + +DockFormSet = formset_factory(DockForm) + +class PortForm(Form): + name = CharField(label='Name', max_length=50) + address = CharField(label='Address', max_length=50) + company = CharField(label='Company', max_length=50) + +class PlugForm(Form): + name = CharField(label='Name', max_length=10) + amperage = DecimalField( + label='Amperage', + min_value=0, + max_digits=3, + decimal_places=0) + voltage = DecimalField( + label='Voltage', + min_value=0, + max_digits=3, + decimal_places=0) + +PlugFormSet = formset_factory(PlugForm) + +class TapForm(Form): + name = CharField(label='Name', max_length=10) + +TapFormSet = formset_factory(TapForm) diff --git a/port/migrations/0002_auto_20190607_1129.py b/port/migrations/0002_auto_20190607_1129.py new file mode 100644 index 0000000..df7ca36 --- /dev/null +++ b/port/migrations/0002_auto_20190607_1129.py @@ -0,0 +1,65 @@ +# Generated by Django 2.2.1 on 2019-06-07 09:29 + +from django.db import migrations, models +import django_countries.fields +import phonenumber_field.modelfields + + +class Migration(migrations.Migration): + + dependencies = [ + ('port', '0001_initial'), + ] + + operations = [ + migrations.RenameField( + model_name='dock', + old_name='depth', + new_name='depth_max', + ), + migrations.RenameField( + model_name='dock', + old_name='num', + new_name='name', + ), + migrations.RenameField( + model_name='plug', + old_name='num', + new_name='name', + ), + migrations.RenameField( + model_name='tap', + old_name='num', + new_name='name', + ), + migrations.AddField( + model_name='billline', + name='value', + field=models.DecimalField(decimal_places=2, default=0.0, max_digits=7), + ), + migrations.AddField( + model_name='dock', + name='depth_min', + field=models.DecimalField(decimal_places=2, max_digits=7, null=True), + ), + migrations.AlterField( + model_name='address', + name='country', + field=django_countries.fields.CountryField(max_length=2), + ), + migrations.AlterField( + model_name='company', + name='phone', + field=phonenumber_field.modelfields.PhoneNumberField(max_length=128, null=True, region=None), + ), + migrations.AlterField( + model_name='person', + name='nationality', + field=django_countries.fields.CountryField(max_length=2, null=True), + ), + migrations.AlterField( + model_name='person', + name='phone', + field=phonenumber_field.modelfields.PhoneNumberField(max_length=128, null=True, region=None), + ), + ] diff --git a/port/models.py b/port/models.py index 7846cda..cbf4992 100644 --- a/port/models.py +++ b/port/models.py @@ -19,7 +19,7 @@ class Address(Model): class Person(Model): name = CharField(max_length=50,null=True) surname = CharField(max_length=50,null=True) - nationality = CountryField() + nationality = CountryField(null=True) email = EmailField(max_length=254,null=True) phone = PhoneNumberField(null=True) @@ -116,12 +116,12 @@ class Employee(Model): return '{}, {} at {}'.format(str(self.person), self.position, str(self.port)) - class Dock(Model): - num = CharField(max_length=10) + name = CharField(max_length=10) 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) + depth_min = DecimalField(max_digits=7, decimal_places=2, null=True) + depth_max = DecimalField(max_digits=7, decimal_places=2, null=True) # Foreign keys port = ForeignKey(Port,on_delete=PROTECT) @@ -129,7 +129,7 @@ class Dock(Model): return '{} : {}'.format(str(self.port), self.num) class Plug(Model): - num = CharField(max_length=10) + name = CharField(max_length=10) amperage = DecimalField(max_digits=7, decimal_places=2) voltage = DecimalField(max_digits=7, decimal_places=2) @@ -139,7 +139,7 @@ class Plug(Model): return '{} : {}'.format(str(self.port), self.num) class Tap(Model): - num = CharField(max_length=10) + name = CharField(max_length=10) # Foreign keys port = ForeignKey(Port,on_delete=PROTECT) @@ -184,7 +184,7 @@ class Bill(Model): class BillLine(Model): quantity = DecimalField(max_digits=7, decimal_places=2) - value = DecimalField(max_digits=7, decimal_places=2) + value = DecimalField(max_digits=7, decimal_places=2, default=0.) # Foreign keyks service = ForeignKey(Service,on_delete=PROTECT) diff --git a/port/templates/port/form.html b/port/templates/port/form.html new file mode 100644 index 0000000..bc51402 --- /dev/null +++ b/port/templates/port/form.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} +{% block content %} +
+ +{% endblock %} diff --git a/port/templates/port/list.html b/port/templates/port/list.html new file mode 100644 index 0000000..636f12a --- /dev/null +++ b/port/templates/port/list.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} +{% block content %} +