aboutsummaryrefslogtreecommitdiffstats
path: root/servo/views
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2016-02-03 13:16:21 +0200
committerFilipp Lepalaan <filipp@mac.com>2016-02-03 13:16:21 +0200
commit5091347c3ee9ef1bb92b3bc4b8b802f48326f30a (patch)
treec7428885fbdf77ef2d582dec1ca68cf2ed23de24 /servo/views
parent5976f01b0affa0351e94c8893123acc118b4015c (diff)
downloadServo-5091347c3ee9ef1bb92b3bc4b8b802f48326f30a.tar.gz
Servo-5091347c3ee9ef1bb92b3bc4b8b802f48326f30a.tar.bz2
Servo-5091347c3ee9ef1bb92b3bc4b8b802f48326f30a.zip
Cleanup
Diffstat (limited to 'servo/views')
-rw-r--r--servo/views/device.py8
-rw-r--r--servo/views/gsx.py15
2 files changed, 14 insertions, 9 deletions
diff --git a/servo/views/device.py b/servo/views/device.py
index de4cf96..2032a15 100644
--- a/servo/views/device.py
+++ b/servo/views/device.py
@@ -162,6 +162,8 @@ def edit_device(request, pk=None, product_line=None, model=None):
def view_device(request, pk, product_line=None, model=None):
data = prep_detail_view(request, pk, product_line, model)
+ data['repairs'] = data['device'].repair_set.all()
+ data['orders'] = data['device'].order_set.all()
return render(request, "devices/view.html", data)
@@ -193,7 +195,7 @@ def find(request):
page = request.GET.get("page")
devices = paginate(results, page, 100)
-
+
return render(request, "devices/find.html", locals())
@@ -205,7 +207,7 @@ def parts(request, pk, order_id, queue_id):
and the Location's corresponding GSX account
"""
from decimal import InvalidOperation
-
+
device = get_object_or_404(Device, pk=pk)
order = device.order_set.get(pk=order_id)
@@ -366,7 +368,7 @@ def search_gsx_repairs(request, pk):
Performs async GSX search for this device's GSX repairs
"""
device = get_object_or_404(Device, pk=pk)
-
+
try:
GsxAccount.default(request.user)
results = {'results': device.get_gsx_repairs()}
diff --git a/servo/views/gsx.py b/servo/views/gsx.py
index 4208c23..12be6c9 100644
--- a/servo/views/gsx.py
+++ b/servo/views/gsx.py
@@ -64,7 +64,7 @@ def import_repair(request, order_pk, device_pk):
return render(request, "repairs/import_repair.html", locals())
-
+
@permission_required("servo.change_order")
def return_label(request, repair, part):
"""
@@ -134,9 +134,12 @@ def remove_part(request, repair, part):
def delete_repair(request, repair_id):
+ """
+ Deletes this unsubmitted GSX repair
+ """
repair = get_object_or_404(Repair, pk=repair_id)
-
- if repair.submitted_at:
+
+ if repair.is_submitted():
messages.error(request, _('Submitted repairs cannot be deleted'))
return redirect(repair.order)
@@ -193,7 +196,7 @@ def prep_edit_view(request, repair, order=None, device=None):
if not order.customer:
raise ValueError(_("Cannot create GSX repair without valid customer data"))
-
+
customer = order.customer.gsx_address(request.user.location)
customer_form = GsxCustomerForm(initial=customer)
@@ -292,7 +295,7 @@ def create_repair(request, order_id, device_id, type):
"""
from datetime import timedelta
from django.utils import timezone
-
+
order = get_object_or_404(Order, pk=order_id)
device = order.devices.get(pk=device_id)
@@ -328,7 +331,7 @@ def repair_details(request, confirmation):
except Exception as e:
data = {'error': e}
return render(request, "snippets/error_modal.html", data)
-
+
data = {'repair': repair}
if request.method == "POST":