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
     parent = relationship('Content', remote_side=[content_id], backref='children')
331
     parent = relationship('Content', remote_side=[content_id], backref='children')
332
     owner = relationship('User', remote_side=[User.user_id])
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
     @hybrid_property
340
     @hybrid_property
335
     def properties(self):
341
     def properties(self):
336
         """ return a structure decoded from json content of _properties """
342
         """ return a structure decoded from json content of _properties """
365
 
371
 
366
     def get_child_nb(self, content_type: ContentType, content_status = ''):
372
     def get_child_nb(self, content_type: ContentType, content_status = ''):
367
         child_nb = 0
373
         child_nb = 0
368
-        for child in self.children:
374
+        for child in self.valid_children:
369
             if child.type==content_type:
375
             if child.type==content_type:
370
                 if not content_status:
376
                 if not content_status:
371
                     child_nb = child_nb+1
377
                     child_nb = child_nb+1