Explorar el Código

Closes #193: When content has no properties: return a default value instead set it.

Bastien Sevajol (Algoo) hace 8 años
padre
commit
eade41d2e1
Se han modificado 1 ficheros con 11 adiciones y 9 borrados
  1. 11 9
      tracim/tracim/model/data.py

+ 11 - 9
tracim/tracim/model/data.py Ver fichero

30
 from tracim.model import DeclarativeBase, RevisionsIntegrity
30
 from tracim.model import DeclarativeBase, RevisionsIntegrity
31
 from tracim.model.auth import User
31
 from tracim.model.auth import User
32
 
32
 
33
+DEFAULT_PROPERTIES = dict(
34
+    allowed_content=dict(
35
+        folder=True,
36
+        file=True,
37
+        page=True,
38
+        thread=True,
39
+    ),
40
+)
41
+
33
 
42
 
34
 class BreadcrumbItem(object):
43
 class BreadcrumbItem(object):
35
 
44
 
507
     @classmethod
516
     @classmethod
508
     def reset_properties(cls, item):
517
     def reset_properties(cls, item):
509
         if item.type==ContentType.Folder:
518
         if item.type==ContentType.Folder:
510
-            item.properties = dict(
511
-                allowed_content = dict (
512
-                    folder = True,
513
-                    file = True,
514
-                    page = True,
515
-                    thread = True
516
-                )
517
-            )
519
+            item.properties = DEFAULT_PROPERTIES
518
             return
520
             return
519
 
521
 
520
         raise NotImplementedError
522
         raise NotImplementedError
1077
     def properties(self) -> dict:
1079
     def properties(self) -> dict:
1078
         """ return a structure decoded from json content of _properties """
1080
         """ return a structure decoded from json content of _properties """
1079
         if not self._properties:
1081
         if not self._properties:
1080
-            ContentChecker.reset_properties(self)
1082
+            return DEFAULT_PROPERTIES
1081
         return json.loads(self._properties)
1083
         return json.loads(self._properties)
1082
 
1084
 
1083
     @properties.setter
1085
     @properties.setter