mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Upload the selected BOM file
This commit is contained in:
parent
802255c62d
commit
4008a9fb45
@ -1,25 +0,0 @@
|
|||||||
{% extends "modal_form.html" %}
|
|
||||||
|
|
||||||
{% block pre_form_content %}
|
|
||||||
|
|
||||||
<h4>Step 1 of 3 - Select BOM File</h4>
|
|
||||||
|
|
||||||
{{ block.super }}
|
|
||||||
|
|
||||||
<p>Select a BOM file to upload for:<br>
|
|
||||||
<b>{{ part.name }} - <i>{{ part.description }}</i></b>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>The BOM file must contain the required named columns as provided in the <a href="/part/bom_template/">BOM Upload Template</a></a></p>
|
|
||||||
|
|
||||||
<b>Notes:</b>
|
|
||||||
<ul>
|
|
||||||
<li>Supported file formats: <i>.csv, .tsv, .xls, .xlsx</li>
|
|
||||||
<li>Maximum of 1000 lines per BOM</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block form_data %}
|
|
||||||
<input type='hidden' name='form_step' value='select_file'/>
|
|
||||||
{% endblock %}
|
|
@ -8,7 +8,9 @@
|
|||||||
<h4>Upload Bill of Materials</h4>
|
<h4>Upload Bill of Materials</h4>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>The BOM file must contain the required named columns as provided in the <a href="/part/bom_template/">BOM Upload Template</a></a></p>
|
<div class='alert alert-info alert-block'>
|
||||||
|
<p>The BOM file must contain the required named columns as provided in the <a href="/part/bom_template/">BOM Upload Template</a></a></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form method="post" action='' class='js-modal-form' enctype="multipart/form-data">
|
<form method="post" action='' class='js-modal-form' enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
@ -27,7 +27,7 @@ part_detail_urls = [
|
|||||||
url(r'^make-variant/', views.MakePartVariant.as_view(), name='make-part-variant'),
|
url(r'^make-variant/', views.MakePartVariant.as_view(), name='make-part-variant'),
|
||||||
url(r'^pricing/', views.PartPricing.as_view(), name='part-pricing'),
|
url(r'^pricing/', views.PartPricing.as_view(), name='part-pricing'),
|
||||||
|
|
||||||
url(r'^bom-upload/?', views.BomUpload.as_view(template_name='part/bom_upload/upload_file.html'), name='upload-bom'),
|
url(r'^bom-upload/?', views.BomUpload.as_view(), name='upload-bom'),
|
||||||
|
|
||||||
url(r'^variants/?', views.PartDetail.as_view(template_name='part/variants.html'), name='part-variants'),
|
url(r'^variants/?', views.PartDetail.as_view(template_name='part/variants.html'), name='part-variants'),
|
||||||
url(r'^stock/?', views.PartDetail.as_view(template_name='part/stock.html'), name='part-stock'),
|
url(r'^stock/?', views.PartDetail.as_view(template_name='part/stock.html'), name='part-stock'),
|
||||||
|
@ -647,7 +647,7 @@ class BomUpload(FormView):
|
|||||||
During these steps, data are passed between the server/client as JSON objects.
|
During these steps, data are passed between the server/client as JSON objects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template_name = 'part/bom_upload/select_file.html'
|
template_name='part/bom_upload/upload_file.html'
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
part = self.get_object()
|
part = self.get_object()
|
||||||
@ -715,16 +715,9 @@ class BomUpload(FormView):
|
|||||||
for k, v in errors.items():
|
for k, v in errors.items():
|
||||||
self.form.errors[k] = v
|
self.form.errors[k] = v
|
||||||
|
|
||||||
data = {
|
if 0 and bom_file_valid:
|
||||||
'form_valid': False
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx = {}
|
|
||||||
|
|
||||||
if bom_file_valid:
|
|
||||||
# BOM file is valid? Proceed to the next step!
|
# BOM file is valid? Proceed to the next step!
|
||||||
form = part_forms.BomUploadSelectFields
|
form = part_forms.BomUploadSelectFields
|
||||||
self.ajax_template_name = 'part/bom_upload/select_fields.html'
|
|
||||||
|
|
||||||
# Provide context to the next form
|
# Provide context to the next form
|
||||||
ctx = {
|
ctx = {
|
||||||
@ -734,8 +727,9 @@ class BomUpload(FormView):
|
|||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
form = self.form
|
form = self.form
|
||||||
|
form.errors['bom_file'] = [_('no errors')]
|
||||||
|
|
||||||
return self.renderJsonResponse(self.request, form, data=data, context=ctx)
|
return self.render_to_response(self.get_context_data(form=form))
|
||||||
|
|
||||||
def handleFieldSelection(self):
|
def handleFieldSelection(self):
|
||||||
""" Handle the output of the field selection form.
|
""" Handle the output of the field selection form.
|
||||||
@ -855,7 +849,7 @@ class BomUpload(FormView):
|
|||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
self.part = get_object_or_404(Part, pk=self.kwargs['pk'])
|
self.part = get_object_or_404(Part, pk=self.kwargs['pk'])
|
||||||
self.form = self.get_form()
|
self.form = self.get_form(self.get_form_class())
|
||||||
|
|
||||||
# Did the user POST a file named bom_file?
|
# Did the user POST a file named bom_file?
|
||||||
|
|
||||||
@ -866,11 +860,7 @@ class BomUpload(FormView):
|
|||||||
elif form_step == 'select_fields':
|
elif form_step == 'select_fields':
|
||||||
return self.handleFieldSelection()
|
return self.handleFieldSelection()
|
||||||
|
|
||||||
data = {
|
return self.render_to_response(self.get_context_data(form=self.form))
|
||||||
'form_valid': False,
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.renderJsonResponse(request, self.form, data=data)
|
|
||||||
|
|
||||||
|
|
||||||
class BomUploadTemplate(AjaxView):
|
class BomUploadTemplate(AjaxView):
|
||||||
|
Loading…
Reference in New Issue
Block a user