diff MPIWGDepartment.py @ 24:6a4996805505

more work on projects.
author casties
date Tue, 09 Apr 2013 16:50:29 +0200
parents 54f135c1ed65
children 9a75eb1b31b3
line wrap: on
line diff
--- a/MPIWGDepartment.py	Mon Apr 08 20:47:39 2013 +0200
+++ b/MPIWGDepartment.py	Tue Apr 09 16:50:29 2013 +0200
@@ -136,6 +136,26 @@
         img = getattr(self, 'img-thumb.jpg')
         return img.absolute_url()
 
+    def getProjects(self, onlyActive=0, onlyArchived=0):
+        """returns a list of projects of this department.
+        
+        onlyActive = 0 : all projects
+        onlyActive = 1 : active projects
+        onlyActive = 2 : inactive projects
+        
+        onlyArchived = 0 : all projects
+        onlyArchived = 1 : current projects
+        onlyArchived = 2 : archived projects
+        """
+        # getTree: jeder Eintrag ist ein Tupel (Tiefe, ProjektNummer,Titel,ProjektObject)
+        tree = self.getTree(dep=self.getProjectId(), date=None, onlyActive=onlyActive, onlyArchived=onlyArchived)
+        # re-pack into simple list
+        projects = []
+        for item in tree:
+            projects.append(item[3])
+            
+        return projects
+    
     def changeWeight(self,weight,RESPONSE=None):
         """change weight"""
         self.weight=weight