Browse Source

Closes #150: Workspace.contents must check if last content revision is still in this workspace

Bastien Sevajol (Algoo) 8 years ago
parent
commit
2ffbe3350a
2 changed files with 10 additions and 2 deletions
  1. 1 0
      tracim/tracim/controllers/workspace.py
  2. 9 2
      tracim/tracim/model/data.py

+ 1 - 0
tracim/tracim/controllers/workspace.py View File

60
         )
60
         )
61
 
61
 
62
         fake_api.sub_items = Context(CTX.FOLDER_CONTENT_LIST).toDict(
62
         fake_api.sub_items = Context(CTX.FOLDER_CONTENT_LIST).toDict(
63
+            # TODO BS 20161209: Is the correct way to grab folders? No use API?
63
             workspace.get_valid_children(ContentApi.DISPLAYABLE_CONTENTS)
64
             workspace.get_valid_children(ContentApi.DISPLAYABLE_CONTENTS)
64
         )
65
         )
65
 
66
 

+ 9 - 2
tracim/tracim/model/data.py View File

64
     revisions = relationship("ContentRevisionRO")
64
     revisions = relationship("ContentRevisionRO")
65
 
65
 
66
     @hybrid_property
66
     @hybrid_property
67
-    def contents(self):
67
+    def contents(self) -> ['Content']:
68
         # Return a list of unique revisions parent content
68
         # Return a list of unique revisions parent content
69
-        return list(set([revision.node for revision in self.revisions]))
69
+        contents = []
70
+        for revision in self.revisions:
71
+            # TODO BS 20161209: This ``revision.node.workspace`` make a lot
72
+            # of SQL queries !
73
+            if revision.node.workspace == self and revision.node not in contents:
74
+                contents.append(revision.node)
75
+
76
+        return contents
70
 
77
 
71
     @property
78
     @property
72
     def calendar_url(self) -> str:
79
     def calendar_url(self) -> str: