aboutsummaryrefslogtreecommitdiffstats
path: root/servo/models
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2016-02-29 12:15:32 +0200
committerFilipp Lepalaan <filipp@mac.com>2016-02-29 12:15:32 +0200
commit27978c9011196be5a47933eb62efb3ddab17f328 (patch)
tree3e4ee2b5cab77ffbc88c955ee6364aae76527c44 /servo/models
parentf3cd067dd262dd0a6384a2122375dc3f10e3ebcf (diff)
downloadServo-27978c9011196be5a47933eb62efb3ddab17f328.tar.gz
Servo-27978c9011196be5a47933eb62efb3ddab17f328.tar.bz2
Servo-27978c9011196be5a47933eb62efb3ddab17f328.zip
Load CompTIA options from GSX
Closes issue #3
Diffstat (limited to 'servo/models')
-rw-r--r--servo/models/order.py4
-rw-r--r--servo/models/parts.py24
-rw-r--r--servo/models/repair.py12
3 files changed, 26 insertions, 14 deletions
diff --git a/servo/models/order.py b/servo/models/order.py
index aad1932..2fa3097 100644
--- a/servo/models/order.py
+++ b/servo/models/order.py
@@ -932,13 +932,13 @@ class ServiceOrderItem(AbstractOrderItem):
blank=True,
default="",
max_length=4,
- verbose_name=_("symptom code")
+ verbose_name=_("Symptom code")
)
comptia_modifier = models.CharField(
blank=True,
default="",
max_length=1,
- verbose_name=_("symptom modifier")
+ verbose_name=_("Symptom modifier")
)
def can_create_device(self):
diff --git a/servo/models/parts.py b/servo/models/parts.py
index 013b4cb..ab54e79 100644
--- a/servo/models/parts.py
+++ b/servo/models/parts.py
@@ -8,6 +8,7 @@ from django.utils import timezone
from django.core.files import File
from django.utils.translation import ugettext_lazy as _
+from servo.models import GsxAccount
from servo.models.shipments import Shipment
from servo.models.order import ServiceOrderItem
from servo.models.purchases import PurchaseOrder, PurchaseOrderItem
@@ -19,15 +20,23 @@ def symptom_modifiers():
def symptom_codes(group):
"""
- Return symptom codes for component group
+ Return CompTIA symptom codes for component group
"""
if group == '':
return
- data = yaml.load(open("servo/fixtures/comptia.yaml", "r"))
- symptoms = data[group]['symptoms']
- srted = sorted(symptoms)
- codes = [(k, "%s - %s " % (k, symptoms[k])) for k in srted]
+ symptoms = {}
+
+ try:
+ act = GsxAccount.fallback()
+ codes = gsxws.comptia.fetch()[group]
+ for k, v in codes:
+ symptoms[k] = v
+ except gsxws.GsxError as e:
+ data = yaml.load(open("servo/fixtures/comptia.yaml", "r"))
+ symptoms = data[group]['symptoms']
+
+ codes = [(k, "%s - %s " % (k, symptoms[k])) for k in sorted(symptoms)]
return codes
@@ -344,8 +353,11 @@ class ServicePart(models.Model):
return repair.update_kgb_sn(self.order_item.sn)
def can_update_sn(self):
+ """
+ Can update SN to GSX only if SN defined
+ """
soi = self.order_item
- return not soi.sn == ''
+ return soi.sn != ''
def update_sn(self):
# CTS parts not eligible for SN update
diff --git a/servo/models/repair.py b/servo/models/repair.py
index ba52980..d947055 100644
--- a/servo/models/repair.py
+++ b/servo/models/repair.py
@@ -85,13 +85,13 @@ class ChecklistItemValue(models.Model):
class ActiveManager(models.Manager):
- """
- GSX repairs that have been submitted, and not marked complete
- """
use_for_related_fields = True
-
- def active(self, **kwargs):
- return self.filter(completed_at=None, **kwargs).exclude(submitted_at=None)
+
+ def active(self):
+ """
+ GSX repairs that have been submitted, and not marked complete
+ """
+ return self.filter(completed_at=None).exclude(submitted_at=None)
class Repair(models.Model):