diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index deaac66d30..d0e1046448 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -2,7 +2,7 @@ from django import forms from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit -from .models import Part +from .models import Part, PartCategory class EditPartForm(forms.ModelForm): @@ -28,4 +28,26 @@ class EditPartForm(forms.ModelForm): 'URL', 'minimum_stock', 'trackable', + ] + + +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_class = 'blueForms' + self.helper.form_method = 'post' + #self.helper.form_action = 'submit' + + self.helper.add_input(Submit('submit', 'Submit')) + + class Meta: + model = PartCategory + fields = [ + 'parent', + 'name', + 'description' ] \ No newline at end of file diff --git a/InvenTree/part/templates/part/category_delete.html b/InvenTree/part/templates/part/category_delete.html new file mode 100644 index 0000000000..03be834e30 --- /dev/null +++ b/InvenTree/part/templates/part/category_delete.html @@ -0,0 +1,50 @@ +{% extends 'base.html' %} + +{% block content %} + +
Deleting this category is a permanent action and cannot be undone.
+ + {% if category.children.all|length > 0 %} +This category contains {{ category.children.all|length }} child categories.
+ If this category is deleted, these child categories will be moved to
+ {% if category.parent %}
+ the '{{ category.parent.name }}' category.
+ {% else %}
+ the top level 'Parts' category.
+ {% endif %}
+
This category contains {{ category.parts.all|length }} parts.
+ {% if category.parent %}
+ If this category is deleted, these parts will be moved to the parent category '{{ category.parent.pathstring }}'
+ {% else %}
+ If this category is deleted, these parts will be moved to the top-level category 'Parts'
+ {% endif %}
+