--- MPIWGWeb/MPIWGProjects.py 2006/07/13 09:56:56 1.47.2.53 +++ MPIWGWeb/MPIWGProjects.py 2006/07/14 09:14:17 1.47.2.54 @@ -647,7 +647,7 @@ class MPIWGRoot(ZSQLExtendFolder): """test""" return self.getProjectsByFieldContent('xdata_09',['biology'])[0].absolute_url - def getContexts(self,childs=None,parents=None,depth=None,date=None): + def getContexts(self,childs=None,parents=None,depth=None,date=None,onlyActive=True): """childs alle childs, alle parents""" ret=[] @@ -662,15 +662,17 @@ class MPIWGRoot(ZSQLExtendFolder): if childs: for project in self.getProjectFields('xdata_05',sort='int',date=date): searchStr=childs+"(\..*)" - if re.match(searchStr,project[1]): - - if depth: - - if int(depth)>=len(project[1].split("."))-len(childs.split(".")): - + + if (onlyActive and project[0].isActiveProject()) or (not onlyActive): + if re.match(searchStr,project[1]): + + if depth: + + if int(depth)>=len(project[1].split("."))-len(childs.split(".")): + + ret.append(project) + else: ret.append(project) - else: - ret.append(project) return ret def getProjectFields(self,fieldName,date=None,folder=None,sort=None): @@ -995,7 +997,7 @@ class MPIWGRoot(ZSQLExtendFolder): return entry - def getTree(self,date=None): + def getTree(self,date=None,onlyActive=None): """generate Tree from project list""" returnList=[] @@ -1009,9 +1011,14 @@ class MPIWGRoot(ZSQLExtendFolder): #title=project[0].WEB_title title=[project[0].getContent('WEB_title')] #print title - if idNr[0]!="x": + + if idNr[0]=="x": # kompatibilitŠt mit alter Konvention, x vor der Nummer macht project inactive + project[0].setActiveFlag(False) + + if onlyActive and project[0].isActiveProject(): #nur active projekte returnList.append((depth,nr,title,project[0])) - + elif not onlyActive: + returnList.append((depth,nr,title,project[0])) return returnList def formatElementsAsList(self,elements): @@ -1128,11 +1135,21 @@ class MPIWGRoot(ZSQLExtendFolder): for idNr in form.keys(): - if not (fields[int(idNr)][3].xdata_05==form[idNr]): - fields[int(idNr)][3].xdata_05=form[idNr] - fields[int(idNr)][3].copyObjectToArchive() - - + + splitted=idNr.split('_') + + if len(splitted)==1: # name des Feldes = idNr, dann Aendere id_nr + if not (fields[int(idNr)][3].xdata_05==form[idNr]): + fields[int(idNr)][3].xdata_05=form[idNr] + fields[int(idNr)][3].copyObjectToArchive() + + if form.has_key(idNr+'_active'): # active flag is set + + fields[int(splitted[0])][3].setActiveFlag(True) + else: + + fields[int(splitted[0])][3].setActiveFlag(False) + if RESPONSE is not None: RESPONSE.redirect('showTree') @@ -1285,6 +1302,7 @@ class MPIWGRoot(ZSQLExtendFolder): if splittedNew[0]=='': del splittedNew[0] search=string.join(splittedNew,' AND ') + if not search=='': proj=self.MembersCatalog({'title':search}) @@ -1632,6 +1650,17 @@ class MPIWGProject(CatalogAware,Folder): if RESPONSE: RESPONSE.redirect('manageImages') + + def hasChildren(self,date=None,onlyActive=True): + """check if project has children""" + ct=self.getContexts(childs=self.getContent('xdata_05'), + depth=1,date=date,onlyActive=onlyActive) + + if ct and len(ct)>0: + return True + else: + return False + def addImage(self,fileHd,caption,RESPONSE=None,filename=None): """add an MPIWG_Project_image""" @@ -1789,6 +1818,8 @@ class MPIWGProject(CatalogAware,Folder): self.creationTime=time.strftime("%Y%m%d%H%M%S",time.localtime())[0:] self.id=id self.title=id + self.isActiveFlag=True #Flag is true is the project is still active, False if accomplished + if argv: for arg in definedFields: try: @@ -1809,6 +1840,14 @@ class MPIWGProject(CatalogAware,Folder): ) + def isActiveProject(self): + """check if the project is still active, default is true, set to false is the project is accomplished""" + return getattr(self,'isActiveFlag',True) + + def setActiveFlag(self,status=True): + """set the active flag""" + self.isActiveFlag=status + def checkDate(self,date): """teste ob zum Zeitpunkt date eine andere version existierte""" @@ -2078,6 +2117,10 @@ class MPIWGProject(CatalogAware,Folder): setattr(self,x,[self.REQUEST[x].decode('utf-8')]) + if self.REQUEST.has_key('active'): + self.setActiveFlag(True) + else: + self.setActiveFlag(False) if fromEdit and (RESPONSE is not None): RESPONSE.redirect('./editMPIWGBasisEditor') @@ -2214,4 +2257,4 @@ def manage_addMPIWGProject(self,id,RESPO if RESPONSE is not None: - RESPONSE.redirect('manage_main') + RESPONSE.redirect('manage_main') \ No newline at end of file