mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Bank CSV import: Allow dealing with files of more than a few hundred lines during first import
This commit is contained in:
@@ -47,22 +47,30 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
{% for row in rows|slice:":100" %}
|
||||
{% with forloop.counter0 as rowid %}
|
||||
<tr>
|
||||
<td></td>
|
||||
{% for col in row %}
|
||||
<td>{{ col }}<input type="hidden" name="col[{{ rowid }}][{{ forloop.counter0 }}]"
|
||||
value="{{ col }}" /></td>
|
||||
<td>{{ col }}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% if rows|length > 100 %}
|
||||
<tr>
|
||||
<td colspan="{{ rows.0|length|add:1 }}" class="text-center">
|
||||
<em>{% trans "More data was uploaded but is not shown here. It will still be processed" %}</em>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
<input type="hidden" name="cols" value="{{ rows.0|length }}" />
|
||||
<input type="hidden" name="rows" value="{{ rows|length }}" />
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<input type="hidden" name="cols" value="{{ rows.0|length }}" />
|
||||
<input type="hidden" name="rows" value="{{ rows|length }}" />
|
||||
<textarea class="helper-display-none" name="data">
|
||||
{{ json|escape }}
|
||||
</textarea>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
@@ -347,14 +347,12 @@ class ImportView(ListView):
|
||||
return self.assign_view(data)
|
||||
|
||||
def process_csv_hint(self):
|
||||
data = []
|
||||
for i in range(int(self.request.POST.get('rows'))):
|
||||
data.append(
|
||||
[
|
||||
self.request.POST.get('col[%d][%d]' % (i, j))
|
||||
for j in range(int(self.request.POST.get('cols')))
|
||||
]
|
||||
)
|
||||
try:
|
||||
data = json.loads(self.request.POST.get('data').strip())
|
||||
except ValueError:
|
||||
messages.error(self.request, _('Invalid input data.'))
|
||||
return self.get(self.request, *self.args, **self.kwargs)
|
||||
|
||||
if 'reference' not in self.request.POST:
|
||||
messages.error(self.request, _('You need to select the column containing the payment reference.'))
|
||||
return self.assign_view(data)
|
||||
@@ -382,7 +380,10 @@ class ImportView(ListView):
|
||||
return super().get(self.request)
|
||||
|
||||
def assign_view(self, parsed):
|
||||
ctx = {'rows': parsed}
|
||||
ctx = {
|
||||
'json': json.dumps(parsed),
|
||||
'rows': parsed,
|
||||
}
|
||||
if 'event' in self.kwargs:
|
||||
ctx['basetpl'] = 'pretixplugins/banktransfer/import_base.html'
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user