aboutsummaryrefslogtreecommitdiffstats
path: root/servo/views
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-08-18 23:36:29 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-08-18 23:36:29 +0300
commitb54c9272c9ad8c9900e0c92f95a260235eab4f99 (patch)
treea1742965902bb3f9224446e836728a1a938429b3 /servo/views
parent50fe15e2747c5b9f81e17cb389ccf74f589d4671 (diff)
downloadServo-b54c9272c9ad8c9900e0c92f95a260235eab4f99.tar.gz
Servo-b54c9272c9ad8c9900e0c92f95a260235eab4f99.tar.bz2
Servo-b54c9272c9ad8c9900e0c92f95a260235eab4f99.zip
Cleanup
Diffstat (limited to 'servo/views')
-rw-r--r--servo/views/device.py4
-rw-r--r--servo/views/order.py15
2 files changed, 9 insertions, 10 deletions
diff --git a/servo/views/device.py b/servo/views/device.py
index 0d517f9..be38c35 100644
--- a/servo/views/device.py
+++ b/servo/views/device.py
@@ -37,12 +37,14 @@ from django.template.defaultfilters import slugify
from django.views.decorators.cache import cache_page
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
-from servo.models import Device, Product, GsxAccount, ServiceOrderItem
+from servo.models import Device, Order, Product, GsxAccount, ServiceOrderItem
from servo.forms.devices import DeviceForm, DeviceUploadForm, DeviceSearchForm
+
class RepairDiagnosticResults:
pass
+
class DiagnosticResults(object):
def __init__(self, diags):
if not diags.diagnosticTestData:
diff --git a/servo/views/order.py b/servo/views/order.py
index b00b4e6..27ee5a3 100644
--- a/servo/views/order.py
+++ b/servo/views/order.py
@@ -169,9 +169,6 @@ def prepare_list_view(request, args):
data['orders'] = order_pages
data['subtitle'] = _("%d search results") % orders.count()
- # @FIXME!!! how to handle this with jsonserializer???
- #request.session['order_queryset'] = orders
-
return data
@@ -221,7 +218,7 @@ def close(request, pk):
"""
Closes this Service Order
"""
- order = Order.objects.get(pk=pk)
+ order = get_object_or_404(Order, pk=pk)
if request.method == 'POST':
try:
@@ -245,7 +242,7 @@ def close(request, pk):
@permission_required("servo.delete_order")
def reopen_order(request, pk):
- order = Order.objects.get(pk=pk)
+ order = get_object_or_404(Order, pk=pk)
msg = order.reopen(request.user)
messages.success(request, msg)
return redirect(order)
@@ -305,7 +302,7 @@ def list_orders(request):
args = request.GET.copy()
default = {'state': Order.STATE_QUEUED}
- if len(args) < 1: # search form not submitted
+ if len(args) < 2: # search form not submitted
f = request.session.get("order_search_filter", default)
args = QueryDict('', mutable=True)
args.update(f)
@@ -450,7 +447,7 @@ def delete(request, pk):
@permission_required('servo.change_order')
def toggle_follow(request, order_id):
- order = Order.objects.get(pk=order_id)
+ order = get_object_or_404(Order, pk=order_id)
data = {'icon': "open", 'action': _("Follow")}
if request.user in order.followed_by.all():
@@ -617,7 +614,7 @@ def add_device(request, pk, device_id=None, sn=None):
try:
event = order.add_device(device, request.user)
messages.success(request, event)
- except Exception, e:
+ except Exception as e:
messages.error(request, e)
return redirect(order)
@@ -721,7 +718,7 @@ def edit_product(request, pk, item_id):
messages.success(request, _(u"Product %s saved") % item.code)
return redirect(order)
- except Exception, e:
+ except Exception as e:
messages.error(request, e)
product = item.product