Selaa lähdekoodia

[doc2] Add has_children property

Johan Ahlen 9 vuotta sitten
vanhempi
commit
65720b5
1 muutettua tiedostoa jossa 4 lisäystä ja 0 poistoa
  1. 4 0
      desktop/core/src/desktop/models.py

+ 4 - 0
desktop/core/src/desktop/models.py

@@ -937,6 +937,10 @@ class Document2(models.Model):
   def is_home_directory(self):
     return self.is_directory and self.parent_directory == None and self.name == ''
 
+  @property
+  def has_children(self):
+    return self.children.filter(is_history=False).exists()
+
   @property
   def is_trash_directory(self):
     return self.is_directory and self.name == self.TRASH_DIR