version 1.10.2.28, 2006/07/27 09:01:00
|
version 1.11, 2009/02/18 13:01:17
|
Line 7 from OFS.Folder import Folder
|
Line 7 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 |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.PageTemplate import PageTemplate |
|
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
|
from Products.versionedFile.extVersionedFile import extVersionedFileFolder |
|
from AccessControl import getSecurityManager |
|
|
import os |
import os |
import zLOG |
import logging |
import bibliography |
import bibliography |
|
import email |
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 * |
from types import * |
from AccessControl import ClassSecurityInfo |
from AccessControl import ClassSecurityInfo |
|
import time |
import zLOG |
import logging |
|
import email |
|
import re |
|
from OFS.Cache import Cacheable |
|
|
|
from MPIWGHelper import * |
|
#ersetzt logging |
|
def logger(txt,method,txt2): |
|
"""logging""" |
|
logging.info(txt+ txt2) |
|
|
departmentList="Renn\nRheinberger\nDaston\nKlein\nSibum\nIT\nInstitut\nBibliothek" |
departmentList="Renn\nRheinberger\nDaston\nKlein\nSibum\nIT\nInstitut\nBibliothek" |
|
|
|
|
def getTemplate(self, tpName): |
|
"""get a template file either form the instance or from the product""" |
|
ext=self.ZopeFind(self.aq_parent,obj_ids=[tpName]) |
def createNewDBEntry(self,publish_the_data,key,name,vorname,title,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by="",e_mail2="",txt="",txt_p="no",stay_at_mpiwg="",group="",web_object_created="no",current_work=""): |
if ext: |
"""lege person in der datenbank an""" |
pt = getattr(self,ext[0][1].getId()) |
|
|
if date_to=="": # wenn date_to leer |
|
date_to="date_none" |
|
|
|
if date_from=="": # wenn date_fromleer |
|
date_from="date_none" |
|
msg="" |
|
#test ob id schon existiert |
|
if self.ZSQLQuery("select key from personal_www where key='%s'"%id): |
|
return False,"ERROR:key%s already exists"%key |
|
|
|
#eintragen |
|
columnlist="""publish_the_data,key,last_name,first_name,title,status,e_mail,e_mail_p,date_from,date_to,department,home_inst,funded_by,e_mail2,date_stay_at_mpiwg,web_object_created,"group",current_work,current_work_p """ |
|
insertTuple=(publish_the_data,key,name,vorname,title,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by,e_mail2,stay_at_mpiwg,web_object_created,group,current_work,"yes") |
|
|
|
insert=[] |
|
for element in insertTuple: |
|
if element=="date_none": # date_none eintrag wird zu null uebersetzt |
|
insert.append('null') |
else: |
else: |
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/'+tpName)).__of__(self) |
insert.append("%s"%self.ZSQLQuote(element)) |
assert(pt) |
|
return pt |
insertStr=",".join(insert) |
|
queryStr="INSERT INTO personal_www (%s) VALUES (%s)"%(columnlist,insertStr) |
|
self.ZSQLQuery("SET DATESTYLE TO 'German'") |
|
self.ZSQLQuery(queryStr) |
|
logging.info("QQQQ %s:"%queryStr) |
|
#currentwork |
|
#if not (current_work==""): |
|
# queryStr="INSERT INTO current_work (key_main,current,publish) VALUES ('%s',%s,'%s')"%(key,self.ZSQLQuote(current_work),"yes") |
|
|
|
# self.ZSQLQuery(queryStr) |
|
|
class MPIWGStaff(CatalogAware,ZSQLExtendFolder): |
return True,msg |
|
class MPIWGStaff(CatalogAware,ZSQLExtendFolder,Cacheable): |
"""Staff""" |
"""Staff""" |
|
|
meta_type="MPIWGStaff" |
meta_type="MPIWGStaff" |
Line 39 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 81 class MPIWGStaff(CatalogAware,ZSQLExtend
|
departmentList=departmentList |
departmentList=departmentList |
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
|
|
def getConnectionObj(self):#ueberschreibe connection id methode |
def redirect(self,RESPONSE,url): |
|
"""mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen""" |
|
|
return getattr(self.de,self.de.connection_id) |
timeStamp=time.time() |
|
|
|
if url.find("?")>-1: #giebt es schon parameter |
|
addStr="&time=%s" |
|
else: |
|
addStr="?time=%s" |
|
|
|
RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT') |
|
logging.error(email.Utils.formatdate()+' GMT') |
|
RESPONSE.redirect(url+addStr%timeStamp) |
|
|
|
def getKeyUTF8(self): |
|
"""get db_key utf8""" |
|
return utf8ify(self.getKey()) |
|
|
|
def setKey(self,key): |
|
"""set key""" |
|
self.key=key |
|
|
|
def getKey(self): |
|
"""get database key""" |
|
if hasattr(self,'key'): |
|
#logging.error("SAVED KEY:%s"%self.key) |
|
return unicodify(self.key.lower()) |
|
#return self.key.lower() |
|
|
|
#fuer alt faelle ohne key |
|
#logging.error("NEW KEY:%s"%(self.firstName+'_'+self.lastName).lower().replace(' ','')) |
|
return (self.firstName+'_'+self.lastName).lower().replace(' ','') |
|
|
|
def getConnectionObj(self): |
|
"""returns connection id (from root)""" |
|
root = self.getMPIWGRoot() |
|
return root.getConnectionObj() |
|
|
def isPublished(self): |
def isPublished(self): |
"""gib publications status aus der datenbank aus""" |
"""gib publications status aus der datenbank aus""" |
username=self.getId() |
key=self.getKey() |
query="select count(publish_the_data) from personal_www where username='%s' and publish_the_data='yes'"%username |
query="select count(publish_the_data) from personal_www where lower(key)='%s' and publish_the_data='yes'"%key |
|
|
res = self.ZSQLQuery(query) |
res = self.ZSQLQuery(query) |
|
|
Line 55 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 131 class MPIWGStaff(CatalogAware,ZSQLExtend
|
else: |
else: |
return False |
return False |
|
|
def createNewDBEntry(self,publish_the_data,id,name,vorname,username,title,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by="",e_mail2="",txt="",txt_p="no",stay_at_mpiwg=""): |
|
"""lege person in der datenbank an""" |
|
msg="" |
|
#test ob id schon existiert |
|
if self.ZSQLQuery("select id from personal_www where id='%s'"%id): |
|
return False,"ERROR:id %s already exists"%id |
|
|
|
if self.ZSQLQuery("select username from personal_www where username='%s' and publish_the_data='yes'"%username): |
|
|
|
return False,"ERROR:username %s already exists and has data published, id=%s not added (running update again might solve this problem)"%(username,id) |
|
|
|
if self.ZSQLQuery("select username from personal_www where username='%s' and not publish_the_data='yes'"%username): |
|
msg="WARNING:username %s not unique but id=%s added"%(username,id) |
|
#eintragen |
|
columnlist="publish_the_data,id,name,vorname,username,title,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by,e_mail2,stay_at_mpiwg" |
|
insertTuple=(publish_the_data,id,name,vorname,username,title,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by,e_mail2,stay_at_mpiwg) |
|
|
|
insert=[] |
|
for element in insertTuple: |
|
insert.append("'%s'"%element) |
|
|
|
insertStr=",".join(insert) |
|
queryStr="INSERT INTO personal_www (%s) VALUES (%s)"%(columnlist,insertStr) |
|
self.ZSQLQuery("SET DATESTYLE TO 'German'") |
|
self.ZSQLQuery(queryStr) |
|
|
|
#currentwork |
|
if not (txt==""): |
|
queryStr="INSERT INTO current_work (id_main,current,publish) VALUES ('%s','%s','%s')"%(id,txt,txt_p) |
|
|
|
self.ZSQLQuery(queryStr) |
|
|
|
return True,msg |
|
|
|
def updateDBEntry(self,publish_the_data,date_from,date_to,DBid=None,stay_at_mpiwg="",position="",abteilung=""): |
def updateDBEntry(self,publish_the_data,date_from,date_to,DBid=None,stay_at_mpiwg="",position="",abteilung=""): |
"""zpddatedb""" |
"""zpddatedb""" |
if not DBid: |
if not DBid: |
DBid=self.getDBId() |
DBid=self.getDBId() |
|
|
|
|
self.ZSQLQuery("SET DATESTYLE TO 'German'") |
self.ZSQLQuery("SET DATESTYLE TO 'German'") |
|
|
test=self.ZSQLQuery("select id from personal_www where id='%s' "%DBid) |
test=self.ZSQLQuery("select id from personal_www where id='%s' "%DBid) |
|
|
|
|
if test and (len(test)>0): #dataset exists |
if test and (len(test)>0): #dataset exists |
zLOG.LOG("MPIWG Web",zLOG.INFO,'UPDATE: _table="personal_www",_identify="id=%s"'%DBid+',publish_the_data=%s'%publish_the_data+',date_from=%s'%date_from+',date_to=%s'%date_to+',stay_at_mpiwg=%s'%stay_at_mpiwg+',position=%s'%position) |
logger("MPIWG Web",logging.INFO,'UPDATE: _table="personal_www",_identify="id=%s"'%DBid+',publish_the_data=%s'%publish_the_data+',date_from=%s'%date_from+',date_to=%s'%date_to+',stay_at_mpiwg=%s'%stay_at_mpiwg+',position=%s'%position) |
|
|
self.ZSQLChange(_table="personal_www",_identify="id=%s"%DBid,publish_the_data=publish_the_data, |
self.ZSQLChange(_table="personal_www",_identify="id=%s"%DBid,publish_the_data=publish_the_data, |
date_from=date_from, |
date_from=date_from, |
date_to=date_to,stay_at_mpiwg=stay_at_mpiwg,position=position,abteilung=abteilung) |
date_to=date_to,stay_at_mpiwg=stay_at_mpiwg,position=position,abteilung=abteilung) |
Line 117 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 161 class MPIWGStaff(CatalogAware,ZSQLExtend
|
"""change PublicationSelectionMode""" |
"""change PublicationSelectionMode""" |
|
|
self.publicationSelectionMode=publicationSelectionMode |
self.publicationSelectionMode=publicationSelectionMode |
|
self.ZCacheable_invalidate() |
|
if RESPONSE: |
|
self.redirect(RESPONSE,"editPublications") |
|
|
|
|
|
def downloadCV(self,RESPONSE): |
|
"""download cv file""" |
|
ob=self._getOb("downloadableFiles")._getOb("cv.pdf") |
|
|
|
RESPONSE.redirect(ob.absolute_url()+"/download") |
|
|
|
def getLastUpdateCV(self): |
|
"""getDate of Last Update""" |
|
try: |
|
ob=self._getOb("downloadableFiles")._getOb("cv.pdf") |
|
return ob.getLastChangeDate() |
|
except: |
|
return "No file yet!" |
|
def getLastUpdatePublications(self): |
|
"""getDate of Last Update""" |
|
try: |
|
ob=self._getOb("downloadableFiles")._getOb("publications.pdf") |
|
return ob.getLastChangeDate() |
|
except: |
|
return "No file yet!" |
|
def downloadPublications(self,RESPONSE): |
|
"""download publications""" |
|
ob=self._getOb("downloadableFiles")._getOb("publications.pdf") |
|
|
|
RESPONSE.redirect(ob.absolute_url()+"/download") |
|
|
|
def changeDownloads(self,cv_pdf=None,cv_publish=None,publications_pdf=None,publications_publish=None,RESPONSE=None): |
|
""""change the downloadable files""" |
|
self.ZCacheable_invalidate() |
|
if not hasattr(self,'downloadableFiles'): |
|
|
|
extFolder = extVersionedFileFolder() |
|
extFolder.id = "downloadableFiles" |
|
self._setObject(extFolder.id,extFolder) |
|
|
|
ob = self._getOb("downloadableFiles") |
|
|
|
if cv_publish: |
|
self.cv_publish=cv_publish |
|
|
|
if publications_publish: |
|
self.publications_publish=publications_publish |
|
|
|
if cv_pdf: |
|
if not hasattr(ob,"cv.pdf"): |
|
ob.addFile("",cv_pdf,newName="cv.pdf") |
|
|
|
else: |
|
cvFile = getattr(ob,"cv.pdf") |
|
cvFile.addContentObject("","",file=cv_pdf) |
|
|
|
if publications_pdf: |
|
if not hasattr(ob,"publications.pdf"): |
|
ob.addFile("",cv_pdf,newName="publications.pdf") |
|
|
|
else: |
|
cvFile = getattr(ob,"publications.pdf") |
|
cvFile.addContentObject("","",file=publications_pdf) |
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("editPublications") |
self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER']) |
|
|
|
|
def getPublishImage(self): |
def getPublishImage(self): |
Line 131 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 238 class MPIWGStaff(CatalogAware,ZSQLExtend
|
|
|
if file and not(file.filename==""): |
if file and not(file.filename==""): |
if self.getImageObj(): |
if self.getImageObj(): |
self.getImageObj().updateImage(file,rename=None,RESPONSE=None) |
self.getImageObj().updateImage(file,_rename=None,RESPONSE=None) |
else: |
else: |
# create new image object |
# create new image object |
xp = file.filename.rfind('.') |
xp = file.filename.rfind('.') |
if xp > 0: |
if xp > 0: |
ext = file.filename[xp:] |
ext = file.filename[xp:] |
fn = self.getId()+ext |
#fn = self.getId()+ext |
zLOG.LOG("MPWIG STAFF", zLOG.INFO, "new filename: %s"%fn) |
fn = self.getId() |
|
logger("MPWIG STAFF", logging.INFO, "new filename: %s"%fn) |
self.getImageFolder().addImage2(file,fileName=fn) |
self.getImageFolder().addImage2(file,fileName=fn) |
else: |
else: |
zLOG.LOG("MPWIG STAFF", zLOG.ERROR, "uploaded filename %s has no extension!"%file.filename) |
logger("MPWIG STAFF", logging.ERROR, "uploaded filename %s has no extension!"%file.filename) |
|
|
self.publishImage=publishImage |
self.publishImage=publishImage |
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("edit") |
self.redirect(RESPONSE,"edit") |
|
|
def getImageFolder(self): |
def getImageFolder(self): |
"""getImageFolder""" |
"""getImageFolder""" |
Line 155 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 263 class MPIWGStaff(CatalogAware,ZSQLExtend
|
try: |
try: |
return self.getPhysicalRoot().www_neu.images.staff_images |
return self.getPhysicalRoot().www_neu.images.staff_images |
except: |
except: |
zLOG.LOG("MPWIG STAFF", zLOG.ERROR, "image folder not found:"," has to be add /www_neu/staff_images") |
logger("MPWIG STAFF", logging.ERROR, "image folder not found: has to be add /www_neu/staff_images") |
return None |
return None |
|
|
def getImageObj(self): |
def getImageObj(self): |
Line 189 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 297 class MPIWGStaff(CatalogAware,ZSQLExtend
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
{'label':'Edit','action':'changeMPIWGStaffForm'}, |
{'label':'Edit','action':'changeMPIWGStaffForm'}, |
{'label':'Change Publications Special','action':'changePublications_specialForm'}, |
{'label':'Change Publications Special','action':'changePublications_specialForm'}, |
) |
) + Cacheable.manage_options |
|
|
def __init__(self,id, lastName,firstName): |
__manager_id = "ramCache" |
|
def __init__(self,id, lastName,firstName,key): |
"""init""" |
"""init""" |
self.id=id |
self.id=id |
self.title="%s, %s"%(lastName,firstName) |
self.title=key |
self.lastName=lastName |
self.lastName=lastName |
self.firstName=firstName |
self.firstName=firstName |
|
self.key=key |
|
|
def harvest_page(self): |
def getPersonID(self): |
|
"""gibt den ID fuer die Person zurueck" |
|
im Moment ist personID = id, i.e. e-mail |
|
""" |
|
return self.id |
|
|
|
def harvest_page_old(self,context=None): |
"""geharvestete seite = verschlankte version von members_main""" |
"""geharvestete seite = verschlankte version von members_main""" |
pt = getTemplate(self, "harvest_members_main") |
#pt = getTemplate(self, "harvest_members_main") |
|
|
|
if not self.isPublished(): |
|
return "" |
|
if not context: |
|
context=self |
|
|
|
|
|
ext=getattr(self,"harvest_members_main",None) |
|
if ext: |
|
return getattr(self,ext.getId())() |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','harvest_members_main')).__of__(context) |
|
|
|
|
return pt() |
return pt() |
|
|
|
def harvest_page(self): |
|
"""harvest""" |
|
if not self.isPublished(): |
|
return "" |
|
return getattr(self.en.staff.members,self.getId()).index_html() |
|
|
|
|
def index_html(self): |
def index_html(self): |
"""show homepage""" |
"""show homepage""" |
|
|
|
bound_names={} |
|
request = self.REQUEST |
|
if request is not None: |
|
response = request.response |
|
if not response.headers.has_key('content-type'): |
|
response.setHeader('content-type', 'text/html') |
|
|
|
security = getSecurityManager() |
|
bound_names['user'] = security.getUser() |
|
|
|
# Retrieve the value from the cache. |
|
keyset = None |
|
if self.ZCacheable_isCachingEnabled(): |
|
|
|
# Prepare a cache key. |
|
keyset = {'here': self} |
|
|
|
result = self.ZCacheable_get(keywords=keyset) |
|
|
|
if result is not None: |
|
# Got a cached value. |
|
return result |
|
|
pt = getTemplate(self, "members_main") |
pt = getTemplate(self, "members_main") |
return pt() |
# Execute the template in a new security context. |
|
security.addContext(self) |
|
|
|
try: |
|
result = pt.pt_render(extra_context=bound_names) |
|
if keyset is not None: |
|
# Store the result in the cache. |
|
self.ZCacheable_set(result, keywords=keyset) |
|
|
|
return result |
|
finally: |
|
security.removeContext(self) |
|
|
|
|
|
|
def changePublications_specialForm(self): |
def changePublications_specialForm(self): |
"""Priority publications manual field""" |
"""Priority publications manual field""" |
Line 215 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 389 class MPIWGStaff(CatalogAware,ZSQLExtend
|
|
|
def changePublications_special(self,usePublicationsSpecial=None,specialPublicationsField=None,RESPONSE=None): |
def changePublications_special(self,usePublicationsSpecial=None,specialPublicationsField=None,RESPONSE=None): |
"""change publications special params""" |
"""change publications special params""" |
|
self.ZCacheable_invalidate() |
if usePublicationsSpecial: |
if usePublicationsSpecial: |
self.usePublicationsSpecial=True |
self.usePublicationsSpecial=True |
|
|
Line 224 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 399 class MPIWGStaff(CatalogAware,ZSQLExtend
|
self.specialPublicationsField=specialPublicationsField[0:] |
self.specialPublicationsField=specialPublicationsField[0:] |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
self.redirect(RESPONSE,'manage_main') |
|
|
|
|
def publications_full(self): |
def publications_full(self): |
Line 248 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 423 class MPIWGStaff(CatalogAware,ZSQLExtend
|
return pt() |
return pt() |
|
|
security.declareProtected('View management screens','changeMPIWGStaff') |
security.declareProtected('View management screens','changeMPIWGStaff') |
def changeMPIWGStaff(self,lastName,firstName,RESPONSE=None): |
def changeMPIWGStaff(self,lastName,firstName,key=None,RESPONSE=None): |
"""change it""" |
"""change it""" |
|
self.ZCacheable_invalidate() |
self.title="%s, %s"%(lastName,firstName) |
self.title="%s, %s"%(lastName,firstName) |
self.lastName=lastName |
self.lastName=lastName |
self.firstName=firstName |
self.firstName=firstName |
|
if key: |
|
self.key = key |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
self.redirect(RESPONSE,'manage_main') |
|
|
security.declareProtected('View management screens','edit') |
security.declareProtected('View management screens','edit') |
def edit(self): |
def edit(self): |
"""Edit the pages""" |
"""Edit the pages""" |
#TODO: zusammenspiel mit apache, redirect auf 18080 rausnehmen bzw. zumindest verallgemeinern |
#TODO: zusammenspiel mit apache, redirect auf 18080 rausnehmen bzw. zumindest verallgemeinern |
if self.REQUEST['SERVER_URL']=="http://www.mpiwg-berlin.mpg.de": |
#if self.REQUEST['SERVER_URL']=="http://www.mpiwg-berlin.mpg.de": |
redURL="http://xserve04.mpiwg-berlin.mpg.de:18080/www_neu/de/mitarbeiter/members/%s/edit"%self.getId() |
# redURL="http://xserve04.mpiwg-berlin.mpg.de:18080/www_neu/de/mitarbeiter/members/%s/edit"%self.getId() |
|
# |
self.REQUEST.RESPONSE.redirect(redURL) |
# self.REQUEST.RESPONSE.redirect(redURL) |
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff.zpt')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff.zpt')).__of__(self) |
|
|
|
|
|
logging.error("XX:"+email.Utils.formatdate().split("-")[0]+'GMT') |
return pt() |
return pt() |
|
|
mainEditFile=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff_main.zpt')) |
mainEditFile=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff_main.zpt')) |
|
addPublicationsBib=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addPublicationsBib.zpt')) |
|
|
def getPathStyle(self, path, selected, style=""): |
def getPathStyle(self, path, selected, style=""): |
"""returns a string with the given style + 'sel' if path == selected.""" |
"""returns a string with the given style + 'sel' if path == selected.""" |
Line 279 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 461 class MPIWGStaff(CatalogAware,ZSQLExtend
|
else: |
else: |
return style |
return style |
|
|
|
|
|
def getLabel(self): |
|
"""returns a label for this object""" |
|
return self.title |
|
|
|
def getBreadcrumbs(self): |
|
"""return list of breadcrumbs from here to the root""" |
|
crumbs = [] |
|
# skip direct parent Folder /members/ |
|
parent = self.aq_parent.aq_parent |
|
# get parents breadcrumbs |
|
logging.debug("getbreadcrumbs-: title=%s self=%s parent=%s"%(self.title, repr(self), repr(parent))) |
|
if hasattr(parent, 'getBreadcrumbs'): |
|
logging.debug("getbreadcrumbs: recurse to %s"%parent) |
|
crumbs = parent.getBreadcrumbs() |
|
|
|
# try to get acquisition URL from parent |
|
if hasattr(parent, 'absolute_url'): |
|
baseUrl = "%s/%s/"%(parent.absolute_url(), 'members') |
|
else: |
|
baseUrl = "/en/staff/members/" |
|
|
|
# add this |
|
crumbs.append((self.getLabel(), baseUrl+self.getId(), self)) |
|
|
|
return crumbs |
|
|
|
|
|
def changeCurrentWork(self,current_work,key,publish="yes",RESPONSE=None): |
|
"""change current work""" |
|
|
|
query="UPDATE personal_www SET current_work =%s WHERE key='%s'" |
|
|
|
self.ZSQLQuery(query%(self.ZSQLQuote(current_work),key)) |
|
|
|
query="UPDATE personal_www SET current_work_p =%s WHERE key='%s'" |
|
|
|
self.ZSQLQuery(query%(self.ZSQLQuote(publish),key)) |
|
self.ZCacheable_invalidate() |
|
if RESPONSE: |
|
self.redirect(RESPONSE,"edit") |
|
|
security.declareProtected('View management screens','changeResearch') |
security.declareProtected('View management screens','changeResearch') |
def changeResearch(self,noredirect=None): |
def changeResearch(self,noredirect=None,RESPONSE=None): |
"""change the research entries""" |
"""change the research entries""" |
|
self.ZCacheable_invalidate() |
newEntries={} |
newEntries={} |
id_main=self.REQUEST.form['id_main'] |
key_main=self.REQUEST.form['key_main'] |
|
|
mainfieldL=self.REQUEST.form['main_fields'].split(",") |
mainfieldL=self.REQUEST.form['main_fields'].split(",") |
mainfield={} |
mainfield={} |
Line 312 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 537 class MPIWGStaff(CatalogAware,ZSQLExtend
|
#new entries |
#new entries |
for newEntry in newEntries.keys(): |
for newEntry in newEntries.keys(): |
query="INSERT INTO %s "%newEntry |
query="INSERT INTO %s "%newEntry |
keys=['id_main'] |
keys=['key_main'] |
values=["'"+sql_quote(id_main)+"'"] |
values=["'"+sql_quote(key_main)+"'"] |
for key in newEntries[newEntry].keys(): |
for key in newEntries[newEntry].keys(): |
keys.append(key) |
keys.append(key) |
values.append("'"+sql_quote(newEntries[newEntry][key])+"'") |
values.append("'"+sql_quote(newEntries[newEntry][key])+"'") |
Line 329 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 554 class MPIWGStaff(CatalogAware,ZSQLExtend
|
self.ZSQLQuery(query) |
self.ZSQLQuery(query) |
|
|
if not noredirect: |
if not noredirect: |
self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) |
self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER']) |
|
|
security.declareProtected('View management screens','editCV') |
security.declareProtected('View management screens','editCV') |
def editCV(self,cv=None,oid=None,RESPONSE=None): |
def editCV(self,cv=None,oid=None,RESPONSE=None): |
Line 340 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 565 class MPIWGStaff(CatalogAware,ZSQLExtend
|
return pt() |
return pt() |
|
|
query="UPDATE personal_www SET cv =%s WHERE oid='%s'" |
query="UPDATE personal_www SET cv =%s WHERE oid='%s'" |
|
self.ZCacheable_invalidate() |
self.ZSQLQuery(query%(self.ZSQLQuote(cv),oid)) |
self.ZSQLQuery(query%(self.ZSQLQuote(cv),oid)) |
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("editCV") |
self.redirect(RESPONSE,"editCV") |
|
|
|
|
|
def getProfile(self): |
|
"""get the profile""" |
|
self.REQUEST.RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT') |
|
|
|
founds=self.ZSQLInlineSearchU(_table='personal_www',key=self.getKey()) |
|
html="""<html><body>%s</body></html>""" |
|
if founds.profile and founds.profile != "": |
|
|
|
return html%founds.profile |
|
else: |
|
|
|
return html%self.generateProfileForPerson(founds) |
|
|
|
def editProfile(self,oid=None,RESPONSE=None, kupu=None, preview=None): |
|
"""edit Profile, new entry replaces CD, current work and research interests""" |
|
|
|
if (not oid): |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editProfile.zpt')).__of__(self) |
|
return pt() |
|
|
|
self.ZCacheable_invalidate() |
|
|
|
|
|
if preview: |
|
pass |
|
#TODO: not supported yet |
|
#kupu=preview |
|
# find content of body tags |
|
|
|
start=kupu.find("<body>") |
|
end=kupu.find("</body>") |
|
|
|
newcontent= kupu[start+6:end] |
|
|
|
|
|
|
|
|
|
if preview: |
|
#TODO: not supported yet |
|
if RESPONSE: |
|
self.redirect(RESPONSE,"editProfile") |
|
|
|
#return self.preview(newcontent) |
|
|
|
query="UPDATE personal_www SET profile=%s WHERE oid='%s'" |
|
self.ZSQLQuery(query%(self.ZSQLQuote(newcontent),oid)) |
|
logging.error("PROFILE:"+query%(self.ZSQLQuote(newcontent),oid)) |
|
if RESPONSE: |
|
self.redirect(RESPONSE,"editProfile") |
|
|
|
|
|
|
|
def generateProfileForPerson(self,person): |
|
"""erzeugt ein automatisches Profil aus den alten Eintraegen CV, Current work, und research interests""" |
|
|
|
ret="" |
|
founds=self.ZSQLInlineSearch(_table='research_interest',key_main=person.key) |
|
if founds: |
|
ret="<p class=\"bio_section_header\">Research interests: </p><br/>" |
|
for found in self.sortPriority(founds): |
|
ret+=found.interest+"<br/>" |
|
|
|
|
|
if (person.current_work) and (not person.current_work==""): |
|
ret+="<p class=\"bio_section_header\">Current work: </p><br/>" |
|
|
|
ret+=person.current_work+"<br/>" |
|
if (person.cv) and (not person.cv==""): |
|
ret+="<p class=\"bio_section_header\">Curriculum Vitae: </p><br/>" |
|
ret+=self.formatAscii(person.cv) |
|
|
|
return ret |
|
security.declareProtected('View management screens','editDownloads') |
|
def editDownloads(self): |
|
"""editiere die Downloads von der Webseite""" |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editDownloads.zpt')).__of__(self) |
|
return pt() |
|
|
|
security.declareProtected('View management screens','editAdditionalLinks.zpt') |
|
def editAdditionalLinks(self): |
|
"""editiere die Downloads von der Webseite""" |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editAdditionalLinks.zpt')).__of__(self) |
|
return pt() |
|
|
|
|
security.declareProtected('View management screens','editAwards') |
security.declareProtected('View management screens','editAwards') |
def editAwards(self,awards=None,oid=None,RESPONSE=None): |
def editAwards(self,awards=None,oid=None,RESPONSE=None): |
Line 353 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 666 class MPIWGStaff(CatalogAware,ZSQLExtend
|
if (not oid): |
if (not oid): |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editAwards.zpt')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editAwards.zpt')).__of__(self) |
return pt() |
return pt() |
|
self.ZCacheable_invalidate() |
query="UPDATE personal_www SET awards =%s WHERE oid='%s'" |
query="UPDATE personal_www SET awards =%s WHERE oid='%s'" |
|
|
self.ZSQLQuery(query%(self.ZSQLQuote(awards),oid)) |
self.ZSQLQuery(query%(self.ZSQLQuote(awards),oid)) |
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("editAwards") |
self.redirect(RESPONSE,"editAwards") |
|
|
security.declareProtected('View management screens','editTalks') |
security.declareProtected('View management screens','editTalks') |
def editTalks(self): |
def editTalks(self): |
Line 382 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 695 class MPIWGStaff(CatalogAware,ZSQLExtend
|
return "\n".join(list) |
return "\n".join(list) |
|
|
security.declareProtected('View management screens','editMainData') |
security.declareProtected('View management screens','editMainData') |
def editMainData(self,REQUEST=None,RESPONSE=None,name=None,**argv): |
def editMainData(self,REQUEST=None,RESPONSE=None): |
"""edit main data""" |
"""edit main data""" |
|
self.ZCacheable_invalidate() |
|
argv=REQUEST.form |
|
|
|
if not argv.has_key('last_name'): |
if not name: |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMainData.zpt')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMainData.zpt')).__of__(self) |
return pt() |
return pt() |
else: |
else: |
self.ZSQLChange(argv,_table="personal_www",_identify="id=%s"%self.getDBId(),USE_FORM="yes") |
self.ZSQLChange(argv,_table="personal_www",_identify="key=%s"%self.getKeyUTF8(),USE_FORM="yes") |
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("editMainData") |
self.redirect(RESPONSE,"editMainData") |
|
|
security.declareProtected('View management screens','newBibliogrpaphy') |
security.declareProtected('View management screens','newBibliogrpaphy') |
def newBibliography(self,_docType=None, _addEntry=None,RESPONSE=None,**argv): |
def newBibliography(self,_docType=None, _addEntry=None,RESPONSE=None,**argv): |
Line 416 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 730 class MPIWGStaff(CatalogAware,ZSQLExtend
|
bookId="b%06i" % newId |
bookId="b%06i" % newId |
|
|
self.ZSQLAdd(argv,_table="bibliography",reference_type=_docType,id=bookId) |
self.ZSQLAdd(argv,_table="bibliography",reference_type=_docType,id=bookId) |
self.ZSQLAdd(_table="publications",id_gen_bib=bookId,id_main=self.getDBId(),publish='yes') |
|
|
self.ZSQLAdd(_useRequest=False,_table="publications",id_gen_bib=bookId,key_main=self.getDBId(),publish='yes') |
self.updatePublicationDB(personId=self.getDBId()) |
self.updatePublicationDB(personId=self.getDBId()) |
|
|
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("editPublications") |
self.redirect(RESPONSE,"editPublications") |
|
|
return True |
return True |
|
|
Line 447 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 762 class MPIWGStaff(CatalogAware,ZSQLExtend
|
|
|
def changeSortingMode(self,sortingMode,RESPONSE=None,REQUEST=None): |
def changeSortingMode(self,sortingMode,RESPONSE=None,REQUEST=None): |
"""change sorting mode""" |
"""change sorting mode""" |
|
self.ZCacheable_invalidate() |
self.sortingMode=sortingMode |
self.sortingMode=sortingMode |
|
|
if RESPONSE and REQUEST: |
if RESPONSE and REQUEST: |
REQUEST.RESPONSE.redirect(REQUEST['HTTP_REFERER']) |
self.redirect(RESPONSE,REQUEST['HTTP_REFERER']) |
|
|
return True |
return True |
|
|
def getSortingMode(self): |
def getSortingMode(self): |
"""get sorting mode""" |
"""get sorting mode""" |
return getattr(self,'sortingMode','priority') |
mode=getattr(self,'sortingMode','priority') |
|
if mode=="year": |
|
return "year DESC" |
|
else: |
|
return mode |
|
|
def integer(self,value): |
def integer(self,value): |
try: |
try: |
Line 465 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 785 class MPIWGStaff(CatalogAware,ZSQLExtend
|
return 0 |
return 0 |
|
|
security.declareProtected('View management screens','changePublications') |
security.declareProtected('View management screens','changePublications') |
def changePublications(self): |
def changePublications(self,RESPONSE=None): |
"""change the publication list""" |
"""change the publication list""" |
self.changeResearch(noredirect=True) |
self.changeResearch(noredirect=True) |
|
self.ZCacheable_invalidate() |
#self.updatePublicationDB(personId=self.getDBId()) |
#self.updatePublicationDB(personId=self.getDBId()) |
self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) |
self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER']) |
|
|
|
|
|
|
security.declareProtected('View management screens','addPublications') |
security.declareProtected('View management screens','addPublications') |
def addPublications(self,submit=None,REQUEST=None,noredirect=None): |
def addPublications(self,submit=None,REQUEST=None,noredirect=None,RESPONSE=None): |
"""add publications""" |
"""add publications""" |
|
|
#setzte flag ob aufruf aus suchformular |
#setzte flag ob aufruf aus suchformular |
Line 493 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 814 class MPIWGStaff(CatalogAware,ZSQLExtend
|
if not (type(entries) is ListType): |
if not (type(entries) is ListType): |
entries=[entries] |
entries=[entries] |
|
|
|
|
for bibId in entries: |
for bibId in entries: |
query="INSERT INTO %s " % "publications" |
query="INSERT INTO %s " % "publications" |
query+="(id_main,id_institutsbibliographie,publish) " |
query+="(key_main,id_institutsbibliographie,publish) " |
query+="VALUES ('%s','%s','yes')" %(sql_quote(self.getDBId()),sql_quote(bibId)) |
query+="VALUES ('%s','%s','yes')" %(sql_quote(self.getKey()),sql_quote(bibId)) |
|
|
#self.ZSQLAdd(_table="publications",id_institutsbibliographie=bibId,id_main=self.getDBId(),publish='yes') |
#self.ZSQLAdd(_table="publications",id_institutsbibliographie=bibId,id_main=self.getDBId(),publish='yes') |
self.ZSQLQuery(query) |
self.ZSQLQuery(query) |
|
|
self.updatePublicationDB(personId=self.getDBId()) |
self.updatePublicationDB(personId=self.getKey()) |
|
|
if not noredirect: |
if not noredirect: |
|
|
self.REQUEST.RESPONSE.redirect("./editPublications") |
self.redirect(RESPONSE,"./editPublications") |
|
|
return True |
return True |
|
|
|
|
def getDBId(self): |
def getDBId(self): |
"""get id from the personal database""" |
"""get id from the personal database""" |
search=self.ZSQLInlineSearch(_table='personal_www',username=self.getId(),publish_the_data='yes') |
|
if search:#name existiert und published, dann nimm diesen falls es mehrereeventuell nich publizierte datensaetze gibt. |
#in der neuen version ist definitions gemaess der key der Datenbank gleich dem key im Object. |
return search[0].id |
# TODO: remove all occurences of getDBId and replaces it by getKey |
else:#nicht publiziert dann nimm einen davon |
return self.getKey() |
search2=self.ZSQLInlineSearch(_table='personal_www',username=self.getId()) |
|
if search2: |
# search=self.ZSQLInlineSearch(_table='personal_www',key=self.getKey(),publish_the_data='yes') |
return search2[0].id |
# if search:#name existiert und published, dann nimm diesen falls es mehrereeventuell nich publizierte datensaetze gibt. |
else: |
# return search[0].id |
return None |
# else:#nicht publiziert dann nimm einen davon |
|
# search2=self.ZSQLInlineSearch(_table='personal_www',username=self.getId()) |
|
# if search2: |
|
# return search2[0].id |
|
# else: |
|
# return None |
|
|
|
|
|
|
formatBiblHelp=bibliography.formatBiblHelp |
formatBiblHelp=bibliography.formatBiblHelp |
|
|
def sortBibliography(self,list,sortingMode=None): |
def sortBibliography(self,list,sortingMode=None,max=None): |
if not sortingMode: |
if not sortingMode: |
sortingMode=self.getSortingMode() |
sortingMode=self.getSortingMode() |
|
|
if sortingMode == "year": |
if sortingMode == "year": |
return self.sortYear(list) |
l= self.sortYear(list) |
|
else: |
|
l=self.sortPriority(list) |
|
|
|
if max: |
|
return l[0:min(len(l),max)] |
else: |
else: |
return self.sortPriority(list) |
return l |
|
|
def sortPriority(self,list): |
def sortPriority(self,list): |
def sort(x,y): |
def sort(x,y): |
Line 548 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 880 class MPIWGStaff(CatalogAware,ZSQLExtend
|
|
|
return cmp(xInt,yInt) |
return cmp(xInt,yInt) |
|
|
|
if not list: |
|
return [] |
tmp=[x for x in list] |
tmp=[x for x in list] |
tmp.sort(sort) |
tmp.sort(sort) |
|
|
return tmp |
return tmp |
|
|
def sortYear(self,list): |
def sortYear(self,list): |
Line 573 class MPIWGStaff(CatalogAware,ZSQLExtend
|
Line 908 class MPIWGStaff(CatalogAware,ZSQLExtend
|
tmp.sort(sort) |
tmp.sort(sort) |
return tmp |
return tmp |
|
|
def deleteField(self,table,oid): |
def deleteField(self,table,oid,RESPONSE=None): |
"""delete entry""" |
"""delete entry""" |
query="DELETE FROM %s WHERE oid = '%s'"%(table,oid) |
query="DELETE FROM %s WHERE oid = '%s'"%(table,oid) |
|
|
self.ZSQLQuery(query) |
self.ZSQLQuery(query) |
self.REQUEST.RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) |
self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER']) |
|
|
|
|
def manage_addMPIWGStaffForm(self): |
def manage_addMPIWGStaffForm(self): |
Line 594 def manage_addMPIWGStaff(self,id,lastNam
|
Line 929 def manage_addMPIWGStaff(self,id,lastNam
|
|
|
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
self.redirect(RESPONSE,'manage_main') |
|
|
|
|