浏览代码

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

Bastien Sevajol (Algoo) 8 年前
父节点
当前提交
eade41d2e1
共有 1 个文件被更改,包括 11 次插入9 次删除
  1. 11 9
      tracim/tracim/model/data.py

+ 11 - 9
tracim/tracim/model/data.py 查看文件

@@ -30,6 +30,15 @@ from tracim.lib.exception import ContentRevisionUpdateError
30 30
 from tracim.model import DeclarativeBase, RevisionsIntegrity
31 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 43
 class BreadcrumbItem(object):
35 44
 
@@ -507,14 +516,7 @@ class ContentChecker(object):
507 516
     @classmethod
508 517
     def reset_properties(cls, item):
509 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 520
             return
519 521
 
520 522
         raise NotImplementedError
@@ -1077,7 +1079,7 @@ class Content(DeclarativeBase):
1077 1079
     def properties(self) -> dict:
1078 1080
         """ return a structure decoded from json content of _properties """
1079 1081
         if not self._properties:
1080
-            ContentChecker.reset_properties(self)
1082
+            return DEFAULT_PROPERTIES
1081 1083
         return json.loads(self._properties)
1082 1084
 
1083 1085
     @properties.setter