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,6 +60,7 @@ class UserWorkspaceRestController(TIMRestController):
60 60
         )
61 61
 
62 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 64
             workspace.get_valid_children(ContentApi.DISPLAYABLE_CONTENTS)
64 65
         )
65 66
 

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

@@ -64,9 +64,16 @@ class Workspace(DeclarativeBase):
64 64
     revisions = relationship("ContentRevisionRO")
65 65
 
66 66
     @hybrid_property
67
-    def contents(self):
67
+    def contents(self) -> ['Content']:
68 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 78
     @property
72 79
     def calendar_url(self) -> str: