comparison MPIWGDepartment.py @ 27:9a75eb1b31b3

more work on projects.
author casties
date Mon, 22 Apr 2013 21:01:00 +0200
parents 6a4996805505
children aa4ab114c28a
comparison
equal deleted inserted replaced
26:8a99ad8713d6 27:9a75eb1b31b3
5 import re 5 import re
6 import os 6 import os
7 import logging 7 import logging
8 from OFS.Folder import Folder 8 from OFS.Folder import Folder
9 from AccessControl import ClassSecurityInfo 9 from AccessControl import ClassSecurityInfo
10
11 from SrvTxtUtils import getAt
12
10 import MPIWGHelper 13 import MPIWGHelper
11 14
12 class MPIWGDepartment(Folder): 15 class MPIWGDepartment(Folder):
13 """special object for departments on the MPIWG website """ 16 """special object for departments on the MPIWG website """
14 17
134 def getThumbImgUrl(self): 137 def getThumbImgUrl(self):
135 """returns the URL of the image object for the sidebar thumbnail""" 138 """returns the URL of the image object for the sidebar thumbnail"""
136 img = getattr(self, 'img-thumb.jpg') 139 img = getattr(self, 'img-thumb.jpg')
137 return img.absolute_url() 140 return img.absolute_url()
138 141
139 def getProjects(self, onlyActive=0, onlyArchived=0): 142 def getProject(self):
143 """returns the default project"""
144 proj = self.getProjects(count=1, onlyActive=1, onlyArchived=1)
145 return getAt(proj, 0, None)
146
147 def getProjects(self, count=0, onlyActive=0, onlyArchived=0):
140 """returns a list of projects of this department. 148 """returns a list of projects of this department.
141 149
142 onlyActive = 0 : all projects 150 onlyActive = 0 : all projects
143 onlyActive = 1 : active projects 151 onlyActive = 1 : active projects
144 onlyActive = 2 : inactive projects 152 onlyActive = 2 : inactive projects
145 153
146 onlyArchived = 0 : all projects 154 onlyArchived = 0 : all projects
147 onlyArchived = 1 : current projects 155 onlyArchived = 1 : current projects
148 onlyArchived = 2 : archived projects 156 onlyArchived = 2 : archived projects
149 """ 157 """
150 # getTree: jeder Eintrag ist ein Tupel (Tiefe, ProjektNummer,Titel,ProjektObject) 158 pf = self.en.getProjectsFolder()
151 tree = self.getTree(dep=self.getProjectId(), date=None, onlyActive=onlyActive, onlyArchived=onlyArchived) 159 projects = pf.getProjectList(self.getProjectId(), active=onlyActive, archived=onlyArchived)
152 # re-pack into simple list 160 #logging.debug("getProjects projects=%s"%repr(projects))
153 projects = [] 161 if count > 0:
154 for item in tree: 162 return projects[:count]
155 projects.append(item[3])
156 163
157 return projects 164 return projects
158 165
159 def changeWeight(self,weight,RESPONSE=None): 166 def changeWeight(self,weight,RESPONSE=None):
160 """change weight""" 167 """change weight"""