2018-04-14 15:18:12 +00:00
|
|
|
from django import forms
|
|
|
|
from crispy_forms.helper import FormHelper
|
|
|
|
from crispy_forms.layout import Submit
|
|
|
|
|
2018-04-15 11:29:24 +00:00
|
|
|
from .models import Part, PartCategory, BomItem
|
2018-04-14 15:18:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EditPartForm(forms.ModelForm):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditPartForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
|
|
|
|
self.helper.form_id = 'id-edit-part-form'
|
|
|
|
self.helper.form_method = 'post'
|
|
|
|
|
|
|
|
self.helper.add_input(Submit('submit', 'Submit'))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Part
|
|
|
|
fields = [
|
|
|
|
'category',
|
|
|
|
'name',
|
|
|
|
'description',
|
|
|
|
'IPN',
|
|
|
|
'URL',
|
|
|
|
'minimum_stock',
|
|
|
|
'trackable',
|
2018-04-15 14:30:57 +00:00
|
|
|
'purchaseable',
|
2018-04-15 01:40:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class EditCategoryForm(forms.ModelForm):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditCategoryForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
|
|
|
|
self.helper.form_id = 'id-edit-part-form'
|
|
|
|
self.helper.form_method = 'post'
|
|
|
|
|
|
|
|
self.helper.add_input(Submit('submit', 'Submit'))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PartCategory
|
|
|
|
fields = [
|
|
|
|
'parent',
|
|
|
|
'name',
|
|
|
|
'description'
|
2018-04-15 11:29:24 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class EditBomItemForm(forms.ModelForm):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditBomItemForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
|
|
|
|
self.helper.form_id = 'id-edit-part-form'
|
|
|
|
self.helper.form_method = 'post'
|
2018-04-15 15:02:17 +00:00
|
|
|
|
2018-04-15 11:29:24 +00:00
|
|
|
self.helper.add_input(Submit('submit', 'Submit'))
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = BomItem
|
|
|
|
fields = [
|
|
|
|
'part',
|
|
|
|
'sub_part',
|
|
|
|
'quantity'
|
2018-04-15 15:02:17 +00:00
|
|
|
]
|