provide a realistic default protocol
authorymh <ymh.work@gmail.com>
Fri, 04 Aug 2017 10:46:17 +0200
changeset 139 d3738ac909d8
parent 138 a1fb2ced3049
child 140 94d1e40f7954
provide a realistic default protocol
src/notes/api/fields/category.py
src/notes/settings.py
--- a/src/notes/api/fields/category.py	Fri Aug 04 09:48:09 2017 +0200
+++ b/src/notes/api/fields/category.py	Fri Aug 04 10:46:17 2017 +0200
@@ -3,6 +3,7 @@
 '''
 import logging
 
+from notes import settings
 from rest_framework import serializers
 
 logger = logging.getLogger(__name__)
@@ -17,21 +18,7 @@
 
     def to_representation(self, obj):
         logger.debug("ProtocolField.to_representation %r", obj)
-        return {
-            "id": "a4977c1f-4752-4aff-b724-eec4033af25c",
-            "owner": "group1",
-            "revision": "1",
-            "description": "Cras rutrum lacinia pretium. Suspendisse justo est, tincidunt sed tellus a, sodales suscipit risus. Curabitur odio tortor, tincidunt sed est nec, ullamcorper sodales velit.",
-            "metacategories": [{
-                "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
-                "revision": 2,
-                "base": "ef14bcce-52ac-44ba-a7d1-f1441bab94de",
-                "name": "référence",
-                "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin massa nibh, hendrerit quis justo vitae, luctus tempor dolor. Nam quis fringilla diam.",
-                "color": "#2cbfff",
-                "has_comment": False
-            }]
-        }
+        return settings.NOTES_SETTINGS['PROTOCOL']
 
     def to_internal_value(self, data):
         logger.debug("ProtocolField.to_internal_value %r", data)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/notes/settings.py	Fri Aug 04 10:46:17 2017 +0200
@@ -0,0 +1,37 @@
+from django.conf import settings as base_settings
+
+DEFAULT_NOTES_SETTINGS = {
+    'PROTOCOL': {
+        "id": "a4977c1f-4752-4aff-b724-eec4033af25c",
+        "owner": None,
+        "revision": "1",
+        "description": "Default protocol",
+        "metacategories": [{
+            "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
+            "revision": 1,
+            "base": None,
+            "name": "Important",
+            "description": "Important.",
+            "color": "#F1C40F",
+            "has_comment": False
+        }, {
+            "id": "06aded0d-5393-4eef-bad3-f18930047361",
+            "revision": 1,
+            "base": None,
+            "name": "Mot-clé",
+            "description": "Mot-clé.",
+            "color": "#2ECC71",
+            "has_comment": False
+        }, {
+            "id": "908d9190-2b43-4acc-bfc1-ab10d2c45663",
+            "revision": 1,
+            "base": None,
+            "name": "Commentaire",
+            "description": "Commentaire.",
+            "color": "#3498DB",
+            "has_comment": True
+        }]
+    }
+}
+
+NOTES_SETTINGS = dict(DEFAULT_NOTES_SETTINGS, **getattr(base_settings, 'NOTES_SETTINGS', {}))