Files
labhelper/boxes/forms.py
Adrian A. Baumann acde0cb2f8
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 20s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 5s
Box management page added
2026-01-01 14:11:33 +01:00

59 lines
2.2 KiB
Python

from django import forms
from .models import Box, BoxType, Thing
class ThingForm(forms.ModelForm):
"""Form for adding a Thing."""
class Meta:
model = Thing
fields = ('name', 'thing_type', 'description', 'picture')
widgets = {
'name': forms.TextInput(attrs={'class': 'form-control'}),
'thing_type': forms.Select(attrs={'class': 'form-control'}),
'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 4}),
}
class ThingPictureForm(forms.ModelForm):
"""Form for uploading/changing a Thing picture."""
class Meta:
model = Thing
fields = ('picture',)
class BoxTypeForm(forms.ModelForm):
"""Form for adding/editing a BoxType."""
class Meta:
model = BoxType
fields = ('name', 'width', 'height', 'length')
widgets = {
'name': forms.TextInput(attrs={'style': 'width: 100%; max-width: 300px; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
'width': forms.NumberInput(attrs={'style': 'width: 100%; max-width: 150px; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
'height': forms.NumberInput(attrs={'style': 'width: 100%; max-width: 150px; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
'length': forms.NumberInput(attrs={'style': 'width: 100%; max-width: 150px; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
}
class BoxForm(forms.ModelForm):
"""Form for adding/editing a Box."""
class Meta:
model = Box
fields = ('id', 'box_type')
widgets = {
'id': forms.TextInput(attrs={'style': 'width: 100%; max-width: 200px; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px; text-transform: uppercase;'}),
'box_type': forms.Select(attrs={'style': 'width: 100%; max-width: 300px; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
}
ThingFormSet = forms.modelformset_factory(
Thing,
form=ThingForm,
extra=1,
can_delete=False
)