aboutsummaryrefslogtreecommitdiffstats
path: root/servo/models
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-11-28 17:57:57 +0200
committerFilipp Lepalaan <filipp@mac.com>2015-11-28 17:57:57 +0200
commitb4857400e13469785df9e34713e0bc55f77759e6 (patch)
tree0c0043fa4f11cdb5e8576132ad6afdc63ed35517 /servo/models
parent57c46eff8a61a56658242306d139e86b84f01f5d (diff)
downloadServo-b4857400e13469785df9e34713e0bc55f77759e6.tar.gz
Servo-b4857400e13469785df9e34713e0bc55f77759e6.tar.bz2
Servo-b4857400e13469785df9e34713e0bc55f77759e6.zip
Fix issue with showing GSX repair history
Diffstat (limited to 'servo/models')
-rw-r--r--servo/models/device.py24
1 files changed, 22 insertions, 2 deletions
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)