Started adding functionality for assets and cables forms to be dynamically swapped

This commit is contained in:
Matthew Smith
2019-10-05 21:16:03 +01:00
parent e3cbcbd151
commit 7359e05427
2 changed files with 11 additions and 0 deletions

View File

@@ -14,6 +14,11 @@ class AssetForm(forms.ModelForm):
raise ValidationError("Cannot sell an item before it is acquired")
return self.cleaned_data["date_sold"]
class CableForm(AssetForm):
class Meta:
model = models.Cable
fields = '__all__'
class SupplierForm(forms.ModelForm):
class Meta:
model = models.Supplier

View File

@@ -13,6 +13,12 @@ from dateutil import parser
import simplejson as json
from assets import models, forms
class CableFormMixin:
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["cableForm"] = forms.CableForm
return context
class AssetList(LoginRequiredMixin, generic.ListView):
model = models.Asset
template_name = 'asset_list.html'