aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
Diffstat (limited to 'servo')
-rw-r--r--servo/defaults.py17
-rw-r--r--servo/forms/devices.py3
2 files changed, 12 insertions, 8 deletions
diff --git a/servo/defaults.py b/servo/defaults.py
index cf91559..8b81c92 100644
--- a/servo/defaults.py
+++ b/servo/defaults.py
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
+"""Contains callables for model default values."""
-"""
-defaults.py
-Contains callables for model default values
-"""
import uuid
import settings
import local_settings
@@ -12,9 +9,10 @@ from decimal import Decimal
from django.db import connection
from django.core.cache import cache
+
def _get(key):
cached = cache.get('defaults', {})
-
+
if not cached.get(key):
cursor = connection.cursor()
cursor.execute("SELECT key, value FROM servo_configuration")
@@ -25,27 +23,36 @@ def _get(key):
return cached.get(key)
+
def country():
+ """Default country code for this installation."""
return local_settings.INSTALL_COUNTRY
+
def site_id():
return settings.SITE_ID
+
def locale():
return settings.INSTALL_LOCALE
+
def uid():
return str(uuid.uuid1()).upper()
+
def subject():
return _get('default_subject')
+
def vat():
val = _get('pct_vat') or 0.0
return Decimal(val)
+
def margin(sum=0.0):
return _get('pct_margin') or 0.0
+
def gsx_account():
return _get('gsx_account')
diff --git a/servo/forms/devices.py b/servo/forms/devices.py
index e3c1dae..8d41c02 100644
--- a/servo/forms/devices.py
+++ b/servo/forms/devices.py
@@ -12,12 +12,10 @@ product_lines = [(k, x['name']) for k, x in Device.PRODUCT_LINES.items()]
class DeviceSearchForm(forms.Form):
product_line = forms.MultipleChoiceField(
- #widget=forms.CheckboxSelectMultiple,
choices=product_lines,
required=False
)
warranty_status = forms.MultipleChoiceField(
- #widget=forms.CheckboxSelectMultiple,
choices=Device.WARRANTY_CHOICES,
required=False,
)
@@ -73,4 +71,3 @@ class DeviceUploadForm(forms.Form):
class DiagnosticsForm(forms.Form):
pass
-