Mercurial > hg > MPIWGWeb
diff MPIWGStaff.py @ 47:225179dfd892
getPublications erweitert nach Typ
ausserdem erh?lt man jetzt auch einzelne Publicationen nach escidoc:id
author | dwinter |
---|---|
date | Mon, 29 Apr 2013 16:01:24 +0200 |
parents | 955d102392db |
children | f59bdd5f4890 |
line wrap: on
line diff
--- a/MPIWGStaff.py Sat Apr 27 10:04:57 2013 +0200 +++ b/MPIWGStaff.py Mon Apr 29 16:01:24 2013 +0200 @@ -1120,11 +1120,11 @@ return tmp - def getPublications(self,coneId="renn"): + def getPublications(self,coneId="renn",limit=None,publicationType=None): logging.debug("coneID:%s"%coneId) try: - pubs=self.mpiwgPubman.getPublications(coneId) + pubs=self.mpiwgPubman.getPublications(coneId,limit=limit,publicationType=publicationType) return pubs except: @@ -1230,6 +1230,9 @@ return html%"" + + + def getTalks(self): return self.folder.executeZSQL("SELECT oid,* FROM talks WHERE key_main = %s",[self.content.key]) @@ -1412,6 +1415,28 @@ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff','edit_downloads.zpt')).__of__(self) return pt() + def editPublications(self,REQUEST): + """editiere die Publications von der Webseite""" + + + data=REQUEST.form + + if data.has_key('selectionMode'): + query="UPDATE personal_www SET publications_mode=%s WHERE key=%s" + + self.executeZSQL(query,[data['selectionMode'],self.getKey()]) + + self.refresh_content() + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff','edit_publications.zpt')).__of__(self) + return pt() + + + def refresh_content(self,): + + self.content = self.folder.executeZSQL("select * from personal_www where key = %s", [self.getKey()])[0] + + def changeDownloads(self,REQUEST): """"change the downloadable files""" self.invalidate_chache(); @@ -1563,13 +1588,126 @@ splitted = ident.split("@"); return splitted[0] - def getPublications(self): + def getPublications(self,limit=None,publicationType=None): + + + if self.content.publications_mode=="year" or publicationType is not None: + coneId = self.getConeId(); + if coneId: + pubs= self.folder.getPublications(coneId,limit=limit,publicationType=publicationType) + return pubs - coneId = self.getConeId(); - if coneId: - pubs= self.folder.getPublications(coneId) + elif self.content.publications_mode=="priority": + selPubs= self.getSelectedPublications() + + pubs=[] + for selPub in selPubs: + pubs.append((selPub.escidocid,self.mpiwgPubman.getEntryFromPubman(selPub.escidocid))) + return pubs - return [] + return {} + + + def publicationsFull(self,REQUEST): + """show publication""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','show_publications.zpt')).__of__(self) + return pt(member=self.content) + + + + + + def addPublicationsFromPubman(self,REQUEST): + """addPublications from pubman""" + + data=REQUEST.form + + if data.get("method",None) is None: + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','add_publications.zpt')).__of__(self) + return pt() + + if data.get("method") == "search": + entries= self.mpiwgPubman.search(data) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','add_publications.zpt')).__of__(self) + + + return pt(values=entries) + + + + if data.get("method") == "add": + + return self.addEntriesToPublicationList(data) + #pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','add_publications.zpt')).__of__(self) + + + + def addEntriesToPublicationList(self,data): + """fuege eintrage aus data zur publications liste, + @param data Map mit escidocID --> value + value muss "add" sein damit hinzugefuegt wird""" + + for key in data.keys(): + + query="INSERT INTO pubmanbiblio (key_main,escidocId) values (%s,%s)" + + if data.get(key)=="add": + self.executeZSQL(query,[self.getKey(),key]) + + + + selectedPublications = self.getSelectedPublications() + + pt = PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','change_publications.zpt')).__of__(self) + + return pt() + + + def changePublications(self,REQUEST): + """change published publications""" + + data=REQUEST.form + + + if data.get("method","change"): + for key in data.keys(): + splitted=key.split("__") #format escidoc_id__p fuer priority, nur escidocid + value=data[key] + if len(splitted)==1: + self.deleteFromPublicationList(key); + + elif(splitted[1]) == "p": + self.setPublicationPriority(splitted[0],value); + + + pt = PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','change_publications.zpt')).__of__(self) + return pt() + + + def deleteFromPublicationList(self,escidocid): + """Loessche publication with escidoc id from publication list""" + + query ="DELETE FROM pubmanbiblio WHERE escidocid=%s and key_main=%s" + + self.executeZSQL(query,[escidocid,self.getKey()]); + + + def setPublicationPriority(self,escidocid,value): + + query="update pubmanbiblio set priority=%s where escidocid=%s and key_main=%s" + + self.executeZSQL(query,[value,escidocid,self.getKey()]); + + + def getSelectedPublications(self): + """hole publications aus der datenbank""" + + + query="select * from pubmanbiblio where key_main = %s order by priority" + + + return self.executeZSQL(query,[self.getKey()]) + InitializeClass(MPIWGStaffMember)