annotate MPIWGRoot.py @ 66:68b3d71eed27

formatting for preprint list. javascript for foldable divs.
author casties
date Fri, 03 May 2013 22:10:10 +0200
parents 63184d71c014
children ad2e970ffd9f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
2 from App.ImageFile import ImageFile
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
3 from OFS.Image import Image
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
4 from Globals import package_home
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
5 import string
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
6 import os
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
7 import logging
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
8 from OFS.Folder import Folder
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
9 from AccessControl import ClassSecurityInfo
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
10 import sys
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
11
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
12 from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
13
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
14 from MPIWGHelper import *
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
15 import updatePersonalWWW
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
16 import MPIWGStaff
35
38cbbeaf266b more work on projects.
casties
parents: 33
diff changeset
17 from SrvTxtUtils import getInt, getAt, utf8ify, refreshingImageFileIndexHtml
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
18
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
19
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
20 class MPIWGRoot(ZSQLExtendFolder):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
21 """Stammordner fuer den Web-Server"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
22
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
23 _v_harvestCache=None
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
24 meta_type='MPIWGRoot'
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
25
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
26 manage_options = Folder.manage_options+(
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
27 {'label':'Update personal homepages','action':'updatePersonalwww_html'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
28 {'label':'Reindex catalogs','action':'reindexCatalogs'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
29 {'label':'Main config','action':'changeMPIWGRootForm'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
30 {'label':'add e-mails','action':'showNewDBEntries'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
31 #{'label':'update the institutsbibliography','action':'updateInstitutsbiliography'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
32 #{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
33 #{'label':'Store Historical Persons','action':'storeHistoricalPersons'},
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
34 )
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
35
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
36 # (is this used?)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
37 folders=['MPIWGProject','Folder','ECHO_Navigation']
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
38 # language of this instance
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
39 lang = 'en'
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
40 # types of objects that show up in navigation
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
41 nav_meta_types = ['MPIWGTemplate','MPIWGLink','MPIWGFolder']
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
42
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
43 #
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
44 # templates
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
45 #
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
46 main_template = PageTemplateFile('zpt/www/main_template', globals())
26
8a99ad8713d6 new common template for fragments. new styles for servicebox.
casties
parents: 23
diff changeset
47 common_template = PageTemplateFile('zpt/www/common_template', globals())
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
48 mpiwg_css = ImageFile('css/mpiwg.css', globals())
66
68b3d71eed27 formatting for preprint list. javascript for foldable divs.
casties
parents: 65
diff changeset
49 # make mpiwg_css refreshable for development
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
50 mpiwg_css.index_html = refreshingImageFileIndexHtml
66
68b3d71eed27 formatting for preprint list. javascript for foldable divs.
casties
parents: 65
diff changeset
51 jquery_js = ImageFile('js/jquery.js', globals())
68b3d71eed27 formatting for preprint list. javascript for foldable divs.
casties
parents: 65
diff changeset
52 mpiwg_js = ImageFile('js/mpiwg.js', globals())
68b3d71eed27 formatting for preprint list. javascript for foldable divs.
casties
parents: 65
diff changeset
53 # make mpiwg_js refreshable for development
68b3d71eed27 formatting for preprint list. javascript for foldable divs.
casties
parents: 65
diff changeset
54 mpiwg_js.index_html = refreshingImageFileIndexHtml
2
ddf6c1a27a4b new version with main_template and css in product.
casties
parents: 1
diff changeset
55
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
56
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
57 def __init__(self, id, title):
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
58 """init"""
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
59 self.id=id
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
60 self.title=title
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
61
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
62
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
63 def getLang(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
64 """returns the default language"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
65 return self.lang
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
66
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
67
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
68 def browserCheck(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
69 """check the browsers request to find out the browser type"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
70 bt = {}
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
71 ua = self.REQUEST.get_header("HTTP_USER_AGENT")
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
72 bt['ua'] = ua
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
73 bt['isIE'] = False
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
74 bt['isN4'] = False
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
75 if string.find(ua, 'MSIE') > -1:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
76 bt['isIE'] = True
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
77 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
78 bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
79
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
80 try:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
81 nav = ua[string.find(ua, '('):]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
82 ie = string.split(nav, "; ")[1]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
83 if string.find(ie, "MSIE") > -1:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
84 bt['versIE'] = string.split(ie, " ")[1]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
85 except: pass
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
86
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
87 bt['isMac'] = string.find(ua, 'Macintosh') > -1
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
88 bt['isWin'] = string.find(ua, 'Windows') > -1
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
89 bt['isIEWin'] = bt['isIE'] and bt['isWin']
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
90 bt['isIEMac'] = bt['isIE'] and bt['isMac']
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
91 bt['staticHTML'] = False
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
92
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
93 return bt
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
94
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
95
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
96 def isNewCapital(self,text=None,reset=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
97
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
98 if text:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
99 text=text.upper()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
100 if reset:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
101 self.REQUEST['capital']="A"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
102 return True
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
103 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
104 if len(text)>0 and not (text[0]==self.REQUEST['capital']):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
105 self.REQUEST['capital']=text[0]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
106 return True
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
107 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
108 return False
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
109
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
110
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
111 def getSubsections(self, here=None):
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
112 """return sub-navigation elements i.e. elements below sections"""
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
113 p = here
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
114 if p is None:
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
115 p = self
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
116
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
117 sec = None
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
118 # descend parents to the root (and remember the last id)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
119 while p is not None and p.meta_type != 'MPIWGRoot':
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
120 sec = p
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
121 p = p.aq_parent
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
122
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
123 subsecs = sec.objectItems(spec=self.nav_meta_types)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
124 subsecs = [s for s in subsecs if s[1].title != ""]
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
125 subsecs.sort(key=lambda x:int(getattr(x[1],'weight','0')))
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
126 return subsecs
10
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
127
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
128 # compatibility
c711fe75d0ac order by weight form for MPIWGFolder. more cleanup.
casties
parents: 9
diff changeset
129 subNav = getSubsections
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
130
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
131
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
132 def getSections(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
133 """returns a list of all sections i.e. top-level MPIWGFolders"""
13
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
134 items = self.objectValues(spec='MPIWGFolder')[:]
14
69d221c3e010 fixed sorting bug.
casties
parents: 13
diff changeset
135 items.sort(key=lambda x:int(x.weight))
13
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
136 return items
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
137
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
138
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
139 def getPathStyle(self, path, selected, style=""):
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
140 """returns a string with the given style + 'sel' if path == selected."""
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
141 if path == selected:
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
142 return style + 'sel'
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
143 else:
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
144 return style
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
145
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
146
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
147 def getFeatures(self, num=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
148 """returns a list of the last num Features"""
13
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
149 dir = getattr(self, 'features', None)
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
150 if dir is None:
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
151 return []
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
152
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
153 items = dir.objectValues(spec='MPIWGFeature')[:]
14
69d221c3e010 fixed sorting bug.
casties
parents: 13
diff changeset
154 items.sort(key=lambda x:int(x.weight))
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
155 if num is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
156 # take only the last num elements
13
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
157 items = items[-num:]
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
158 return items
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
159
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
160
9
5db416602e85 new MPIWGDepartment class.
casties
parents: 2
diff changeset
161 def getDepartments(self):
5db416602e85 new MPIWGDepartment class.
casties
parents: 2
diff changeset
162 """returns a list of the Departments"""
5db416602e85 new MPIWGDepartment class.
casties
parents: 2
diff changeset
163 dir = getattr(self, 'departments', None)
5db416602e85 new MPIWGDepartment class.
casties
parents: 2
diff changeset
164 if dir is None:
5db416602e85 new MPIWGDepartment class.
casties
parents: 2
diff changeset
165 return []
5db416602e85 new MPIWGDepartment class.
casties
parents: 2
diff changeset
166
13
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
167 items = dir.objectValues(spec='MPIWGDepartment')[:]
14
69d221c3e010 fixed sorting bug.
casties
parents: 13
diff changeset
168 items.sort(key=lambda x:int(x.weight))
13
325e7c338815 research websites page. better department editing.
casties
parents: 10
diff changeset
169 return items
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
170
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
171
39
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
172 def getDepartment(self, projectNumber=None):
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
173 """returns a Department object"""
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
174 dir = getattr(self, 'departments', None)
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
175 if dir is None:
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
176 return None
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
177
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
178 if projectNumber is not None:
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
179 for dep in dir.objectValues(spec='MPIWGDepartment'):
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
180 if dep.getProjectNumber() == projectNumber:
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
181 return dep
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
182
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
183 return None
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
184
40
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
185
30
aa4ab114c28a more work on projects.
casties
parents: 27
diff changeset
186 def getProjectFolder(self):
27
9a75eb1b31b3 more work on projects.
casties
parents: 26
diff changeset
187 """returns the MPIWGProjectFolder"""
9a75eb1b31b3 more work on projects.
casties
parents: 26
diff changeset
188 dir = getattr(self, 'projects', None)
9a75eb1b31b3 more work on projects.
casties
parents: 26
diff changeset
189 return dir
9a75eb1b31b3 more work on projects.
casties
parents: 26
diff changeset
190
40
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
191
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
192 def getStaffFolder(self):
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
193 """returns the MPIWGStaffFolder"""
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
194 dir = getattr(self, 'members', None) # TODO: fix the test
40
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
195 return dir
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
196
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
197
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
198 def getMPIWGRoot(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
199 """returns the MPIWG root"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
200 return self
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
201
40
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
202
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
203 def MPIWGrootURL(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
204 """returns the URL to the root"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
205 return self.absolute_url()
40
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
206
41
cacba38c268c added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents: 40
diff changeset
207
cacba38c268c added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents: 40
diff changeset
208 # TODO: make obsolete
cacba38c268c added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents: 40
diff changeset
209 def decode(self, s):
cacba38c268c added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents: 40
diff changeset
210 """unicodify"""
cacba38c268c added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents: 40
diff changeset
211 return unicodify(s)
cacba38c268c added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents: 40
diff changeset
212
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
213
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
214 def changeMPIWGRootForm(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
215 """edit"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
216 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeMPIWGRootForm')).__of__(self)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
217 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
218
39
bbad6a092861 more work on projects.
casties
parents: 35
diff changeset
219 def changeMPIWGRoot(self,title,connection_id,coneServiceURL,lang=None,autocommit=None,RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
220 """change"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
221 self.title=title
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
222 self.connection_id=connection_id
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
223 #self.disciplineList=disciplineList
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
224 #self.themesList=themesList
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
225 self.coneServiceURL=coneServiceURL
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
226
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
227 if lang is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
228 self.lang = lang
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
229
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
230 self.autocommit = (autocommit == "on")
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
231 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
232 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
233
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
234
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
235 # TODO: is this used?
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
236 def updatePublicationDB(self,personId=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
237 """updates the publication db, i.e. copy year and type into the main table"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
238
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
239 if personId:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
240 founds = self.ZSQLInlineSearch(_table="publications",key_main=personId)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
241 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
242 founds = self.ZSQLInlineSearch(_table="publications")
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
243
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
244 for found in founds:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
245
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
246 if found.id_institutsbibliographie and (not found.id_institutsbibliographie =="") and (not found.id_institutsbibliographie =="0"):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
247
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
248 entries = self.ZSQLInlineSearch(_table="institutsbiblio",id=found.id_institutsbibliographie)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
249 for entry in entries:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
250 self.ZSQLChange(_table='publications',_identify='oid=%s' % found.oid,year=entry.year,referencetype=entry.reference_type)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
251
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
252 if found.id_gen_bib and (not found.id_gen_bib ==""):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
253 entries = self.ZSQLInlineSearch(_table="bibliography",id=found.id_gen_bib)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
254 for entry in entries:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
255 self.ZSQLChange(_table='publications',_identify='oid=%s' % found.oid,year=entry.year,referencetype=entry.reference_type)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
256
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
257 return True
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
258
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
259 def showNewDBEntries(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
260 """zeige neue Eintraege in der Datenbank ohne e-mail adressen bzw. fuer die noch kein Object angelegt wurde"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
261 qstr="select * from personal_www where web_object_created='no' and not key=''"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
262 res=self.ZSQLQuery(qstr)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
263
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
264 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','showNewDBEntries.zpt')).__of__(self)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
265 return pt(newEntries=res)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
266
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
267 def createNewStaffObjects(self,RESPONSE):
65
63184d71c014 lots of cleaning up.
casties
parents: 60
diff changeset
268 """create new staff object"""
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
269 memberFolder=getattr(self,'members')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
270 args=self.REQUEST.form
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
271 arg_k=args.keys()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
272 arg_k.remove("submit")
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
273 ret=""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
274 for key in arg_k:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
275 k=self.urlUnQuote(key)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
276
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
277 qstr="select * from personal_www where key=%s"%self.ZSQLQuote(k)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
278 res=self.ZSQLQuery(qstr)[0]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
279 if args[key]!="": #email-adresse wurde eingetragen
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
280 #create the object
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
281 e_mail=args[key]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
282 try:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
283 newObj=MPIWGStaff.MPIWGStaff(e_mail,res.last_name,res.first_name,k)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
284 memberFolder._setObject(e_mail,newObj)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
285 obj=getattr(memberFolder,e_mail)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
286 obj.reindex_object()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
287 ret+="Created %s \n"%e_mail
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
288 created=True
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
289 except:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
290 msg="Cannot create new user %s (%s %s)"%(e_mail,sys.exc_info()[0],sys.exc_info()[1])
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
291 logging.error(msg)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
292 ret+=msg+"\n"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
293 created=False
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
294
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
295 if created:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
296 qstr="update personal_www set web_object_created='yes',e_mail='%s@mpiwg-berlin.mpg.de' where key=%s"%(e_mail,self.ZSQLQuote(k))
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
297 self.ZSQLQuery(qstr)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
298
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
299 return ret
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
300
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
301
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
302 def generateNewPersonEntry(self,data):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
303 """generate a new person entry for data, neue personen werden zunaechst nur in der datenbank angelegt """
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
304
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
305 #memberFolder=getattr(self,'members')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
306 #create the object
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
307
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
308 # try:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
309 # newObj=MPIWGStaff.MPIWGStaff(urllib.quote(data['key']),data['last_name'].encode('utf-8'),data['first_name'].encode('utf-8'))
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
310 # memberFolder._setObject(urllib.quote(data['key']),newObj)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
311 # except:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
312 # return False, "Cannot create new user %s (%s %s)"%(data['key'],sys.exc_info()[0],sys.exc_info()[1])
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
313 #
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
314
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
315 #create the new entry in the database
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
316
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
317
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
318 result,msg=MPIWGStaff.createNewDBEntry(self,data['publish_the_data'],data['key'],data['last_name'],
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
319 data['first_name'],data['titles_new'],data['status'],"",
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
320 "",data['date_from'],data['date_to'],
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
321 data['department'],'',data['funded_by'],
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
322 data['e_mail2'],data['current_work'],"yes",data['date_stay_at_mpiwg'],data['group'],"no",data['current_work'])
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
323
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
324 return result,msg
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
325
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
326 def updatePersonEntry(self,data,ignoreEntries=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
327 """update an person entry from data. but ignore all fields in ignore Entries"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
328 if ignoreEntries is None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
329 ignoreEntries = []
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
330
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
331 #ignoreEntries.append('current_work') # TODO:updatecurrent work
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
332 logging.debug("updatePersonEntry: data=%s ignoreEntries=%s"%(repr(data),repr(ignoreEntries)))
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
333
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
334 if data['date_to']=="": # wenn date_to leer
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
335 data['date_to']="date_none"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
336
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
337 if data['date_from']=="": # wenn date_fromleer
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
338 data['date_from']="date_none"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
339 msg=""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
340
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
341
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
342 #eintragen
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
343
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
344 columns=data.keys()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
345 for x in ignoreEntries:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
346 logging.debug("updatePersonEntry: ignoring %s"%x)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
347 try: #falls in ignore entries felder sind, die nicht in columns sind, fange den fehler ab
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
348 columns.remove(x)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
349 except:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
350 pass
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
351
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
352
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
353 insert=[]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
354 for key in columns:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
355 if data[key]=="date_none": # date_none eintrag wird zu null uebersetzt
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
356 insert.append('%s=null'%key)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
357 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
358 insert.append(""" "%s"=%s"""%(key,self.ZSQLQuote(data[key])))
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
359
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
360 insertStr=",".join(insert)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
361 queryStr="update personal_www SET %s where key='%s'"%(insertStr,data['key'])
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
362 self.ZSQLQuery("SET DATESTYLE TO 'German'")
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
363 self.ZSQLQuery(queryStr)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
364
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
365 #currentwork
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
366 #if not (txt==""):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
367 # queryStr="INSERT INTO current_work (id_main,current,publish) VALUES ('%s','%s','%s')"%(id,txt,txt_p)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
368 #
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
369 # self.ZSQLQuery(queryStr)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
370
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
371 return True,msg
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
372
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
373
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
374 def updatePersonalwww_doIt(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
375 """do the update"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
376 args=self.REQUEST.form
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
377 resultSet=self.REQUEST.SESSION['personal_www']['resultSet']
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
378 news=self.REQUEST.SESSION['personal_www']['news']
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
379 conflicts=self.REQUEST.SESSION['personal_www']['conflicts']
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
380 logging.debug("updatePersonalwww_doIt: args=%s\n resultSet=%s\n news=%s\n conflicts=%s"%(args,resultSet,news,conflicts))
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
381
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
382 ret="<html><body>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
383 # generate the new entry
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
384
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
385 if news and (len(news)>0):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
386 ret+="<h2>Hinzugef&uuml;gt</h2>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
387 ret+="<p>Neueintr&auml;ge erscheinen erst auf der Homepage, wenn ihnen eine e-mail Adresse zugeordnet wurde.</p>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
388 ret+="<ul>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
389
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
390 for new in news:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
391 if args.has_key(self.urlQuote(new.encode('utf-8'))): # entry was selected
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
392 result,msg=self.generateNewPersonEntry(resultSet[new])
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
393 if not result:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
394 logging.error("Error (generateNewPersonEntry) %s"%msg)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
395 ret+="<li>ERROR: %s %s"%(new.encode('utf-8'),msg)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
396 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
397 ret+="<li>OK: %s"%(new.encode('utf-8'))
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
398
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
399 if news and (len(news)>0):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
400 ret+="<p>Neueintr&auml;ge erscheinen erst auf der Homepage, wenn ihnen eine e-mail Adresse zugeordnet wurde.</p>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
401 ret+="</ul>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
402
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
403 # update
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
404
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
405 if len(conflicts.keys())>0:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
406 ret+="<h2>&Auml;nderung des Benutzers &uuml;bernehmen</h2>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
407 ret+="<p>Wenn n&ouml;tig in Filemaker-db &auml;ndern:</p>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
408
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
409 # konflicte
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
410 for conflict in conflicts.keys():
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
411 ignoreEntries=[]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
412 displayIgnored=[]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
413 for cf in conflicts[conflict]:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
414 if args[conflict.encode('utf-8')+'_'+cf[0]]=="stored": #use the stored one
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
415 ignoreEntries.append(cf[0]) #so ignore field cf[0]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
416 displayIgnored.append(cf)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
417
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
418 if len(displayIgnored)>0:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
419 ret+="<h3>%s</h3>"%conflict.encode('utf-8')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
420 ret+="<table border='1'>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
421 for iE in displayIgnored:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
422 ret+="<tr><td>%s</td><td>%s</td><td>%s</td>"%(iE[0].encode('utf-8'),iE[1].encode('utf-8'),iE[2].encode('utf-8'))
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
423 ret+="</table>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
424
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
425 self.updatePersonEntry(resultSet[conflict],ignoreEntries=ignoreEntries)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
426
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
427 # rest
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
428 cl=list(conflicts.keys())
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
429
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
430 for key in resultSet.keys():
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
431 if key not in cl:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
432 self.updatePersonEntry(resultSet[key])
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
433 return ret+"</body></html>"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
434
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
435
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
436 def updatePersonalwww_html(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
437 """update form for the homepages web form"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
438 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','updatePersonalwww.zpt')).__of__(self)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
439 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
440
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
441
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
442 def updatePersonalwww(self,uploadfile):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
443 """update personalwww
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
444 @param uploadfile: file handle auf das file
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
445 """
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
446 dsn=self.getConnectionObj().connection_string
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
447 #dsn="dbname=personalwww"
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
448 resultSet=updatePersonalWWW.importFMPXML(uploadfile)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
449 news,conflicts=updatePersonalWWW.checkImport(dsn, resultSet)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
450
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
451 self.REQUEST.SESSION['personal_www']={}
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
452 self.REQUEST.SESSION['personal_www']['resultSet']=resultSet
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
453 self.REQUEST.SESSION['personal_www']['news']=news
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
454 self.REQUEST.SESSION['personal_www']['conflicts']=conflicts
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
455
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
456 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','updatePersonalwww_check.zpt')).__of__(self)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
457 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
458
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
459
55
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
460 def getAllProjectPublications(self):
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
461 """get all publications"""
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
462 fw=file("/tmp/allProjectPublications","w")
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
463 projects =self.projects.getProjectsAsList(None,active=0,archived=0)
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
464
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
465 for project in projects:
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
466 logging.debug(project)
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
467 if hasattr(project,'publicationList'):
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
468 try:
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
469 x =project.publicationList.bibliolist.data
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
470
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
471 except:
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
472 logging.error("Can't do: %s"%project.absolute_url())
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
473 continue
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
474
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
475 id=project.getId()
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
476 for l in x.split("\n"):
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
477 fw.write("%s,%s\n"%(id,l))
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
478 fw.flush()
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
479
12cb73494367 bibliographie funktionen
dwinter
parents: 54
diff changeset
480 fw.close()
57
84879a3f91a6 getLastArrivals
dwinter
parents: 55
diff changeset
481
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
482
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
483 def manage_addMPIWGRootForm(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
484 """form for adding the root"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
485 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGRootForm.zpt')).__of__(self)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
486 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
487
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
488 def manage_addMPIWGRoot(self,id,title,connection_id="",RESPONSE=None):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
489 """add a root folder"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
490 newObj=MPIWGRoot(id,title)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
491 self._setObject(id,newObj)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
492 ob=getattr(self,id)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
493 setattr(ob,'connection_id',connection_id)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
494 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
495 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
496