mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Create view / form / URL for PartParameter creation
This commit is contained in:
parent
db834802e3
commit
c68c79ea43
@ -11,6 +11,7 @@ from django import forms
|
|||||||
|
|
||||||
from .models import Part, PartCategory, PartAttachment
|
from .models import Part, PartCategory, PartAttachment
|
||||||
from .models import BomItem
|
from .models import BomItem
|
||||||
|
from .models import PartParameterTemplate, PartParameter
|
||||||
|
|
||||||
|
|
||||||
class PartImageForm(HelperForm):
|
class PartImageForm(HelperForm):
|
||||||
@ -98,6 +99,18 @@ class EditPartForm(HelperForm):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class EditPartParameterForm(HelperForm):
|
||||||
|
""" Form for editing a PartParameter object """
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = PartParameter
|
||||||
|
fields = [
|
||||||
|
'part',
|
||||||
|
'template',
|
||||||
|
'data'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class EditCategoryForm(HelperForm):
|
class EditCategoryForm(HelperForm):
|
||||||
""" Form for editing a PartCategory object """
|
""" Form for editing a PartCategory object """
|
||||||
|
|
||||||
|
@ -1066,6 +1066,11 @@ class PartParameterTemplate(models.Model):
|
|||||||
except PartParameterTemplate.DoesNotExist:
|
except PartParameterTemplate.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def instance_count(self):
|
||||||
|
""" Return the number of instances of this Parameter Template """
|
||||||
|
return self.instances.count()
|
||||||
|
|
||||||
name = models.CharField(max_length=100, help_text='Parameter Name')
|
name = models.CharField(max_length=100, help_text='Parameter Name')
|
||||||
|
|
||||||
units = models.CharField(max_length=25, help_text='Parameter Units', blank=True)
|
units = models.CharField(max_length=25, help_text='Parameter Units', blank=True)
|
||||||
|
@ -7,20 +7,29 @@
|
|||||||
<h4>Part Parameters</h4>
|
<h4>Part Parameters</h4>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<div id='button-toolbar'>
|
||||||
|
<div class='button-toolbar container-fluid' style='float: right;'>
|
||||||
|
<button class='btn btn-success' id='param-create'>New Parameter</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table class='table table-condensed table-striped'>
|
<table id='param-table' class='table table-condensed table-striped' data-toolbar='#button-toolbar'>
|
||||||
<tr>
|
<thead>
|
||||||
<th>Name</th>
|
<tr>
|
||||||
<th>Value</th>
|
<th data-field='name' data-serachable='true'>Name</th>
|
||||||
<th>Units</th>
|
<th data-field='value' data-searchable='true'>Value</th>
|
||||||
</tr>
|
<th data-field='units' data-searchable='true'>Units</th>
|
||||||
{% for param in part.get_parameters %}
|
</tr>
|
||||||
<tr>
|
</thead>
|
||||||
<td>{{ param.template.name }}</td>
|
<tbody>
|
||||||
<td>{{ param.data }}</td>
|
{% for param in part.get_parameters %}
|
||||||
<td>{{ param.template.units }}</td>
|
<tr>
|
||||||
</tr>
|
<td>{{ param.template.name }}</td>
|
||||||
{% endfor %}
|
<td>{{ param.data }}</td>
|
||||||
|
<td>{{ param.template.units }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
@ -29,4 +38,15 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
|
$('#param-table').bootstrapTable({
|
||||||
|
search: true,
|
||||||
|
sortable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#param-create').click(function() {
|
||||||
|
launchModalForm("{% url 'part-param-create' %}?part={{ part.id }}", {
|
||||||
|
reload: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -18,6 +18,10 @@ part_attachment_urls = [
|
|||||||
url(r'^(?P<pk>\d+)/delete/?', views.PartAttachmentDelete.as_view(), name='part-attachment-delete'),
|
url(r'^(?P<pk>\d+)/delete/?', views.PartAttachmentDelete.as_view(), name='part-attachment-delete'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
part_parameter_urls = [
|
||||||
|
url('^new/?', views.PartParameterCreate.as_view(), name='part-param-create'),
|
||||||
|
]
|
||||||
|
|
||||||
part_detail_urls = [
|
part_detail_urls = [
|
||||||
url(r'^edit/?', views.PartEdit.as_view(), name='part-edit'),
|
url(r'^edit/?', views.PartEdit.as_view(), name='part-edit'),
|
||||||
url(r'^delete/?', views.PartDelete.as_view(), name='part-delete'),
|
url(r'^delete/?', views.PartDelete.as_view(), name='part-delete'),
|
||||||
@ -91,6 +95,9 @@ part_urls = [
|
|||||||
# Part attachments
|
# Part attachments
|
||||||
url(r'^attachment/', include(part_attachment_urls)),
|
url(r'^attachment/', include(part_attachment_urls)),
|
||||||
|
|
||||||
|
# Part parameters
|
||||||
|
url(r'^parameter/', include(part_parameter_urls)),
|
||||||
|
|
||||||
# Change category for multiple parts
|
# Change category for multiple parts
|
||||||
url(r'^set-category/?', views.PartSetCategory.as_view(), name='part-set-category'),
|
url(r'^set-category/?', views.PartSetCategory.as_view(), name='part-set-category'),
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import tablib
|
|||||||
from fuzzywuzzy import fuzz
|
from fuzzywuzzy import fuzz
|
||||||
|
|
||||||
from .models import PartCategory, Part, PartAttachment
|
from .models import PartCategory, Part, PartAttachment
|
||||||
|
from .models import PartParameterTemplate, PartParameter
|
||||||
from .models import BomItem
|
from .models import BomItem
|
||||||
from .models import match_part_names
|
from .models import match_part_names
|
||||||
|
|
||||||
@ -1396,6 +1397,15 @@ class PartPricing(AjaxView):
|
|||||||
return self.renderJsonResponse(request, self.form_class(), data=data, context=self.get_pricing(quantity))
|
return self.renderJsonResponse(request, self.form_class(), data=data, context=self.get_pricing(quantity))
|
||||||
|
|
||||||
|
|
||||||
|
class PartParameterCreate(AjaxCreateView):
|
||||||
|
""" View for creating a new PartParameter """
|
||||||
|
|
||||||
|
model = PartParameter
|
||||||
|
form_class = part_forms.EditPartParameterForm
|
||||||
|
ajax_form_title = 'Create Part Parameter'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CategoryDetail(DetailView):
|
class CategoryDetail(DetailView):
|
||||||
""" Detail view for PartCategory """
|
""" Detail view for PartCategory """
|
||||||
model = PartCategory
|
model = PartCategory
|
||||||
|
Loading…
x
Reference in New Issue
Block a user