aboutsummaryrefslogtreecommitdiffstats
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
parent50fe15e2747c5b9f81e17cb389ccf74f589d4671 (diff)
downloadServo-b54c9272c9ad8c9900e0c92f95a260235eab4f99.tar.gz
Servo-b54c9272c9ad8c9900e0c92f95a260235eab4f99.tar.bz2
Servo-b54c9272c9ad8c9900e0c92f95a260235eab4f99.zip
Cleanup
-rw-r--r--servo/models/common.py3
-rw-r--r--servo/urls/checkin.py2
-rw-r--r--servo/views/device.py4
-rw-r--r--servo/views/order.py15
4 files changed, 12 insertions, 12 deletions
diff --git a/servo/models/common.py b/servo/models/common.py
index 3c06d84..4338405 100644
--- a/servo/models/common.py
+++ b/servo/models/common.py
@@ -244,9 +244,10 @@ class GsxAccount(models.Model):
@classmethod
def get_default_account(cls):
+ from servo.lib.utils import empty
act_pk = Configuration.conf('gsx_account')
- if act_pk in ('', None,):
+ if empty(act_pk):
raise ValueError(_('Default GSX account not configured'))
return GsxAccount.objects.get(pk=act_pk)
diff --git a/servo/urls/checkin.py b/servo/urls/checkin.py
index c8111d0..b7a7780 100644
--- a/servo/urls/checkin.py
+++ b/servo/urls/checkin.py
@@ -33,7 +33,7 @@ from servo.views.checkin import *
urlpatterns = patterns(
'',
url(r'^$', index, name='checkin-index'),
- url(r'^sn/$', RedirectView.as_view(url='/checkin/')),
+ url(r'^sn/$', RedirectView.as_view(url='/checkin/', permanent=True)),
url(r'^customer/$', get_customer, name='checkin-get_customer'),
url(r'^reset/$', reset, name='checkin-reset'),
url(r'^status/$', status, name='checkin-status'),
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