POST the data back again

This commit is contained in:
Oliver Walters 2019-06-28 19:48:22 +10:00
parent fb96651c15
commit 58336482fe
3 changed files with 9 additions and 5 deletions

View File

@ -79,7 +79,7 @@ class BomUploadManager:
except tablib.UnsupportedFormat:
raise ValidationError({'bom_file': _('Error reading BOM file (invalid data)')})
def guess_headers(self, header, threshold=80):
def guess_header(self, header, threshold=80):
""" Try to match a header (from the file) to a list of known headers
Args:
@ -145,7 +145,11 @@ class BomUploadManager:
rows = []
for i in range(self.row_count()):
row = self.get_row_data(i)
row = {
'data': self.get_row_data(i),
'index': i
}
if row:
rows.append(row)

View File

@ -25,6 +25,7 @@
<option value='{{ req }}'{% if req == col.guess %}selected='selected'{% endif %}>{{ req }}</option>
{% endfor %}
</select>
<input type='hidden' name='col_{{ forloop.counter0 }}' value='{{ col.name }}'/>
{{ col.name }}
</th>
{% endfor %}
@ -34,8 +35,9 @@
{% for row in bom_rows %}
<tr>
<td>{% add forloop.counter 1 %}</td>
{% for item in row %}
{% for item in row.data %}
<td>
<input type='hidden' name='row_{{ row.index }}_col_{{ forloop.counter0 }}' value='{{ item }}'/>
{{ item }}
</td>
{% endfor %}

View File

@ -721,8 +721,6 @@ class BomUpload(AjaxView, FormMixin):
form = part_forms.BomUploadSelectFields
self.ajax_template_name = 'part/bom_upload/select_fields.html'
# Try to guess at the
# Provide context to the next form
ctx = {
'req_cols': BomUploadManager.HEADERS,