Mercurial > hg > MPIWGWeb
changeset 62:64be5db08495
more cleaning projects.
author | casties |
---|---|
date | Fri, 03 May 2013 10:16:47 +0200 |
parents | 04fb655633ef |
children | fd6931bd49c8 |
files | MPIWGProjects.py zpt/project/pubman/add_publications.zpt zpt/project/pubman/change_publications.zpt |
diffstat | 3 files changed, 74 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/MPIWGProjects.py Thu May 02 18:32:01 2013 +0200 +++ b/MPIWGProjects.py Fri May 03 10:16:47 2013 +0200 @@ -316,6 +316,7 @@ editImagesForm = PageTemplateFile('zpt/project/edit_images', globals()) editPublicationsForm = PageTemplateFile('zpt/project/edit_publications', globals()) editAdditionalPublicationsForm = PageTemplateFile('zpt/project/pubman/change_publications', globals()) + editAddAdditionalPublications = PageTemplateFile('zpt/project/pubman/add_publications', globals()) # management templates loadNewFileForm = PageTemplateFile('zpt/project/manage_newfile', globals()) description_only_html = PageTemplateFile('zpt/project/description_only_html', globals()) @@ -1457,88 +1458,63 @@ 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) + pt = self.editAddAdditionalPublications 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) - - + pt = self.editAddAdditionalPublications return pt(values=entries) - - if data.get("method") == "add": - - return self.addEntriesToPublicationList(data) + return self.addEntriesToAdditionalPublicationList(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, + def addEntriesToAdditionalPublicationList(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") + return self.REQUEST.response.redirect("changeAdditionalPublications") + - def changePublications(self,REQUEST): + def changeAdditionalPublications(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); + self.deleteFromAdditionalPublicationList(key); elif(splitted[1]) == "p": - self.setPublicationPriority(splitted[0],value); + self.setAdditionalPublicationPriority(splitted[0],value); pt = self.editAdditionalPublicationsForm return pt() + - def deleteFromPublicationList(self,escidocid): + def deleteFromAdditionalPublicationList(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): - + def setAdditionalPublicationPriority(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) @@ -1561,8 +1537,6 @@ return False - - def manage_addMPIWGProjectForm(self): """form for adding the project""" pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'addMPIWGProjectForm.zpt')).__of__(self) @@ -1884,7 +1858,19 @@ # update related publications # for pub in project.getPublicationList(): - pub.hasLinkToBookPage() + if not pub.text: + msg = "%s: publication has no text: %s!\n"%(project.getId(), pub) + log += msg + logging.warn(msg) + if not pub.link: + msg = "%s: publication has no link either! Deleting: %s!\n"%(project.getId(), pub) + log += msg + logging.error(msg) + project.deletePublication(pub.getId()) + + else: + # hasLinkToBookPage updates the bookId + pub.hasLinkToBookPage() # # unicodify @@ -1900,8 +1886,7 @@ fulllog += log if RESPONSE is not None: RESPONSE.write(log) - - + log += "\n DONE! updated %s projects!" % cnt fulllog += log if RESPONSE is not None: @@ -1910,9 +1895,6 @@ else: return fulllog - - - def manage_addMPIWGProjectFolderForm(self): """form for adding a MPIWGProjectFolder"""
--- a/zpt/project/pubman/add_publications.zpt Thu May 02 18:32:01 2013 +0200 +++ b/zpt/project/pubman/add_publications.zpt Fri May 03 10:16:47 2013 +0200 @@ -2,38 +2,35 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html metal:use-macro="here/edit_template/macros/page"> <body> -<tal:block metal:fill-slot="navsel" tal:define="global menusel string:talks" /> - -<tal:block metal:fill-slot="body" tal:define="yes_no_list python:'yes\nno'"> - <form action="" method="post"> - <input type="hidden" name="method" value="search"/> - <div> Author/Editor: <input type="text" size="30" name="author"/></div> - <div> Title: <input type="text" size="30" name="title"/></div> - <div> Somewhere in the metadata: <input type="text" size="30" name="any"/></div> - - <input type="submit" value="submit"> - - </form> - + <tal:block metal:fill-slot="navsel" tal:define="global menusel string:publications" /> -<div tal:condition="python:options.has_key('values')"> -<form action="" method="post"> - <input type="hidden" name="method" value="add"/> - -<table> - + <tal:block metal:fill-slot="body" tal:define="yes_no_list python:'yes\nno'"> + <form action="" method="post"> + <input type="hidden" name="method" value="search" /> + <div> + Author/Editor: <input type="text" size="30" name="author" /> + </div> + <div> + Title: <input type="text" size="30" name="title" /> + </div> + <div> + Somewhere in the metadata: <input type="text" size="30" name="any" /> + </div> + <input type="submit" value="submit"> + </form> -<tr tal:repeat="entry python:options['values'].items()"> -<td><input type="checkbox" value="add" tal:attributes="name python:entry[0]"/></td> -<td><tal:x tal:replace="structure python:entry[1]"/></td> -</tr> - -</table> -<input type="submit" value="submit"/> - -</form> - -</div> -</tal:block> + <div tal:condition="python:options.has_key('values')"> + <form action="" method="post"> + <input type="hidden" name="method" value="add" /> + <table> + <tr tal:repeat="entry python:options['values'].items()"> + <td><input type="checkbox" value="add" tal:attributes="name python:entry[0]" /></td> + <td><tal:x tal:replace="structure python:entry[1]" /></td> + </tr> + </table> + <input type="submit" value="submit" /> + </form> + </div> + </tal:block> </body> </html>
--- a/zpt/project/pubman/change_publications.zpt Thu May 02 18:32:01 2013 +0200 +++ b/zpt/project/pubman/change_publications.zpt Fri May 03 10:16:47 2013 +0200 @@ -2,29 +2,22 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html metal:use-macro="here/edit_template/macros/page"> <body> -<tal:block metal:fill-slot="navsel" tal:define="global menusel string:publications" /> - -<tal:block metal:fill-slot="body" tal:define="yes_no_list python:'yes\nno'"> - - -<div> -<form action="" method="post"> - -<table> + <tal:block metal:fill-slot="navsel" tal:define="global menusel string:publications" /> -<input type="hidden" method="change"/> -<tr tal:repeat="entry python:here.getAdditionalPublicationList()"> -<td><input type="checkbox" value="delete" tal:attributes="name python:entry.escidocid"/></td> -<td><input type="text" size="5" tal:attributes="name python:entry.escidocid+'__p'; value python:entry.priority"/></td> -<td><tal:x tal:replace="structure python:here.mpiwgPubman.getEntryFromPubman(entry.escidocid)"/></td> -</tr> - -</table> -<input type="submit" value="submit"/> - -</form> - -</div> -</tal:block> + <tal:block metal:fill-slot="body" tal:define="yes_no_list python:'yes\nno'"> + <div> + <form action="" method="post"> + <table> + <input type="hidden" method="change" /> + <tr tal:repeat="entry python:here.getAdditionalPublicationList()"> + <td><input type="checkbox" value="delete" tal:attributes="name python:entry.escidocid" /></td> + <td><input type="text" size="5" tal:attributes="name python:entry.escidocid+'__p'; value python:entry.priority" /></td> + <td><tal:x tal:replace="structure python:here.mpiwgPubman.getEntryFromPubman(entry.escidocid)" /></td> + </tr> + </table> + <input type="submit" value="submit" /> + </form> + </div> + </tal:block> </body> </html>