fixed crud list
fixed payments upload -a
This commit is contained in:
+26
-7
@@ -1,4 +1,4 @@
|
||||
from django.forms import ModelForm
|
||||
from django.forms import ModelForm, TextInput
|
||||
|
||||
from containers.models import Container
|
||||
|
||||
@@ -7,7 +7,12 @@ class ContainerBaseForm(ModelForm):
|
||||
class Meta:
|
||||
model = Container
|
||||
fields = '__all__'
|
||||
|
||||
widgets = {
|
||||
'number': TextInput(attrs={
|
||||
'oninput': 'validateContainerNumber(this)',
|
||||
'class': 'form-control'
|
||||
})
|
||||
}
|
||||
class ContainerReceiveForm(ContainerBaseForm):
|
||||
"""
|
||||
Form for creating a new Container instance.
|
||||
@@ -16,14 +21,28 @@ class ContainerReceiveForm(ContainerBaseForm):
|
||||
class Meta(ContainerBaseForm.Meta):
|
||||
fields = ['number', 'receive_vehicle', 'damages', 'heavy_damaged', 'position',]
|
||||
|
||||
def __init__(self, *args, preinfo=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Add form-control class to all fields
|
||||
for field in self.fields.values():
|
||||
field.widget.attrs.update({'class': 'form-control'})
|
||||
|
||||
# Checkbox specific styling
|
||||
self.fields['heavy_damaged'].widget.attrs.update({'class': 'form-check-input'})
|
||||
|
||||
# If preinfo is provided, set initial values and make fields readonly
|
||||
if preinfo:
|
||||
...
|
||||
# self.fields['preinfo'].initial = preinfo.container_number
|
||||
# self.fields['number'].initial = preinfo.number
|
||||
# self.fields['container_number'].widget.attrs['readonly'] = True
|
||||
# self.fields['number'].widget.attrs['readonly'] = True
|
||||
# self.fields['booking'].disabled = True
|
||||
# self.fields['number'].disabled = True
|
||||
|
||||
|
||||
class ContainerExpeditionForm(ContainerBaseForm):
|
||||
"""
|
||||
Form for updating an existing Container instance.
|
||||
Inherits from ContainerBaseForm.
|
||||
"""
|
||||
class Meta(ContainerBaseForm.Meta):
|
||||
fields = ['number', 'expedition_vehicle', 'position', 'line', 'container_type', 'damages', 'heavy_damaged']
|
||||
|
||||
@@ -32,4 +51,4 @@ class ContainerExpeditionForm(ContainerBaseForm):
|
||||
readonly_fields = ['number', 'position', 'line', 'container_type', 'damages', 'heavy_damaged']
|
||||
for field in readonly_fields:
|
||||
self.fields[field].widget.attrs['readonly'] = True
|
||||
self.fields[field].disabled = True
|
||||
# self.fields[field].disabled = True
|
||||
Reference in New Issue
Block a user