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 18s
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 4s
82 lines
3.0 KiB
Python
82 lines
3.0 KiB
Python
from django import forms
|
|
|
|
from .models import Box, BoxType, Thing, ThingFile, ThingLink
|
|
|
|
|
|
class ThingForm(forms.ModelForm):
|
|
"""Form for adding/editing a Thing."""
|
|
|
|
class Meta:
|
|
model = Thing
|
|
fields = ('name', 'description', 'picture')
|
|
widgets = {
|
|
'name': forms.TextInput(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 ThingFileForm(forms.ModelForm):
|
|
"""Form for adding a file to a Thing."""
|
|
|
|
class Meta:
|
|
model = ThingFile
|
|
fields = ('title', 'file')
|
|
widgets = {
|
|
'title': forms.TextInput(attrs={'style': 'width: 100%; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
|
|
'file': forms.FileInput(attrs={'style': 'width: 100%;'}),
|
|
}
|
|
|
|
|
|
class ThingLinkForm(forms.ModelForm):
|
|
"""Form for adding a link to a Thing."""
|
|
|
|
class Meta:
|
|
model = ThingLink
|
|
fields = ('title', 'url')
|
|
widgets = {
|
|
'title': forms.TextInput(attrs={'style': 'width: 100%; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
|
|
'url': forms.URLInput(attrs={'style': 'width: 100%; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;'}),
|
|
}
|
|
|
|
|
|
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
|
|
)
|