Browse Source

fixes bug #5: deleted threads (and other contents) are counted in item nb shown as folder content

Damien ACCORSI 10 years ago
parent
commit
a6938637f9
1 changed files with 7 additions and 1 deletions
  1. 7 1
      tracim/tracim/model/data.py

+ 7 - 1
tracim/tracim/model/data.py View File

@@ -331,6 +331,12 @@ class Content(DeclarativeBase):
331 331
     parent = relationship('Content', remote_side=[content_id], backref='children')
332 332
     owner = relationship('User', remote_side=[User.user_id])
333 333
 
334
+    @property
335
+    def valid_children(self):
336
+        for child in self.children:
337
+            if not child.is_deleted and not child.is_archived:
338
+                yield child
339
+
334 340
     @hybrid_property
335 341
     def properties(self):
336 342
         """ return a structure decoded from json content of _properties """
@@ -365,7 +371,7 @@ class Content(DeclarativeBase):
365 371
 
366 372
     def get_child_nb(self, content_type: ContentType, content_status = ''):
367 373
         child_nb = 0
368
-        for child in self.children:
374
+        for child in self.valid_children:
369 375
             if child.type==content_type:
370 376
                 if not content_status:
371 377
                     child_nb = child_nb+1