Cables can now be created.

This commit is contained in:
Matthew Smith
2019-10-08 01:33:38 +01:00
parent 98b9697366
commit fe1541acbf
5 changed files with 58 additions and 40 deletions

View File

@@ -5,21 +5,25 @@ from assets import models
class AssetForm(forms.ModelForm):
class Meta:
model = models.Asset
fields = '__all__'
def clean_date_sold(self):
if self.cleaned_data["date_sold"] and self.cleaned_data["date_acquired"] > self.cleaned_data["date_sold"]:
raise ValidationError("Cannot sell an item before it is acquired")
return self.cleaned_data["date_sold"]
class Meta:
model = models.Asset
fields = '__all__'
widgets = {
'is_cable' : forms.CheckboxInput()
}
class CableForm(AssetForm):
class Meta:
class Meta(AssetForm.Meta):
model = models.Cable
fields = '__all__'
class SupplierForm(forms.ModelForm):
class SupplierForm(forms.Form):
class Meta:
model = models.Supplier
fields = '__all__'