From b996e63329b6f1895b1308165480e85c3a72bf13 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sun, 8 Nov 2015 20:15:05 +0200 Subject: Diagnostics fixes --- servo/models/customer.py | 6 ++++++ servo/models/device.py | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'servo/models') 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() -- cgit v1.2.3