From 5ae2336abc50f6874e5c0df785d3dbe5016d459d Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 10 Sep 2015 16:19:54 +0300 Subject: Fix MultipleObjectsReturned exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We cannot enforce SN uniqueness so let’s just use the first match when creating order with device SN --- servo/views/gsx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'servo/views') diff --git a/servo/views/gsx.py b/servo/views/gsx.py index 0269462..908e9f5 100644 --- a/servo/views/gsx.py +++ b/servo/views/gsx.py @@ -75,12 +75,12 @@ def import_repair(request, order_pk, device_pk): form = ImportForm(request.POST) if form.is_valid(): confirmation = form.cleaned_data['confirmation'] - try: repair = Repair.create_from_gsx(confirmation, order, device, request.user) + messages.success(request, _('GSX repair %s imported successfully' % confirmation)) return redirect(repair) except Exception as e: messages.error(request, e) @@ -100,7 +100,7 @@ def return_label(request, repair, part): repair.connect_gsx(request.user) label_data = repair.get_return_label(part) return HttpResponse(label_data, content_type="application/pdf") - except gsxws.GsxError, e: + except gsxws.GsxError as e: messages.error(request, e) return redirect(repair.order) -- cgit v1.2.3