diff options
author | Filipp Lepalaan <filipp@mac.com> | 2021-05-24 12:54:22 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2021-05-24 12:54:22 +0300 |
commit | 8dc99fdbe3ceb59a6e49b5038a44c073ec0a308c (patch) | |
tree | ddf2d09a0a46e4d321dcc63eb56e410385b74c3d /servo/views | |
parent | 80d05a3ba16c09e356a699ab1b1db837f785d313 (diff) | |
download | Servo-8dc99fdbe3ceb59a6e49b5038a44c073ec0a308c.tar.gz Servo-8dc99fdbe3ceb59a6e49b5038a44c073ec0a308c.tar.bz2 Servo-8dc99fdbe3ceb59a6e49b5038a44c073ec0a308c.zip |
Fix GSX parts DB upload
Diffstat (limited to 'servo/views')
-rw-r--r-- | servo/views/product.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/servo/views/product.py b/servo/views/product.py index 4c7f96f..d2c6750 100644 --- a/servo/views/product.py +++ b/servo/views/product.py @@ -8,6 +8,7 @@ from django.db import IntegrityError from django.contrib import messages from django.core.cache import cache from django.http import HttpResponse +from django.core.management import call_command from django.utils.translation import ugettext as _ from django.forms.models import inlineformset_factory from django.contrib.contenttypes.models import ContentType @@ -108,14 +109,20 @@ def upload_gsx_parts(request, group=None): form = PartsImportForm(request.POST, request.FILES) if form.is_valid(): + data = form.cleaned_data - filename = "servo/uploads/products/partsdb.csv" + filename = "uploads/products/partsdb.csv" destination = open(filename, "wb+") for chunk in data['partsdb'].chunks(): destination.write(chunk) - messages.success(request, _("Parts database uploaded for processing")) + call_command('importparts', filename, data['currency'], + update_prices=data['update_prices'], + import_vintage=data['import_vintage'], + ) + + messages.success(request, _("Parts database uploaded for processing...")) return redirect(list_products) data['form'] = form |