annotate MPIWGStaff_old.py @ 30:aa4ab114c28a

more work on projects.
author casties
date Tue, 23 Apr 2013 14:36:32 +0200
parents ddf6c1a27a4b
children ab836d3f96dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
1 """This file contains the classes for the organization of the staff"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
2 # TODO: pruefe ob die id der einzelnen tabellen, wie id in publications noch benutzt werden
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
3 # TODO: pruefe ob die bibliographischen felder in publications noch benutzt werden
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
4 # TODO: wird username gebraucht?
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
5
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
6 from OFS.Folder import Folder
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
7 from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
8 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
9 from Products.PageTemplates.PageTemplate import PageTemplate
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
10 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
11 from Products.ZCatalog.CatalogPathAwareness import CatalogAware
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
12 from Products.versionedFile.extVersionedFile import extVersionedFileFolder
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
13 from AccessControl import getSecurityManager
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
14
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
15 import os
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
16 import logging
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
17 import bibliography
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
18 import email
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
19 from Globals import package_home
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
20 from Products.PythonScripts.standard import sql_quote
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
21 from types import *
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
22 from AccessControl import ClassSecurityInfo
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
23 import time
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
24 import logging
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
25 import email
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
26 import re
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
27 from OFS.Cache import Cacheable
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
28 import urllib2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
29 import transaction
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
30 import SrvTxtUtils
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
31
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
32 from MPIWGHelper import *
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
33 #ersetzt logging
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
34 def logger(txt,method,txt2):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
35 """logging"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
36 logging.info(txt+ txt2)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
37
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
38 departmentList="Renn\nRheinberger\nDaston\nKlein\nSibum\nIT\nInstitut\nBibliothek"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
39 coneService="http://127.0.0.1:8280/MetaDataManagerRestlet/cone/" # kann in MPIWGRoot konfiguriert werden.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
40
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
41
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
42
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
43 def createNewDBEntry(self,publish_the_data,key,name,vorname,titles_new,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=""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
44 """lege person in der datenbank an"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
45
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
46 if date_to=="": # wenn date_to leer
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
47 date_to="date_none"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
48
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
49 if date_from=="": # wenn date_fromleer
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
50 date_from="date_none"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
51 msg=""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
52 #test ob id schon existiert
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
53 if self.ZSQLQuery("select key from personal_www where key='%s'"%id):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
54 return False,"ERROR:key%s already exists"%key
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
55
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
56 #eintragen
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
57 columnlist="""publish_the_data,key,last_name,first_name,titles_new,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 """
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
58 insertTuple=(publish_the_data,key,name,vorname,titles_new,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")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
59
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
60 insert=[]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
61 for element in insertTuple:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
62 if element=="date_none": # date_none eintrag wird zu null uebersetzt
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
63 insert.append('null')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
64 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
65 insert.append("%s"%self.ZSQLQuote(element))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
66
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
67 insertStr=",".join(insert)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
68 queryStr="INSERT INTO personal_www (%s) VALUES (%s)"%(columnlist,insertStr)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
69 self.ZSQLQuery("SET DATESTYLE TO 'German'")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
70 self.ZSQLQuery(queryStr)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
71 logging.info("QQQQ %s:"%queryStr)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
72 #currentwork
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
73 #if not (current_work==""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
74 # queryStr="INSERT INTO current_work (key_main,current,publish) VALUES ('%s',%s,'%s')"%(key,self.ZSQLQuote(current_work),"yes")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
75
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
76 # self.ZSQLQuery(queryStr)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
77
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
78 return True,msg
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
79 class MPIWGStaff(CatalogAware,ZSQLExtendFolder,Cacheable):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
80 """Staff"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
81
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
82 meta_type="MPIWGStaff"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
83 default_catalog='MembersCatalog'
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
84 departmentList=departmentList
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
85 #_v_cone=None;
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
86 security=ClassSecurityInfo()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
87
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
88 def redirect(self,RESPONSE,url):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
89 """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
90
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
91 timeStamp=time.time()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
92
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
93 if url.find("?")>-1: #giebt es schon parameter
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
94 addStr="&time=%s"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
95 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
96 addStr="?time=%s"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
97
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
98 RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
99 logging.error(email.Utils.formatdate()+' GMT')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
100 RESPONSE.redirect(url+addStr%timeStamp)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
101
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
102 def getKeyUTF8(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
103 """get db_key utf8"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
104 logging.debug("KEY - MPIWGStaff 1:"+self.getKey())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
105 logging.debug("KEY - MPIWGStaff 2 :"+utf8ify(self.getKey()))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
106
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
107 return utf8ify(self.getKey())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
108
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
109 def setKey(self,key):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
110 """set key"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
111 self.key=key
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
112
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
113 def rmKey(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
114 """rm"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
115 self.key=None
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
116 return ""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
117
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
118 def getKey(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
119 """get database key"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
120
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
121
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
122 if getattr(self,'key',None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
123 logging.debug("KEY - MPIWGStaff 4:"+self.key)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
124 #logging.error("SAVED KEY:%s"%self.key)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
125 return unicodify(self.key.lower())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
126 #return self.key.lower()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
127
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
128 #fuer alt faelle ohne key
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
129 #logging.error("NEW KEY:%s"%(self.firstName+'_'+self.lastName).lower().replace(' ',''))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
130 return (self.firstName+'_'+self.lastName).lower().replace(' ','')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
131
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
132 def getConnectionObj(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
133 """returns connection id (from root)"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
134 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
135 root = self.getMPIWGRoot()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
136 return root.getConnectionObj()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
137 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
138 return self.en.getConnectionObj()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
139
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
140 def isPublished(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
141 """gib publications status aus der datenbank aus"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
142 key=self.getKey()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
143 query="select count(publish_the_data) from personal_www where lower(key)='%s' and publish_the_data='yes'"%key
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
144
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
145 res = self.ZSQLQuery(query)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
146
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
147 if res and res[0].count>0:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
148 return True
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
149 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
150 return False
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
151
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
152
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
153
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
154 def updateDBEntry(self,publish_the_data,date_from,date_to,DBid=None,stay_at_mpiwg="",position="",abteilung=""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
155 """zpddatedb"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
156 if not DBid:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
157 DBid=self.getDBId()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
158
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
159
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
160 self.ZSQLQuery("SET DATESTYLE TO 'German'")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
161
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
162 test=self.ZSQLQuery("select id from personal_www where id='%s' "%DBid)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
163
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
164
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
165 if test and (len(test)>0): #dataset exists
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
166 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)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
167 self.ZSQLChange(_table="personal_www",_identify="id=%s"%DBid,publish_the_data=publish_the_data,
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
168 date_from=date_from,
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
169 date_to=date_to,stay_at_mpiwg=stay_at_mpiwg,position=position,abteilung=abteilung)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
170 return True
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
171 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
172 return False
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
173
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
174 def getPublicationSelectionMode(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
175 """get publication selection mode, default 'priority'"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
176 return getattr(self,'publicationSelectionMode','priority')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
177
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
178 def changePublicationSelectionMode(self,publicationSelectionMode,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
179 """change PublicationSelectionMode"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
180
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
181 self.publicationSelectionMode=publicationSelectionMode
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
182 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
183 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
184 self.redirect(RESPONSE,"editPublications")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
185
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
186
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
187 def downloadCV(self,RESPONSE):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
188 """download cv file"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
189 ob=self._getOb("downloadableFiles")._getOb("cv.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
190
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
191 RESPONSE.redirect(ob.absolute_url()+"/download")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
192
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
193 def getLastUpdateCV(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
194 """getDate of Last Update"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
195 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
196 ob=self._getOb("downloadableFiles")._getOb("cv.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
197 return ob.getLastChangeDate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
198 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
199 return "No file yet!"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
200 def getLastUpdatePublications(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
201 """getDate of Last Update"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
202 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
203 ob=self._getOb("downloadableFiles")._getOb("publications.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
204 return ob.getLastChangeDate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
205 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
206 return "No file yet!"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
207 def downloadPublications(self,RESPONSE):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
208 """download publications"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
209 ob=self._getOb("downloadableFiles")._getOb("publications.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
210
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
211 RESPONSE.redirect(ob.absolute_url()+"/download")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
212
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
213 def changeDownloads(self,cv_pdf=None,cv_publish=None,publications_pdf=None,publications_publish=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
214 """"change the downloadable files"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
215 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
216 if not hasattr(self,'downloadableFiles'):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
217
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
218 extFolder = extVersionedFileFolder()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
219 extFolder.id = "downloadableFiles"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
220 self._setObject(extFolder.id,extFolder)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
221
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
222 ob = self._getOb("downloadableFiles")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
223
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
224 if cv_publish:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
225 self.cv_publish=cv_publish
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
226
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
227 if publications_publish:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
228 self.publications_publish=publications_publish
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
229
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
230 if cv_pdf:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
231 if not hasattr(ob,"cv.pdf"):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
232 ob.addFile("",cv_pdf,newName="cv.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
233
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
234 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
235 cvFile = getattr(ob,"cv.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
236 cvFile.addContentObject("","",file=cv_pdf)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
237
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
238 if publications_pdf:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
239 if not hasattr(ob,"publications.pdf"):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
240 ob.addFile("",cv_pdf,newName="publications.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
241
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
242 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
243 cvFile = getattr(ob,"publications.pdf")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
244 cvFile.addContentObject("","",file=publications_pdf)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
245
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
246 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
247 self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER'])
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
248
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
249
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
250 def getPublishImage(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
251 """publish the image??, default no"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
252 return getattr(self,'publishImage','no')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
253
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
254 def updateImage(self,publishImage,file=None,rename=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
255 """update image"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
256
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
257 if file and not(file.filename==""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
258 if self.getImageObj():
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
259 self.getImageObj().updateImage(file,_rename=None,RESPONSE=None)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
260 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
261 # create new image object
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
262 xp = file.filename.rfind('.')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
263 if xp > 0:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
264 ext = file.filename[xp:]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
265 #fn = self.getId()+ext
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
266 fn = self.getId()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
267 logger("MPWIG STAFF", logging.INFO, "new filename: %s"%fn)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
268 self.getImageFolder().addImage2(file,fileName=fn)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
269 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
270 logger("MPWIG STAFF", logging.ERROR, "uploaded filename %s has no extension!"%file.filename)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
271
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
272 self.publishImage=publishImage
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
273
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
274 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
275 self.redirect(RESPONSE,"edit")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
276
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
277 def getImageFolder(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
278 """getImageFolder"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
279 #TODO: make place of staff image folder configurable
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
280
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
281 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
282 return self.getPhysicalRoot().www_neu.images.staff_images
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
283 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
284 logger("MPWIG STAFF", logging.ERROR, "image folder not found: has to be add /www_neu/staff_images")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
285 return None
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
286
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
287 def getImageObj(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
288 """getImage"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
289 imageFolder=self.getImageFolder()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
290
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
291 if not imageFolder: return None
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
292
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
293 image=getattr(imageFolder,self.getId(),None)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
294
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
295 if not image:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
296 for suffix in ['jpg','tif']:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
297
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
298 image=getattr(imageFolder,self.getId()+"."+suffix,None)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
299 if image:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
300 break
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
301 return image
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
302
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
303 def getImageUrl(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
304 """getImageUrl"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
305 image=self.getImageObj()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
306 if not image:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
307 return None
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
308 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
309 return self.getImageObj().absolute_url()+"/image"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
310
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
311 def PrincipiaSearchSource(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
312 """Return cataloguable key for ourselves."""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
313 return str(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
314
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
315 manage_options = Folder.manage_options+(
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
316 {'label':'Edit','action':'changeMPIWGStaffForm'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
317 {'label':'Change Publications Special','action':'changePublications_specialForm'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
318 ) + Cacheable.manage_options
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
319
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
320 __manager_id = "ramCache"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
321 def __init__(self,id, lastName,firstName,key):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
322 """init"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
323 self.id=id
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
324 self.title=key
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
325 self.lastName=lastName
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
326 self.firstName=firstName
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
327 self.key=key
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
328
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
329 def getPersonID(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
330 """gibt den ID fuer die Person zurueck"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
331 im Moment ist personID = id, i.e. e-mail
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
332 """
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
333 return self.id
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
334
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
335 def getConeUrl(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
336 """gibt coneURL zurueck"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
337
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
338 self.coneService=getattr(self, "coneServiceURL",coneService)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
339 logging.debug("coneservice:"+self.coneService)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
340
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
341 if getattr(self,'_v_cone',None)==None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
342 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
343
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
344 self._v_cone=SrvTxtUtils.getHttpData(self.coneService+self.getPersonID())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
345 #cone = urllib2.urlopen(self.coneService+self.getPersonID())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
346 #self._v_cone=cone.read()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
347 if self._v_cone==None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
348 self._v_cone=""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
349 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
350 self._v_cone=""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
351 return ""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
352
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
353 return self._v_cone
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
354
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
355
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
356
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
357
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
358 def harvest_page_old(self,context=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
359 """geharvestete seite = verschlankte version von members_main"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
360 #pt = getTemplate(self, "harvest_members_main")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
361
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
362 if not self.isPublished():
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
363 return ""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
364 if not context:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
365 context=self
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
366
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
367
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
368 ext=getattr(self,"harvest_members_main",None)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
369 if ext:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
370 return getattr(self,ext.getId())()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
371
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
372 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','harvest_members_main')).__of__(context)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
373
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
374
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
375 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
376
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
377 def harvest_page(self,mode="normal"):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
378 """harvest"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
379 logging.debug("AAAAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
380 if not self.isPublished():
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
381 return
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
382 st = getattr(self.en.staff.members,self.getId()).index_html(mode)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
383
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
384 templates = self.en.getHarvestCache()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
385 #templates = getattr(self,'getHarvestCache',self.en.getHarvestCache)()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
386 rendered = st
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
387 templates[self.absolute_url()]=rendered
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
388 transaction.commit()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
389 return rendered
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
390
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
391
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
392
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
393 def index_html(self,mode="normal"):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
394 """show homepage"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
395
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
396 bound_names={}
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
397 request = self.REQUEST
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
398 if request is not None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
399 response = request.response
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
400 if not response.headers.has_key('content-type'):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
401 response.setHeader('content-type', 'text/html')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
402
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
403 security = getSecurityManager()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
404 bound_names['user'] = security.getUser()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
405
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
406 # Retrieve the value from the cache.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
407 keyset = None
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
408 if self.ZCacheable_isCachingEnabled():
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
409
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
410 # Prepare a cache key.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
411 keyset = {'here': self}
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
412
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
413 result = self.ZCacheable_get(keywords=keyset)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
414
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
415 if result is not None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
416 # Got a cached value.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
417 return result
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
418
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
419 # look for individual page
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
420 if self.hasObject("index.html"):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
421 pt = getattr(self, "index.html")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
422 # else use template
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
423 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
424 if mode=="slim":
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
425 pt = getTemplate(self, "members_main_slim")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
426 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
427 pt = getTemplate(self, "members_main")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
428 # Execute the template in a new security context.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
429 security.addContext(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
430
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
431 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
432 result = pt.pt_render(extra_context=bound_names)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
433 if keyset is not None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
434 # Store the result in the cache.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
435 self.ZCacheable_set(result, keywords=keyset)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
436
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
437 return result
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
438 finally:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
439 security.removeContext(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
440
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
441
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
442
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
443 def changePublications_specialForm(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
444 """Priority publications manual field"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
445 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changePublications_special.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
446 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
447
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
448 def changePublications_special(self,usePublicationsSpecial=None,specialPublicationsField=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
449 """change publications special params"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
450 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
451 if usePublicationsSpecial:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
452 self.usePublicationsSpecial=True
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
453
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
454 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
455 self.usePublicationsSpecial=False
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
456
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
457 self.specialPublicationsField=specialPublicationsField[0:]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
458
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
459 if RESPONSE is not None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
460 self.redirect(RESPONSE,'manage_main')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
461
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
462
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
463 def publications_full(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
464 """show publication"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
465 pt=getTemplate(self, "publications_full_main")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
466 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
467
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
468 def talks_full(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
469 """show talks"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
470 pt=getTemplate(self, 'talks_full_main')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
471 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
472
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
473 def teaching_full(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
474 """show talks"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
475 pt=getTemplate(self, 'teaching_full_main')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
476 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
477
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
478 def changeMPIWGStaffForm(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
479 """change form"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
480 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGStaff.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
481 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
482
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
483 security.declareProtected('View management screens','changeMPIWGStaff')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
484 def changeMPIWGStaff(self,lastName,firstName,key=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
485 """change it"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
486 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
487 self.title="%s, %s"%(lastName,firstName)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
488 self.lastName=lastName
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
489 self.firstName=firstName
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
490 if key:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
491 self.key = key
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
492
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
493
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
494 if RESPONSE is not None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
495 self.redirect(RESPONSE,'manage_main')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
496
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
497 security.declareProtected('View management screens','edit')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
498 def edit(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
499 """Edit the pages"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
500 #TODO: zusammenspiel mit apache, redirect auf 18080 rausnehmen bzw. zumindest verallgemeinern
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
501 #if self.REQUEST['SERVER_URL']=="http://www.mpiwg-berlin.mpg.de":
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
502 # redURL="http://xserve04.mpiwg-berlin.mpg.de:18080/www_neu/de/mitarbeiter/members/%s/edit"%self.getId()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
503 #
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
504 # self.REQUEST.RESPONSE.redirect(redURL)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
505
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
506 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
507
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
508
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
509 logging.debug("XX:"+email.Utils.formatdate().split("-")[0]+'GMT')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
510 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
511
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
512 mainEditFile=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff_main.zpt'))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
513 addPublicationsBib=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addPublicationsBib.zpt'))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
514
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
515 def getPathStyle(self, path, selected, style=""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
516 """returns a string with the given style + 'sel' if path == selected."""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
517
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
518 if path == selected:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
519 return style + 'sel'
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
520 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
521 return style
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
522
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
523
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
524 def getLabel(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
525 """returns a label for this object"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
526 return self.title
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
527
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
528 def getBreadcrumbs(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
529 """return list of breadcrumbs from here to the root"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
530 crumbs = []
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
531 # skip direct parent Folder /members/
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
532 parent = self.aq_parent.aq_parent
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
533 # get parents breadcrumbs
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
534 logging.debug("getbreadcrumbs-: title=%s self=%s parent=%s"%(self.title, repr(self), repr(parent)))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
535 if hasattr(parent, 'getBreadcrumbs'):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
536 logging.debug("getbreadcrumbs: recurse to %s"%parent)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
537 crumbs = parent.getBreadcrumbs()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
538
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
539 # try to get acquisition URL from parent
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
540 if hasattr(parent, 'absolute_url'):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
541 baseUrl = "%s/%s/"%(parent.absolute_url(), 'members')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
542 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
543 baseUrl = "/en/staff/members/"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
544
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
545 # add this
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
546 crumbs.append((self.getLabel(), baseUrl+self.getId(), self))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
547
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
548 return crumbs
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
549
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
550
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
551 def changeCurrentWork(self,current_work,key,publish="yes",RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
552 """change current work"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
553
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
554 query="UPDATE personal_www SET current_work =%s WHERE key='%s'"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
555
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
556 self.ZSQLQuery(query%(self.ZSQLQuote(current_work),key))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
557
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
558 query="UPDATE personal_www SET current_work_p =%s WHERE key='%s'"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
559
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
560 self.ZSQLQuery(query%(self.ZSQLQuote(publish),key))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
561 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
562 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
563 self.redirect(RESPONSE,"edit")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
564
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
565 security.declareProtected('View management screens','changeResearch')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
566 def changeResearch(self,noredirect=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
567 """change the research entries"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
568 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
569 newEntries={}
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
570 key_main=self.REQUEST.form['key_main']
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
571
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
572 mainfieldL=self.REQUEST.form['main_fields'].split(",")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
573 mainfield={}
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
574 for x in mainfieldL:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
575 tmp=x.split('__')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
576 mainfield[tmp[0]]=tmp[1]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
577 for field in self.REQUEST.form.keys():
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
578 splittedField=field.split("__")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
579 if len(splittedField)<3:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
580 pass #kein datenbank eintrag
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
581
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
582 elif splittedField[2]=='new': # store new entries
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
583 if not newEntries.has_key(splittedField[0]):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
584 newEntries[splittedField[0]]={}
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
585
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
586 newEntries[splittedField[0]][splittedField[1]]=self.REQUEST.form[field]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
587
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
588 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
589 query="UPDATE %s "%splittedField[0]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
590 query+="SET %s = '%s' "%(splittedField[1],sql_quote(self.REQUEST.form[field]))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
591 query+="WHERE oid = '%s' "%sql_quote(splittedField[2])
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
592
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
593 self.ZSQLQuery(query)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
594
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
595
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
596 #new entries
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
597 for newEntry in newEntries.keys():
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
598 query="INSERT INTO %s "%newEntry
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
599 keys=['key_main']
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
600 values=["'"+sql_quote(key_main)+"'"]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
601 for key in newEntries[newEntry].keys():
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
602 keys.append(key)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
603 values.append("'"+sql_quote(newEntries[newEntry][key])+"'")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
604
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
605
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
606 keystring=",".join(keys)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
607
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
608 valuestring=",".join(values)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
609
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
610 query+=" (%s) "%keystring
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
611 query+="VALUES (%s)"%valuestring
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
612 if not (newEntries[newEntry][mainfield[newEntry]].lstrip().rstrip()==""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
613 self.ZSQLQuery(query)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
614
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
615 if not noredirect:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
616 self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER'])
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
617
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
618 security.declareProtected('View management screens','editCV')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
619 def editCV(self,cv=None,oid=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
620 """edit Cv"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
621
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
622 if (not oid):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
623 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editCV.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
624 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
625
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
626 query="UPDATE personal_www SET cv =%s WHERE oid='%s'"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
627 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
628 self.ZSQLQuery(query%(self.ZSQLQuote(cv),oid))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
629
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
630 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
631 self.redirect(RESPONSE,"editCV")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
632
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
633
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
634 def getProfile(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
635 """get the profile"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
636 self.REQUEST.RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
637
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
638 founds=self.ZSQLInlineSearchU(_table='personal_www',key=self.getKeyUTF8())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
639 html="""<html><body>%s</body></html>"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
640 if founds.profile and founds.profile != "":
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
641
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
642 return html%founds.profile
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
643 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
644
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
645 return html%self.generateProfileForPerson(founds)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
646
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
647 def editProfile(self,oid=None,RESPONSE=None, kupu=None, preview=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
648 """edit Profile, new entry replaces CD, current work and research interests"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
649
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
650 if (not oid):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
651 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editProfile.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
652 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
653
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
654 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
655
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
656
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
657 if preview:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
658 pass
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
659 #TODO: not supported yet
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
660 #kupu=preview
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
661 # find content of body tags
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
662
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
663 start=kupu.find("<body>")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
664 end=kupu.find("</body>")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
665
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
666 newcontent= kupu[start+6:end]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
667
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
668
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
669
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
670
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
671 if preview:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
672 #TODO: not supported yet
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
673 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
674 self.redirect(RESPONSE,"editProfile")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
675
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
676 #return self.preview(newcontent)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
677
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
678 query="UPDATE personal_www SET profile=%s WHERE oid='%s'"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
679 self.ZSQLQuery(query%(self.ZSQLQuote(newcontent),oid))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
680 logging.error("PROFILE:"+query%(self.ZSQLQuote(newcontent),oid))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
681 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
682 self.redirect(RESPONSE,"editProfile")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
683
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
684
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
685
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
686 def generateProfileForPerson(self,person):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
687 """erzeugt ein automatisches Profil aus den alten Eintraegen CV, Current work, und research interests"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
688
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
689 ret=""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
690 #founds=self.ZSQLInlineSearch(_table='research_interest',key_main=person.getKeyUTF8())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
691 founds=self.ZSQLInlineSearch(_table='research_interest',key_main=person.key)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
692 if founds:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
693 ret="<p class=\"bio_section_header\">Research interests: </p><br/>"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
694 for found in self.sortPriority(founds):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
695 ret+=found.interest+"<br/>"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
696
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
697
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
698 if (person.current_work) and (not person.current_work==""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
699 ret+="<p class=\"bio_section_header\">Current work: </p><br/>"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
700
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
701 ret+=person.current_work+"<br/>"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
702 if (person.cv) and (not person.cv==""):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
703 ret+="<p class=\"bio_section_header\">Curriculum Vitae: </p><br/>"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
704 ret+=self.formatAscii(person.cv)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
705
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
706 return ret
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
707 security.declareProtected('View management screens','editDownloads')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
708 def editDownloads(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
709 """editiere die Downloads von der Webseite"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
710
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
711 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editDownloads.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
712 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
713
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
714 security.declareProtected('View management screens','editAdditionalLinks.zpt')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
715 def editAdditionalLinks(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
716 """editiere die Downloads von der Webseite"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
717
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
718 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editAdditionalLinks.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
719 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
720
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
721
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
722 security.declareProtected('View management screens','editAwards')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
723 def editAwards(self,awards=None,oid=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
724 """edit a awards"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
725
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
726 if (not oid):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
727 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editAwards.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
728 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
729 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
730 query="UPDATE personal_www SET awards =%s WHERE oid='%s'"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
731
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
732 self.ZSQLQuery(query%(self.ZSQLQuote(awards),oid))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
733
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
734
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
735 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
736 self.redirect(RESPONSE,"editAwards")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
737
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
738 security.declareProtected('View management screens','editTalks')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
739 def editTalks(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
740 """edit talks"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
741
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
742 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editTalks.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
743 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
744
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
745 security.declareProtected('View management screens','editTeaching')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
746 def editTeaching(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
747 """edit Teaching"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
748
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
749 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editTeaching.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
750 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
751
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
752 def getDocTypes(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
753 finds = self.ZopeFind(self.metadata.main.meta.bib,obj_metatypes=["OSAS_MetadataMapping__neu"])
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
754
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
755 list= [x[0] for x in finds]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
756 return "\n".join(list)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
757
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
758 security.declareProtected('View management screens','editMainData')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
759 def editMainData(self,REQUEST=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
760 """edit main data"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
761 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
762 argv=REQUEST.form
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
763
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
764 if not argv.has_key('last_name'):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
765 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMainData.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
766 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
767 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
768 self.ZSQLChange(argv,_table="personal_www",_identify="lower(key)=%s"%utf8ify(self.getKey().lower()),USE_FORM="yes")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
769 # aendere auch dien enstsprechen infos in der instance
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
770 self.changeMPIWGStaff(argv['last_name'],argv['first_name']);
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
771
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
772
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
773
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
774 self.reindex_object()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
775
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
776
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
777
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
778 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
779 self.redirect(RESPONSE,"editMainData")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
780
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
781 security.declareProtected('View management screens','newBibliogrpaphy')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
782 def newBibliography(self,_docType=None, _addEntry=None,RESPONSE=None,**argv):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
783
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
784 """add an entry to the bibliography"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
785 if not _docType: #kein docType
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
786 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','newBibliographyEntryDocType.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
787 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
788 elif _docType and not _addEntry: #doctype aber keine daten
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
789 self.REQUEST['_docType']=_docType
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
790 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','newBibliographyEntry.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
791 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
792 else: #doctype und daten
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
793 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
794 newId=self.ZSQLSimpleSearch("select nextval('id_raw')")[0].nextval
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
795 except:#id_raw existiert nich, dann neu erzeugen
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
796
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
797 self.createOrUpdateId_raw()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
798 newId=self.ZSQLSimpleSearch("select nextval('id_raw')")[0].nextval
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
799
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
800 bookId="b%06i" % newId
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
801
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
802 self.ZSQLAdd(argv,_table="bibliography",reference_type=_docType,id=bookId)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
803
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
804 self.ZSQLAdd(_useRequest=False,_table="publications",id_gen_bib=bookId,key_main=self.getDBId(),publish='yes')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
805 self.updatePublicationDB(personId=self.getDBId())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
806
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
807
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
808 if RESPONSE:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
809 self.redirect(RESPONSE,"editPublications")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
810
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
811 return True
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
812
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
813 security.declareProtected('View management screens','editImage')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
814 def editImage(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
815 """edit images"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
816 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editImageStaff.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
817 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
818
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
819 security.declareProtected('View management screens','editBibliography')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
820 def editBibliography(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
821 """edit the bibliography"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
822 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editBibliographyEntry.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
823 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
824
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
825
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
826 security.declareProtected('View management screens','editPublications')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
827 def editPublications(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
828 """edit the bibliographie"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
829
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
830 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editPublications.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
831 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
832
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
833 def changeSortingMode(self,sortingMode,RESPONSE=None,REQUEST=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
834 """change sorting mode"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
835 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
836 self.sortingMode=sortingMode
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
837
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
838 if RESPONSE and REQUEST:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
839 self.redirect(RESPONSE,REQUEST['HTTP_REFERER'])
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
840
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
841 return True
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
842
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
843 def getSortingMode(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
844 """get sorting mode"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
845 mode=getattr(self,'sortingMode','priority')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
846 if mode=="year":
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
847 return "year DESC"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
848 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
849 return mode
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
850
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
851 def integer(self,value):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
852 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
853 return int(value)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
854 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
855 return 0
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
856
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
857 security.declareProtected('View management screens','changePublications')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
858 def changePublications(self,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
859 """change the publication list"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
860 self.changeResearch(noredirect=True)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
861 self.ZCacheable_invalidate()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
862 #self.updatePublicationDB(personId=self.getDBId())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
863 self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER'])
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
864
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
865
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
866
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
867 security.declareProtected('View management screens','addPublications')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
868 def addPublications(self,submit=None,REQUEST=None,noredirect=None,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
869 """add publications"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
870
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
871 #setzte flag ob aufruf aus suchformular
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
872
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
873 if REQUEST.get("QUERY_STRING",None) and (not submit):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
874 self.REQUEST.set('fromSearch','1')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
875 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
876 self.REQUEST.set('fromSearch','0')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
877
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
878 if not submit or (not (submit == "add")):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
879 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addPublications.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
880 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
881
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
882 #new entries
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
883 entries = REQUEST.form.get('addEntries',None)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
884 if not (type(entries) is ListType):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
885 entries=[entries]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
886
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
887
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
888 for bibId in entries:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
889 query="INSERT INTO %s " % "publications"
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
890 query+="(key_main,id_institutsbibliographie,publish) "
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
891 query+="VALUES ('%s','%s','yes')" %(sql_quote(self.getKey()),sql_quote(bibId))
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
892
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
893 #self.ZSQLAdd(_table="publications",id_institutsbibliographie=bibId,id_main=self.getDBId(),publish='yes')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
894 self.ZSQLQuery(query)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
895
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
896 self.updatePublicationDB(personId=self.getKey())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
897
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
898 if not noredirect:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
899
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
900 self.redirect(RESPONSE,"./editPublications")
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
901
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
902 return True
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
903
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
904
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
905 def getDBId(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
906 """get id from the personal database"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
907
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
908 #in der neuen version ist definitions gemaess der key der Datenbank gleich dem key im Object.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
909 # TODO: remove all occurences of getDBId and replaces it by getKey
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
910 return self.getKey()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
911
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
912 # search=self.ZSQLInlineSearch(_table='personal_www',key=self.getKey(),publish_the_data='yes')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
913 # if search:#name existiert und published, dann nimm diesen falls es mehrereeventuell nich publizierte datensaetze gibt.
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
914 # return search[0].id
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
915 # else:#nicht publiziert dann nimm einen davon
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
916 # search2=self.ZSQLInlineSearch(_table='personal_www',username=self.getId())
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
917 # if search2:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
918 # return search2[0].id
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
919 # else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
920 # return None
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
921
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
922
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
923
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
924 formatBiblHelp=bibliography.formatBiblHelp
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
925
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
926 def sortBibliography(self,list,sortingMode=None,max=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
927 if not sortingMode:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
928 sortingMode=self.getSortingMode()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
929
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
930 if sortingMode == "year":
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
931 l= self.sortYear(list)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
932 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
933 l=self.sortPriority(list)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
934
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
935 if max:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
936 return l[0:min(len(l),max)]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
937 else:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
938 return l
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
939
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
940 def sortPriority(self,list):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
941 def sort(x,y):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
942 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
943 xInt=int(x.priority)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
944 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
945 xInt=0
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
946 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
947 yInt=int(y.priority)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
948 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
949 yInt=0
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
950
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
951 return cmp(xInt,yInt)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
952
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
953 if not list:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
954 return []
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
955 tmp=[x for x in list]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
956 tmp.sort(sort)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
957
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
958 return tmp
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
959
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
960 def sortYear(self,list):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
961 #TODO: sort TO APPEAR and TO BE PUBLISHED etc...
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
962
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
963 def sort(x,y):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
964 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
965 xInt=int(x.year)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
966 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
967 xInt=0
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
968 try:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
969 yInt=int(y.year)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
970 except:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
971 yInt=0
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
972
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
973 return cmp(yInt,xInt)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
974
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
975
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
976 tmp=[x for x in list]
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
977
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
978 tmp.sort(sort)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
979 return tmp
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
980
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
981 def deleteField(self,table,oid,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
982 """delete entry"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
983 query="DELETE FROM %s WHERE oid = '%s'"%(table,oid)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
984
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
985 self.ZSQLQuery(query)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
986 self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER'])
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
987
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
988
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
989 def manage_addMPIWGStaffForm(self):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
990 """form for adding the project"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
991 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGStaffForm.zpt')).__of__(self)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
992 return pt()
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
993
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
994 def manage_addMPIWGStaff(self,id,lastName,firstName,RESPONSE=None):
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
995 """add it"""
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
996 newObj=MPIWGStaff(id,lastName,firstName)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
997
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
998 self._setObject(id,newObj)
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
999
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
1000
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
1001 if RESPONSE is not None:
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
1002 self.redirect(RESPONSE,'manage_main')
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
1003
ddf6c1a27a4b new version with main_template and css in product.
casties
parents:
diff changeset
1004