Browse Source

The resources units should be modifiable as a (local_)settings

Fix: https://code.ffdn.org/jocelyn/transparency/issues/11
Étienne Deparis 6 years ago
parent
commit
cfdacd5620
2 changed files with 11 additions and 16 deletions
  1. 1 15
      costs/models.py
  2. 10 1
      transparency/settings.py

+ 1 - 15
costs/models.py

@@ -142,24 +142,10 @@ class AbstractItem(models.Model):
 
 
 class AbstractResource(AbstractItem):
-    UNIT_AMP = 'a'
-    UNIT_MBPS = 'mbps'
-    UNIT_U = 'u'
-    UNIT_IPV4 = 'ipv4'
-    UNIT_ETHERNET_PORT = 'eth'
-    UNIT_SERVICE = 'services'
-
     capacity_unit = models.CharField(
         'unité',
         max_length=10,
-        choices=(
-            (UNIT_AMP, 'A'),
-            (UNIT_MBPS, 'Mbps'),
-            (UNIT_U, 'U'),
-            (UNIT_IPV4, 'IPv4'),
-            (UNIT_ETHERNET_PORT, 'ports'),
-            (UNIT_SERVICE, 'abonnement'),
-        ),
+        choices=settings.RESOURCES_UNITS,
         blank=True,
         help_text="unité de capacité (si applicable)",
     )

+ 10 - 1
transparency/settings.py

@@ -115,10 +115,19 @@ PROVISIONING_DURATIONS = [
 ]
 
 ## How many months do we suggest setup costs staggering accross ?
-
 SETUP_COST_STAGGERING_MONTHS = 36
+
 ORGANIZATION_NAME = 'Transparency inc.'
 
+RESOURCES_UNITS = [
+    ('a', 'A'),
+    ('mbps', 'Mbps'),
+    ('u', 'U'),
+    ('ipv4', 'IPv4'),
+    ('eth', 'ports'),
+    ('services', 'abonnement')
+]
+
 try:
     from .local_settings import *
 except ImportError: