--- MPIWGWeb/MPIWGProjects.py 2006/04/21 17:58:45 1.47.2.51 +++ MPIWGWeb/MPIWGProjects.py 2006/07/14 09:14:17 1.47.2.54 @@ -270,6 +270,19 @@ class MPIWGRoot(ZSQLExtendFolder): folders=['MPIWGProject','Folder','ECHO_Navigation'] meta_type='MPIWGRoot' + def decode(self,str): + """decoder""" + if not str: + return "" + if type(str) is StringType: + try: + return str.decode('utf-8') + except: + return str.decode('latin-1') + else: + + return str + def versionHeaderEN(self): """version header text""" @@ -634,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=[] @@ -649,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): @@ -765,10 +780,14 @@ class MPIWGRoot(ZSQLExtendFolder): RESPONSE.setHeader('Content-type', 'text/html') RESPONSE.write("\n") + RESPONSE.write("Update Institutsbibliography\n") + ret=self.upDateSQL('personalwww.xml') + RESPONSE.write("done Insitutsbibliography:%s\n"%ret) url="http://itgroup.mpiwg-berlin.mpg.de:8050/FMPro?-db=personal-www&-format=-dso_xml&-lay=sql_export&-max=20000&-findall" dom = NonvalidatingReader.parseUri(url) #fh=urllib.urlopen(url) #dom=xml.dom.minidom.parse(fh) + RESPONSE.write("got_xml_File\n") @@ -978,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=[] @@ -992,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): @@ -1041,7 +1065,7 @@ class MPIWGRoot(ZSQLExtendFolder): ret+="""
  • \n""" if actualDepth==1: - departmentName={'1':'Department I','2':'Department II','3':'Department III', '4':'Ind. Research Group','5':'Ind. Research Group','6':'Research Network'} + departmentName={'1':'Department I','2':'Department II','3':'Department III', '4':'Ind. Research Group','5':'Ind. Research Group','6':'Ind. Research Group','7':'Research Network'} department=element[3].getContent('xdata_05') ret+="""
    %s: """%(department,departmentName[department]) @@ -1111,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') @@ -1268,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}) @@ -1615,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""" @@ -1772,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: @@ -1792,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""" @@ -2061,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') @@ -2197,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