annotate MPIWGStaff_old.py @ 170:485bf377913a

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