diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-11-08 20:15:05 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-11-08 20:15:05 +0200 |
commit | b996e63329b6f1895b1308165480e85c3a72bf13 (patch) | |
tree | 61dfe561f60cfa8a5f42b499b57de318995b0875 /servo/models | |
parent | f688c757234feadbc9ce5e559d70f4d9d40a0bec (diff) | |
download | Servo-b996e63329b6f1895b1308165480e85c3a72bf13.tar.gz Servo-b996e63329b6f1895b1308165480e85c3a72bf13.tar.bz2 Servo-b996e63329b6f1895b1308165480e85c3a72bf13.zip |
Diagnostics fixes
Diffstat (limited to 'servo/models')
-rw-r--r-- | servo/models/customer.py | 6 | ||||
-rw-r--r-- | servo/models/device.py | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/servo/models/customer.py b/servo/models/customer.py index a01ebdf..a6609d0 100644 --- a/servo/models/customer.py +++ b/servo/models/customer.py @@ -159,6 +159,12 @@ class Customer(MPTTModel): fmt = phonenumbers.PhoneNumberFormat.NATIONAL return phonenumbers.format_number(n, fmt) + def get_company_name(self): + """Since we don't really have a "company" field in Servo, + climb up the parent tree and return a concated name + """ + return ', '.join([i for i in self.get_parents()]) + def valid_email(self): """ Returns email address or raises ValidationError diff --git a/servo/models/device.py b/servo/models/device.py index 3c162df..b7e1ca3 100644 --- a/servo/models/device.py +++ b/servo/models/device.py @@ -280,6 +280,7 @@ class Device(models.Model): return device def to_gsx(self): + """Returns the corresponding gsxws Product object""" if len(self.imei): return gsxws.Product(self.imei) return gsxws.Product(self.sn) @@ -425,7 +426,15 @@ class Device(models.Model): Fetch GSX iOS or Repair diagnostics based on device type """ GsxAccount.default(user) - return self.to_gsx().diagnostics() + from gsxws.diagnostics import Diagnostics + + if len(self.imei): + diags = Diagnostics(alternateDeviceId=self.imei) + else: + diags = Diagnostics(serialNumber=self.sn) + + diags.shipTo = user.location.gsx_shipto + return diags.fetch() def get_warranty(self): return gsxws.Product(self.sn).warranty() |