From b4857400e13469785df9e34713e0bc55f77759e6 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sat, 28 Nov 2015 17:57:57 +0200 Subject: Fix issue with showing GSX repair history --- servo/models/device.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'servo/models') diff --git a/servo/models/device.py b/servo/models/device.py index 85abeb9..d422f92 100644 --- a/servo/models/device.py +++ b/servo/models/device.py @@ -480,8 +480,11 @@ class Device(models.Model): self.pk]) def get_purchase_country(self): - # Return device's purchase country, can be 2-letter code (from checkin) or - # full country name (from GSX) + """ + Returns device's purchase country + can be 2-letter code (from checkin) or + full country name (from GSX) + """ from django_countries import countries if len(self.purchase_country) > 2: @@ -502,6 +505,23 @@ class Device(models.Model): diags.shipTo = request.user.location.gsx_shipto return diags.fetch_suites() + def get_gsx_repairs(self): + """ + Returns this device's GSX repairs, if any + """ + device = gsxws.Product(self.get_sn()) + results = [] + + for i, p in enumerate(device.repairs()): + d = {'purchaseOrderNumber': p.purchaseOrderNumber} + d['repairConfirmationNumber'] = p.repairConfirmationNumber + d['createdOn'] = p.createdOn + d['customerName'] = p.customerName.encode('utf-8') + d['repairStatus'] = p.repairStatus + results.append(d) + + return results + def __unicode__(self): return '%s (%s)' % (self.description, self.sn) -- cgit v1.2.3