# HG changeset patch # User dwinter # Date 1367339708 -7200 # Node ID a6ace48c2bf256bfa77fe5cc88e13e1051702f0b # Parent 12cb73494367b68324df3608204a6e02cc969e70 publication management f?r projekte diff -r 12cb73494367 -r a6ace48c2bf2 MPIWGProjects.py --- a/MPIWGProjects.py Tue Apr 30 16:46:32 2013 +0200 +++ b/MPIWGProjects.py Tue Apr 30 18:35:08 2013 +0200 @@ -641,28 +641,6 @@ pt = self.edit_related_projects return pt() - - def hasExtendedPublicationList(self): - """test if extended publication list exists""" - if not hasattr(self, "publicationList"): - return False - else: - return True - - def createExtendedPublicationList(self, RESPONSE=None): - """erzeuge erweiterte publications liste""" - pl = BibliographyManager("publicationList", "", "institutsbiblio", self.connection_id) - self._setObject("publicationList", pl) - - zt = ZopePageTemplate('index.html') - pl._setObject('index.html', zt) - default_content_fn = os.path.join(package_home(globals()), - 'zpt/showExtendedProjectBibliography.zpt') - text = open(default_content_fn).read() - zt.pt_edit(text, 'text/html') - - if RESPONSE: - self.redirect(RESPONSE, "managePublications") def getPublications(self): @@ -1620,6 +1598,131 @@ self.executeZSQL("insert into projects_members (project_number, member_key) values (%s, %s)", (pNum, memberKey)) + + + 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/project/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/project/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(): + + if key.startswith('escidoc:'): + + query="INSERT INTO pubmanbiblio_projects (key_main,escidocId) values (%s,%s)" + + if data.get(key)=="add": + self.executeZSQL(query,[self.getId(),key]) + + + #selectedPublications = self.getSelectedPublications() + + #pt = PageTemplateFile(os.path.join(package_home(globals()),'zpt/project/pubman','change_publications.zpt')).__of__(self) + + #return pt() + + if hasattr(self,'REQUEST'): + return self.REQUEST.response.redirect("changePublications") + + 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/project/pubman','change_publications.zpt')).__of__(self) + return pt() + + def deleteFromPublicationList(self,escidocid): + """Loessche publication with escidoc id from publication list""" + + query ="DELETE FROM pubmanbiblio_projects WHERE escidocid=%s and key_main=%s" + + self.executeZSQL(query,[escidocid,self.getId()]); + + def setPublicationPriority(self,escidocid,value): + + query="update pubmanbiblio_projects set priority=%s where escidocid=%s and key_main=%s" + + try: + + value = int(value) + self.executeZSQL(query,[value,escidocid,self.getId()]); + + + except: + logging.error("couldn't change:") + logging.error(escidocid) + logging.error(value) + + def getSelectedPublications(self): + """hole publications aus der datenbank""" + + + query="select * from pubmanbiblio_projects where lower(key_main) = lower(%s) order by priority DESC" + + + return self.executeZSQL(query,[self.getId()]) + + + + def hasExtendedPublicationList(self): + """test if extended publication list exists""" + + + + query="select count(*) from pubmanbiblio_projects where lower(key_main) = lower(%s)" + + + res= self.executeZSQL(query,[self.getId()]) + + if res[0].count>0: + return True + else: + return False + + def publicationsFull(self,REQUEST): + """show publication""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/project/pubman','show_publications.zpt')).__of__(self) + return pt() + + def manage_addMPIWGProjectForm(self): """form for adding the project""" diff -r 12cb73494367 -r a6ace48c2bf2 MPIWGStaff.py --- a/MPIWGStaff.py Tue Apr 30 16:46:32 2013 +0200 +++ b/MPIWGStaff.py Tue Apr 30 18:35:08 2013 +0200 @@ -1127,7 +1127,7 @@ return tmp - def getPublications(self,coneId="renn",limit=None,publicationType=None): + def getPublicationsFromPubman(self,coneId="renn",limit=None,publicationType=None): logging.debug("coneID:%s"%coneId) try: @@ -1595,13 +1595,13 @@ splitted = ident.split("@"); return splitted[0] - def getPublications(self,limit=None,publicationType=None): + def getPublicationsFromPubman(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) + pubs= self.folder.getPublicationsFromPubman(coneId,limit=limit,publicationType=publicationType) return pubs elif self.content.publications_mode=="priority": @@ -1659,18 +1659,23 @@ for key in data.keys(): - query="INSERT INTO pubmanbiblio (key_main,escidocId) values (%s,%s)" + if key.startswith('escidoc:'): + - if data.get(key)=="add": - self.executeZSQL(query,[self.getKey(),key]) + query="INSERT INTO pubmanbiblio (key_main,escidocId) values (%s,%s)" + if data.get(key)=="add": + self.executeZSQL(query,[self.getKey(),key]) + - selectedPublications = self.getSelectedPublications() + #selectedPublications = self.getSelectedPublications() + + #pt = PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','change_publications.zpt')).__of__(self) - pt = PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','change_publications.zpt')).__of__(self) - - return pt() + #return pt() + if hasattr(self,'REQUEST'): + return self.REQUEST.response.redirect("changePublications") def changePublications(self,REQUEST): @@ -1703,12 +1708,16 @@ 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()]); - - + try: + query="update pubmanbiblio set priority=%s where escidocid=%s and key_main=%s" + + self.executeZSQL(query,[value,escidocid,self.getKey()]); + + except: + logging.error("couldn't change:") + logging.error(escidocid) + logging.error(value) + def getSelectedPublications(self): """hole publications aus der datenbank""" diff -r 12cb73494367 -r a6ace48c2bf2 zpt/project/edit_publications.zpt --- a/zpt/project/edit_publications.zpt Tue Apr 30 16:46:32 2013 +0200 +++ b/zpt/project/edit_publications.zpt Tue Apr 30 18:35:08 2013 +0200 @@ -27,7 +27,8 @@
-(If the publications from your current project description are not showing in this list, click here to copy them.)
+ + +