--- MPIWGWeb/MPIWGStaff.py 2005/07/14 15:12:11 1.10.2.1 +++ MPIWGWeb/MPIWGStaff.py 2005/10/10 08:42:48 1.10.2.2 @@ -5,8 +5,9 @@ from Products.PageTemplates.PageTemplate from Products.PageTemplates.PageTemplate import PageTemplate from Products.ZCatalog.CatalogPathAwareness import CatalogAware import os +import bibliography from Globals import package_home - +from Products.PythonScripts.standard import sql_quote def getTemplate(self, tpName): """get a template file either form the instance or from the product""" @@ -47,24 +48,24 @@ class MPIWGStaff(CatalogAware,ZSQLExtend return pt() def changePublications_specialForm(self): - """Priority publications manual field""" - pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changePublications_special.zpt')).__of__(self) + """Priority publications manual field""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changePublications_special.zpt')).__of__(self) return pt() - + def changePublications_special(self,usePublicationsSpecial=None,specialPublicationsField=None,RESPONSE=None): - """change publications special params""" - if usePublicationsSpecial: + """change publications special params""" + if usePublicationsSpecial: self.usePublicationsSpecial=True - - else: - self.usePublicationsSpecial=False + + else: + self.usePublicationsSpecial=False - self.specialPublicationsField=specialPublicationsField[0:] + self.specialPublicationsField=specialPublicationsField[0:] if RESPONSE is not None: RESPONSE.redirect('manage_main') - + def publications_full(self): """show publication""" pt=getTemplate(self, "publications_full_main") @@ -94,8 +95,153 @@ class MPIWGStaff(CatalogAware,ZSQLExtend if RESPONSE is not None: RESPONSE.redirect('manage_main') - + def edit(self): + """Edit the pages""" + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff.zpt')).__of__(self) + return pt() + + mainEditFile=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff_main.zpt')) + + def changeResearch(self,noredirect=None): + """change the research entries""" + newEntries={} + id_main=self.REQUEST.form['id_main'] + + mainfieldL=self.REQUEST.form['main_fields'].split(",") + mainfield={} + for x in mainfieldL: + tmp=x.split('__') + mainfield[tmp[0]]=tmp[1] + for field in self.REQUEST.form.keys(): + splittedField=field.split("__") + if len(splittedField)<3: + pass #kein datenbank eintrag + + elif splittedField[2]=='new': # store new entries + if not newEntries.has_key(splittedField[0]): + newEntries[splittedField[0]]={} + + newEntries[splittedField[0]][splittedField[1]]=self.REQUEST.form[field] + + else: + query="UPDATE %s "%splittedField[0] + query+="SET %s = '%s' "%(splittedField[1],sql_quote(self.REQUEST.form[field])) + query+="WHERE oid = '%s' "%sql_quote(splittedField[2]) + + self.ZSQLQuery(query) + + + #new entries + for newEntry in newEntries.keys(): + query="INSERT INTO %s "%newEntry + keys=['id_main'] + values=["'"+id_main+"'"] + for key in newEntries[newEntry].keys(): + keys.append(key) + values.append("'"+newEntries[newEntry][key]+"'") + + + keystring=",".join(keys) + + valuestring=",".join(values) + + query+=" (%s) "%keystring + query+="VALUES (%s)"%valuestring + if not (newEntries[newEntry][mainfield[newEntry]].lstrip().rstrip()==""): + self.ZSQLQuery(query) + + if not noredirect: + self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) + + def editCV(self,cv=None,oid=None,RESPONSE=None): + """edit Cv""" + + if (not cv): + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editCV.zpt')).__of__(self) + return pt() + + query="UPDATE personal_www SET cv ='%s' WHERE oid='%s'" + + self.ZSQLQuery(query%(cv,oid)) + + if RESPONSE: + RESPONSE.redirect("editCV") + + def editAwards(self,awards=None,oid=None,RESPONSE=None): + """edit a awards""" + if (not awards): + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editAwards.zpt')).__of__(self) + return pt() + + query="UPDATE personal_www SET awards ='%s' WHERE oid='%s'" + + self.ZSQLQuery(query%(awards,oid)) + + if RESPONSE: + RESPONSE.redirect("editAwards") + + def editTalks(self): + """edit talks""" + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editTalks.zpt')).__of__(self) + return pt() + + + def editTeaching(self): + """edit Teaching""" + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editTeaching.zpt')).__of__(self) + return pt() + + def editPublications(self): + """edit the bibliographie""" + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editPublications.zpt')).__of__(self) + return pt() + + def changePublications(self): + """change the publication list""" + + self.changeResearch(noredirect=True) + self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) + + + def addPublications(self): + """add publications""" + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addPublications.zpt')).__of__(self) + return pt() + + formatBiblHelp=bibliography.formatBiblHelp + + def sortPriority(self,list): + tmp=[x for x in list] + + def sort(x,y): + try: + xInt=int(x.priority) + except: + xInt=0 + try: + yInt=int(y.priority) + except: + yInt=0 + + return cmp(xInt,yInt) + + tmp.sort(sort) + return tmp + + def deleteField(self,table,oid): + """delete entry""" + query="DELETE FROM %s WHERE oid = '%s'"%(table,oid) + print "query" + self.ZSQLQuery(query) + self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) + + def manage_addMPIWGStaffForm(self): """form for adding the project""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGStaffForm.zpt')).__of__(self)