2019-06-08 13:38:59 +02:00
|
|
|
from django.forms import Form, ModelForm, \
|
|
|
|
CharField, IntegerField, DecimalField, \
|
|
|
|
BooleanField, EmailField, DateTimeField, ImageField, \
|
2019-06-10 19:34:46 +02:00
|
|
|
formset_factory, SelectDateWidget
|
2019-06-05 20:06:51 +02:00
|
|
|
from django_countries.fields import CountryField
|
2019-06-08 21:02:25 +02:00
|
|
|
from phonenumber_field.formfields import PhoneNumberField
|
2019-06-05 20:06:51 +02:00
|
|
|
|
2019-06-08 13:38:59 +02:00
|
|
|
from .models import *
|
|
|
|
|
2019-06-09 22:12:49 +02:00
|
|
|
class AddressForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Address
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'address',
|
|
|
|
'zip_code',
|
|
|
|
'city',
|
|
|
|
'country'
|
|
|
|
]
|
|
|
|
|
2019-06-08 13:59:32 +02:00
|
|
|
class PersonForm(ModelForm):
|
2019-06-08 13:38:59 +02:00
|
|
|
class Meta:
|
|
|
|
model = Person
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'name',
|
|
|
|
'surname',
|
|
|
|
'nationality',
|
|
|
|
'email',
|
|
|
|
'phone'
|
|
|
|
]
|
|
|
|
"""
|
2019-06-05 20:06:51 +02:00
|
|
|
name = CharField(label='Name', max_length=50)
|
|
|
|
surname = CharField(label='Surname', max_length=50)
|
|
|
|
nationality = CountryField().formfield(label='Nationality')
|
|
|
|
email = EmailField(label='E-Mail')
|
|
|
|
phone = PhoneNumberField(label='Phone Number')
|
2019-06-08 13:38:59 +02:00
|
|
|
"""
|
2019-06-05 20:06:51 +02:00
|
|
|
|
2019-06-09 22:12:49 +02:00
|
|
|
class CompanyForm(ModelForm):
|
2019-06-08 13:38:59 +02:00
|
|
|
class Meta:
|
2019-06-09 22:12:49 +02:00
|
|
|
model = Company
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'name',
|
|
|
|
'email',
|
|
|
|
'phone',
|
|
|
|
'registration_num']
|
|
|
|
|
|
|
|
class InsuranceForm(CompanyForm):
|
|
|
|
class Meta:
|
|
|
|
model = Insurance
|
2019-06-08 13:38:59 +02:00
|
|
|
|
|
|
|
fields = [
|
2019-06-09 22:12:49 +02:00
|
|
|
'name']
|
|
|
|
|
|
|
|
|
|
|
|
class BoatForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Boat
|
2019-06-08 13:38:59 +02:00
|
|
|
|
2019-06-09 22:12:49 +02:00
|
|
|
fields = ['name',
|
|
|
|
'registration_num',
|
|
|
|
'length',
|
|
|
|
'beam',
|
|
|
|
'water_draught',
|
|
|
|
'tonnage',
|
|
|
|
'water_tank',
|
|
|
|
'model',
|
|
|
|
'heating',
|
|
|
|
'passenger_capacity',
|
|
|
|
'company',
|
|
|
|
'picture']
|
|
|
|
|
|
|
|
class PortForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Port
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'name',
|
|
|
|
'address',
|
|
|
|
'company']
|
2019-06-08 13:38:59 +02:00
|
|
|
|
2019-06-09 22:12:49 +02:00
|
|
|
"""
|
|
|
|
name = CharField(label='Name', max_length=50)
|
|
|
|
address = CharField(label='Address', max_length=50)
|
|
|
|
company = CharField(label='Company', max_length=50)
|
|
|
|
"""
|
|
|
|
|
2019-06-08 13:38:59 +02:00
|
|
|
class DockForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Dock
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'name',
|
|
|
|
'length',
|
|
|
|
'width',
|
|
|
|
'depth_min',
|
|
|
|
'depth_max']
|
2019-06-08 13:08:57 +02:00
|
|
|
|
2019-06-08 13:38:59 +02:00
|
|
|
"""
|
2019-06-08 13:08:57 +02:00
|
|
|
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)
|
2019-06-08 13:38:59 +02:00
|
|
|
"""
|
2019-06-08 13:08:57 +02:00
|
|
|
|
|
|
|
DockFormSet = formset_factory(DockForm)
|
|
|
|
|
2019-06-08 13:59:32 +02:00
|
|
|
class PlugForm(ModelForm):
|
2019-06-08 13:38:59 +02:00
|
|
|
class Meta:
|
|
|
|
model = Plug
|
2019-06-09 22:12:49 +02:00
|
|
|
|
2019-06-08 13:38:59 +02:00
|
|
|
fields = [
|
|
|
|
'name',
|
|
|
|
'amperage',
|
|
|
|
'voltage',
|
|
|
|
]
|
|
|
|
|
|
|
|
"""
|
2019-06-08 13:08:57 +02:00
|
|
|
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)
|
2019-06-08 13:38:59 +02:00
|
|
|
"""
|
2019-06-08 13:08:57 +02:00
|
|
|
|
|
|
|
PlugFormSet = formset_factory(PlugForm)
|
|
|
|
|
2019-06-08 13:59:32 +02:00
|
|
|
class TapForm(ModelForm):
|
2019-06-08 13:38:59 +02:00
|
|
|
class Meta:
|
|
|
|
model = Tap
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
'name']
|
|
|
|
|
|
|
|
"""
|
2019-06-08 13:08:57 +02:00
|
|
|
name = CharField(label='Name', max_length=10)
|
2019-06-08 13:38:59 +02:00
|
|
|
"""
|
2019-06-08 13:08:57 +02:00
|
|
|
|
|
|
|
TapFormSet = formset_factory(TapForm)
|
2019-06-08 13:44:47 +02:00
|
|
|
|
2019-06-09 22:12:49 +02:00
|
|
|
|
|
|
|
|
2019-06-08 21:02:25 +02:00
|
|
|
class StayForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Stay
|
2019-06-09 22:12:49 +02:00
|
|
|
|
2019-06-08 21:02:25 +02:00
|
|
|
fields = ['arrival',
|
|
|
|
'departure',
|
|
|
|
'coming_from',
|
|
|
|
'going_to',
|
|
|
|
'no_mooring']
|
|
|
|
widgets = {
|
2019-06-10 19:34:46 +02:00
|
|
|
'arrival': SelectDateWidget(),
|
|
|
|
'departure': SelectDateWidget()
|
2019-06-08 21:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MooringForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Mooring
|
2019-06-09 22:12:49 +02:00
|
|
|
|
2019-06-08 21:02:25 +02:00
|
|
|
fields = ['date',
|
|
|
|
'dock',
|
|
|
|
'tap',
|
|
|
|
'plug']
|
2019-06-09 22:12:49 +02:00
|
|
|
|
2019-06-08 21:02:25 +02:00
|
|
|
MooringFormSet = formset_factory(MooringForm)
|