|
|
| version 1.10.2.2, 2005/10/10 08:42:48 | version 1.10.2.3, 2005/10/10 19:10:13 |
|---|---|
| Line 1 | Line 1 |
| """This file contains the classes for the organization of the staff""" | """This file contains the classes for the organization of the staff""" |
| # TODO: pruefe ob die id der einzelnen tabellen, wie id in publications noch benutzt werden | |
| # TODO: pruefe ob die bibliographischen felder in publications noch benutzt werden | |
| # TODO: auswahl der ausgewaehlten publication auf der ersten seite der homepage | |
| from OFS.Folder import Folder | from OFS.Folder import Folder |
| from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder | from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder |
| from Products.PageTemplates.PageTemplateFile import PageTemplateFile | from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
| Line 8 import os | Line 12 import os |
| import bibliography | import bibliography |
| from Globals import package_home | from Globals import package_home |
| from Products.PythonScripts.standard import sql_quote | from Products.PythonScripts.standard import sql_quote |
| from types import * | |
| def getTemplate(self, tpName): | def getTemplate(self, tpName): |
| """get a template file either form the instance or from the product""" | """get a template file either form the instance or from the product""" |
| Line 195 class MPIWGStaff(CatalogAware,ZSQLExtend | Line 201 class MPIWGStaff(CatalogAware,ZSQLExtend |
| pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editTeaching.zpt')).__of__(self) | pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editTeaching.zpt')).__of__(self) |
| return pt() | return pt() |
| def editBibliography(self): | |
| """edit the bibliography""" | |
| pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editBibliographyEntry.zpt')).__of__(self) | |
| return pt() | |
| def editPublications(self): | def editPublications(self): |
| """edit the bibliographie""" | """edit the bibliographie""" |
| pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editPublications.zpt')).__of__(self) | pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editPublications.zpt')).__of__(self) |
| return pt() | return pt() |
| def changeSortingMode(self,sortingMode,RESPONSE=None,REQUEST=None): | |
| """change sorting mode""" | |
| self.sortingMode=sortingMode | |
| if RESPONSE and REQUEST: | |
| REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER']) | |
| return True | |
| def getSortingMode(self): | |
| """get sorting mode""" | |
| return getattr(self,'sortingMode','priority') | |
| def changePublications(self): | def changePublications(self): |
| """change the publication list""" | """change the publication list""" |
| self.updatePublicationDB(personId=self.getDBId()) | |
| self.changeResearch(noredirect=True) | self.changeResearch(noredirect=True) |
| self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) | self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) |
| def addPublications(self): | def addPublications(self,submit=None,REQUEST=None,noredirect=None): |
| """add publications""" | """add publications""" |
| #setzte flag ob aufruf aus suchformular | |
| if REQUEST.get("QUERY_STRING",None) and (not submit): | |
| self.REQUEST.set('fromSearch','1') | |
| else: | |
| self.REQUEST.set('fromSearch','0') | |
| if not submit or (not (submit == "add")): | |
| pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addPublications.zpt')).__of__(self) | pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addPublications.zpt')).__of__(self) |
| return pt() | return pt() |
| #new entries | |
| entries = REQUEST.form.get('addEntries',None) | |
| if not (type(entries) is ListType): | |
| entries=[entries] | |
| for bibId in entries: | |
| query="INSERT INTO %s " % "publications" | |
| query+="(id_main,id_institutsbibliographie) " | |
| query+="VALUES ('%s','%s')" %(sql_quote(self.getDBId()),sql_quote(bibId)) | |
| self.ZSQLQuery(query) | |
| self.updatePublicationDB(personId=self.getDBId()) | |
| if not noredirect: | |
| self.REQUEST.RESPONSE.redirect("./editPublications") | |
| return True | |
| def getDBId(self): | |
| """get id from the personal database""" | |
| search=self.ZSQLInlineSearch(_table='personal_www',username=self.getId()) | |
| if search: | |
| return search[0].id | |
| else: | |
| return None | |
| formatBiblHelp=bibliography.formatBiblHelp | formatBiblHelp=bibliography.formatBiblHelp |
| def sortPriority(self,list): | def sortBibliography(self,list): |
| tmp=[x for x in list] | sortingMode=self.getSortingMode() |
| if sortingMode == "year": | |
| return self.sortYear(list) | |
| else: | |
| return self.sortPriority(list) | |
| def sortPriority(self,list): | |
| def sort(x,y): | def sort(x,y): |
| try: | try: |
| xInt=int(x.priority) | xInt=int(x.priority) |
| Line 231 class MPIWGStaff(CatalogAware,ZSQLExtend | Line 302 class MPIWGStaff(CatalogAware,ZSQLExtend |
| return cmp(xInt,yInt) | return cmp(xInt,yInt) |
| tmp=[x for x in list] | |
| tmp.sort(sort) | |
| return tmp | |
| def sortYear(self,list): | |
| #TODO: sort TO APPEAR and TO BE PUBLISHED etc... | |
| def sort(x,y): | |
| try: | |
| xInt=int(x.year) | |
| except: | |
| xInt=0 | |
| try: | |
| yInt=int(y.year) | |
| except: | |
| yInt=0 | |
| return cmp(yInt,xInt) | |
| tmp=[x for x in list] | |
| tmp.sort(sort) | tmp.sort(sort) |
| return tmp | return tmp |