Mercurial > hg > MPIWGWeb
annotate MPIWGRoot.py @ 190:9a09156eee7c
added general bibliography for adding to staff page
author | dwinter |
---|---|
date | Tue, 18 Jun 2013 14:12:17 +0200 |
parents | cc5198541af8 |
children | 938add25f81b |
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 | 2 from App.ImageFile import ImageFile |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
3 from Globals import package_home |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
4 import string |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
5 import os |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
6 import logging |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
7 from OFS.Folder import Folder |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
8 import sys |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
9 |
65 | 10 from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder |
2 | 11 |
162 | 12 import MPIWGHelper |
2 | 13 import updatePersonalWWW |
14 import MPIWGStaff | |
162 | 15 from SrvTxtUtils import getInt, unicodify, refreshingImageFileIndexHtml, getDateString |
2 | 16 |
17 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
18 class MPIWGRoot(ZSQLExtendFolder): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
19 """Stammordner fuer den Web-Server""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
20 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
21 _v_harvestCache=None |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
22 meta_type='MPIWGRoot' |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
23 |
2 | 24 manage_options = Folder.manage_options+( |
25 {'label':'Update personal homepages','action':'updatePersonalwww_html'}, | |
26 {'label':'Reindex catalogs','action':'reindexCatalogs'}, | |
27 {'label':'Main config','action':'changeMPIWGRootForm'}, | |
28 {'label':'add e-mails','action':'showNewDBEntries'}, | |
29 #{'label':'update the institutsbibliography','action':'updateInstitutsbiliography'}, | |
30 #{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, | |
31 #{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, | |
32 ) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
33 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
34 # (is this used?) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
35 folders=['MPIWGProject','Folder','ECHO_Navigation'] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
36 # language of this instance |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
37 lang = 'en' |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
38 # types of objects that show up in navigation |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
39 nav_meta_types = ['MPIWGTemplate','MPIWGLink','MPIWGFolder'] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
40 |
2 | 41 # |
42 # templates | |
43 # | |
44 main_template = PageTemplateFile('zpt/www/main_template', globals()) | |
26
8a99ad8713d6
new common template for fragments. new styles for servicebox.
casties
parents:
23
diff
changeset
|
45 common_template = PageTemplateFile('zpt/www/common_template', globals()) |
2 | 46 mpiwg_css = ImageFile('css/mpiwg.css', globals()) |
66
68b3d71eed27
formatting for preprint list. javascript for foldable divs.
casties
parents:
65
diff
changeset
|
47 # make mpiwg_css refreshable for development |
2 | 48 mpiwg_css.index_html = refreshingImageFileIndexHtml |
66
68b3d71eed27
formatting for preprint list. javascript for foldable divs.
casties
parents:
65
diff
changeset
|
49 jquery_js = ImageFile('js/jquery.js', globals()) |
68b3d71eed27
formatting for preprint list. javascript for foldable divs.
casties
parents:
65
diff
changeset
|
50 mpiwg_js = ImageFile('js/mpiwg.js', globals()) |
68b3d71eed27
formatting for preprint list. javascript for foldable divs.
casties
parents:
65
diff
changeset
|
51 # make mpiwg_js refreshable for development |
68b3d71eed27
formatting for preprint list. javascript for foldable divs.
casties
parents:
65
diff
changeset
|
52 mpiwg_js.index_html = refreshingImageFileIndexHtml |
159 | 53 # ZMI |
54 changeMPIWGRootForm = PageTemplateFile('zpt/root/manage_change') | |
55 | |
2 | 56 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
57 |
65 | 58 def __init__(self, id, title): |
59 """init""" | |
60 self.id=id | |
61 self.title=title | |
62 | |
63 | |
72 | 64 # TODO: remove |
65 def replaceNotEmpty(self,format,field): | |
66 """replace not empty""" | |
67 if field and (not field.lstrip()==''): | |
68 return format%field | |
69 #return self.decode(format%field) | |
70 else: | |
71 return "" | |
72 | |
73 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
74 def getLang(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
75 """returns the default language""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
76 return self.lang |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
77 |
65 | 78 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
79 def browserCheck(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
80 """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
|
81 bt = {} |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
82 ua = self.REQUEST.get_header("HTTP_USER_AGENT") |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
83 bt['ua'] = ua |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
84 bt['isIE'] = False |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
85 bt['isN4'] = False |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
86 if string.find(ua, 'MSIE') > -1: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
87 bt['isIE'] = True |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
88 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
89 bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
90 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
91 try: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
92 nav = ua[string.find(ua, '('):] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
93 ie = string.split(nav, "; ")[1] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
94 if string.find(ie, "MSIE") > -1: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
95 bt['versIE'] = string.split(ie, " ")[1] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
96 except: pass |
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 bt['isMac'] = string.find(ua, 'Macintosh') > -1 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
99 bt['isWin'] = string.find(ua, 'Windows') > -1 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
100 bt['isIEWin'] = bt['isIE'] and bt['isWin'] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
101 bt['isIEMac'] = bt['isIE'] and bt['isMac'] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
102 bt['staticHTML'] = False |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
103 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
104 return bt |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
105 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
106 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
107 def isNewCapital(self,text=None,reset=None): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
108 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
109 if text: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
110 text=text.upper() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
111 if reset: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
112 self.REQUEST['capital']="A" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
113 return True |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
114 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
115 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
|
116 self.REQUEST['capital']=text[0] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
117 return True |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
118 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
119 return False |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
120 |
87
77f2478ae971
getDateString method to format dates in English and German.
casties
parents:
84
diff
changeset
|
121 |
77f2478ae971
getDateString method to format dates in English and German.
casties
parents:
84
diff
changeset
|
122 def getDateString(self, **args): |
77f2478ae971
getDateString method to format dates in English and German.
casties
parents:
84
diff
changeset
|
123 """Return a formatted date string.""" |
77f2478ae971
getDateString method to format dates in English and German.
casties
parents:
84
diff
changeset
|
124 return getDateString(**args) |
77f2478ae971
getDateString method to format dates in English and German.
casties
parents:
84
diff
changeset
|
125 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
126 |
10 | 127 def getSubsections(self, here=None): |
128 """return sub-navigation elements i.e. elements below sections""" | |
129 p = here | |
130 if p is None: | |
131 p = self | |
65 | 132 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
133 sec = None |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
134 # 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
|
135 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
|
136 sec = p |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
137 p = p.aq_parent |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
138 |
65 | 139 subsecs = sec.objectItems(spec=self.nav_meta_types) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
140 subsecs = [s for s in subsecs if s[1].title != ""] |
100 | 141 subsecs.sort(key=lambda x:getInt(getattr(x[1], 'weight', '0'))) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
142 return subsecs |
10 | 143 |
144 # compatibility | |
145 subNav = getSubsections | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
146 |
65 | 147 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
148 def getSections(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
149 """returns a list of all sections i.e. top-level MPIWGFolders""" |
126 | 150 items = self.objectValues(spec='MPIWGFolder') |
100 | 151 items.sort(key=lambda x:getInt(getattr(x, 'weight', '0'))) |
13 | 152 return items |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
153 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
154 |
162 | 155 getPathStyle = MPIWGHelper.getPathStyle |
156 | |
157 | |
180 | 158 def getFeatures(self, num=None, reverse=False): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
159 """returns a list of the last num Features""" |
13 | 160 dir = getattr(self, 'features', None) |
161 if dir is None: | |
162 return [] | |
163 | |
75 | 164 items = dir.objectValues(spec='MPIWGFeature') |
180 | 165 items.sort(key=lambda x:int(x.weight), reverse=reverse) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
166 if num is not None: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
167 # take only the last num elements |
13 | 168 items = items[-num:] |
169 return items | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
170 |
65 | 171 |
84 | 172 def getFeatureAuthorMap(self): |
173 """Return a map of authors of features. | |
174 | |
175 Returns a dict with author names and a list of feature numbers. | |
176 """ | |
177 features = self.getFeatures() | |
178 authors = {} | |
179 # build dict of unique authors and features | |
180 fno = 0 | |
181 for f in features: | |
182 author = f.getAuthor() | |
183 fno += 1 | |
184 if author: | |
185 for a in author.split(';'): | |
186 a = a.strip() | |
187 if a in authors: | |
188 authors[a].append(fno) | |
189 else: | |
190 authors[a] = [fno] | |
191 | |
192 return authors | |
193 | |
194 | |
9 | 195 def getDepartments(self): |
196 """returns a list of the Departments""" | |
197 dir = getattr(self, 'departments', None) | |
198 if dir is None: | |
199 return [] | |
200 | |
75 | 201 items = dir.objectValues(spec='MPIWGDepartment') |
14 | 202 items.sort(key=lambda x:int(x.weight)) |
13 | 203 return items |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
204 |
65 | 205 |
94
7aaed5218d55
added staffdb_key to departments. getDepartment also gets by id.
casties
parents:
87
diff
changeset
|
206 def getDepartment(self, id=None, projectNumber=None): |
39 | 207 """returns a Department object""" |
208 dir = getattr(self, 'departments', None) | |
209 if dir is None: | |
210 return None | |
211 | |
94
7aaed5218d55
added staffdb_key to departments. getDepartment also gets by id.
casties
parents:
87
diff
changeset
|
212 if id is not None: |
7aaed5218d55
added staffdb_key to departments. getDepartment also gets by id.
casties
parents:
87
diff
changeset
|
213 return dir.get(id, None) |
7aaed5218d55
added staffdb_key to departments. getDepartment also gets by id.
casties
parents:
87
diff
changeset
|
214 |
39 | 215 if projectNumber is not None: |
216 for dep in dir.objectValues(spec='MPIWGDepartment'): | |
217 if dep.getProjectNumber() == projectNumber: | |
218 return dep | |
219 | |
220 return None | |
221 | |
40 | 222 |
30 | 223 def getProjectFolder(self): |
27 | 224 """returns the MPIWGProjectFolder""" |
225 dir = getattr(self, 'projects', None) | |
226 return dir | |
227 | |
40 | 228 |
229 def getStaffFolder(self): | |
230 """returns the MPIWGStaffFolder""" | |
65 | 231 dir = getattr(self, 'members', None) # TODO: fix the test |
40 | 232 return dir |
233 | |
234 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
235 def getMPIWGRoot(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
236 """returns the MPIWG root""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
237 return self |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
238 |
40 | 239 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
240 def MPIWGrootURL(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
241 """returns the URL to the root""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
242 return self.absolute_url() |
40 | 243 |
41
cacba38c268c
added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents:
40
diff
changeset
|
244 |
cacba38c268c
added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents:
40
diff
changeset
|
245 # TODO: make obsolete |
cacba38c268c
added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents:
40
diff
changeset
|
246 def decode(self, s): |
cacba38c268c
added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents:
40
diff
changeset
|
247 """unicodify""" |
cacba38c268c
added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents:
40
diff
changeset
|
248 return unicodify(s) |
cacba38c268c
added decode() back to MPIWGRoot, templates using it should be fixed...
casties
parents:
40
diff
changeset
|
249 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
250 |
39 | 251 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
|
252 """change""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
253 self.title=title |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
254 self.connection_id=connection_id |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
255 #self.disciplineList=disciplineList |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
256 #self.themesList=themesList |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
257 self.coneServiceURL=coneServiceURL |
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 if lang is not None: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
260 self.lang = lang |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
261 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
262 self.autocommit = (autocommit == "on") |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
263 if RESPONSE is not None: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
264 RESPONSE.redirect('manage_main') |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
265 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
266 |
189
cc5198541af8
erzeugen neuer eintr?ge auf der homepage mittels updatexml
dwinter
parents:
188
diff
changeset
|
267 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
268 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
269 def showNewDBEntries(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
270 """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
|
271 qstr="select * from personal_www where web_object_created='no' and not key=''" |
189
cc5198541af8
erzeugen neuer eintr?ge auf der homepage mittels updatexml
dwinter
parents:
188
diff
changeset
|
272 res=self.members.executeZSQL(qstr) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
273 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
274 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
|
275 return pt(newEntries=res) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
276 |
189
cc5198541af8
erzeugen neuer eintr?ge auf der homepage mittels updatexml
dwinter
parents:
188
diff
changeset
|
277 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
278 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
279 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
280 def generateNewPersonEntry(self,data): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
281 """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
|
282 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
283 #memberFolder=getattr(self,'members') |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
284 #create the object |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
285 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
286 # try: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
287 # 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
|
288 # memberFolder._setObject(urllib.quote(data['key']),newObj) |
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 # 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
|
291 # |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
292 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
293 #create the new entry in the database |
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 |
189
cc5198541af8
erzeugen neuer eintr?ge auf der homepage mittels updatexml
dwinter
parents:
188
diff
changeset
|
296 result,msg=self.members.createNewDBEntry(data['publish_the_data'],data['key'],data['last_name'], |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
297 data['first_name'],data['titles_new'],data['status'],"", |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
298 "",data['date_from'],data['date_to'], |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
299 data['department'],'',data['funded_by'], |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
300 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
|
301 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
302 return result,msg |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
303 |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
304 def updatePersonEntry(self,newdata,ignoreEntries=None): |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
305 """update an person entry from newdata. but ignore all fields in ignore Entries""" |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
306 data = newdata.copy() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
307 if ignoreEntries is None: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
308 ignoreEntries = [] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
309 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
310 #ignoreEntries.append('current_work') # TODO:updatecurrent work |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
311 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
|
312 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
313 if data['date_to']=="": # wenn date_to leer |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
314 data['date_to']=None |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
315 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
316 if data['date_from']=="": # wenn date_fromleer |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
317 data['date_from']=None |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
318 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
319 #eintragen |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
320 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
321 columns=data.keys() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
322 for x in ignoreEntries: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
323 logging.debug("updatePersonEntry: ignoring %s"%x) |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
324 if x in data: |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
325 del data[x] |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
326 |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
327 member = self.getStaffFolder().getMember(key = data['key']) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
328 if member is None: |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
329 logging.error("updatePersonEntry: member (key=%s) not found!"%repr(data['key'])) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
330 return |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
331 |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
332 # TODO: change date handling |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
333 self.getStaffFolder().executeZSQL("SET DATESTYLE TO 'German'") |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
334 member.changeData(data) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
335 |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
336 # msg="" |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
337 # insert=[] |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
338 # for key in columns: |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
339 # if data[key]=="date_none": # date_none eintrag wird zu null uebersetzt |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
340 # insert.append('%s=null'%key) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
341 # else: |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
342 # insert.append(""" "%s"=%s"""%(key,self.ZSQLQuote(data[key]))) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
343 # |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
344 # insertStr=",".join(insert) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
345 # queryStr="update personal_www SET %s where key='%s'"%(insertStr,data['key']) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
346 # self.ZSQLQuery("SET DATESTYLE TO 'German'") |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
347 # self.ZSQLQuery(queryStr) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
348 # |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
349 # return True,msg |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
350 |
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 def updatePersonalwww_doIt(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
353 """do the update""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
354 args=self.REQUEST.form |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
355 resultSet=self.REQUEST.SESSION['personal_www']['resultSet'] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
356 news=self.REQUEST.SESSION['personal_www']['news'] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
357 conflicts=self.REQUEST.SESSION['personal_www']['conflicts'] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
358 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
|
359 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
360 ret="<html><body>" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
361 # generate the new entry |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
362 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
363 if news and (len(news)>0): |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
364 ret+="<h2>Added</h2>" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
365 ret+="<ul>" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
366 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
367 for new in news: |
186 | 368 if args.has_key(new.encode('utf-8')): # entry was selected |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
369 result,msg=self.generateNewPersonEntry(resultSet[new]) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
370 if not result: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
371 logging.error("Error (generateNewPersonEntry) %s"%msg) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
372 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
|
373 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
374 ret+="<li>OK: %s"%(new.encode('utf-8')) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
375 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
376 if news and (len(news)>0): |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
377 ret+="<p>New entries will be visible on the webpage when an email address has been assigned.</p>" |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
378 ret+="</ul>" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
379 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
380 # update |
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 if len(conflicts.keys())>0: |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
383 ret+="<h2>Accepted changes to user entries</h2>" |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
384 ret+="<p>Change Filemaker-db when necessary.</p>" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
385 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
386 # konflicte |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
387 for conflict in conflicts.keys(): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
388 ignoreEntries=[] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
389 displayIgnored=[] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
390 for cf in conflicts[conflict]: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
391 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
|
392 ignoreEntries.append(cf[0]) #so ignore field cf[0] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
393 displayIgnored.append(cf) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
394 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
395 if len(displayIgnored)>0: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
396 ret+="<h3>%s</h3>"%conflict.encode('utf-8') |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
397 ret+="<table border='1'>" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
398 for iE in displayIgnored: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
399 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
|
400 ret+="</table>" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
401 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
402 self.updatePersonEntry(resultSet[conflict],ignoreEntries=ignoreEntries) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
403 |
162 | 404 # rest |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
405 cl=list(conflicts.keys()) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
406 |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
407 if len(resultSet.keys()) > 0: |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
408 ret += "<h2>Updating user entries</h2>" |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
409 ret += "<ul>" |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
410 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
411 for key in resultSet.keys(): |
162 | 412 if key not in cl: |
413 self.updatePersonEntry(resultSet[key]) | |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
414 ret+="<li>%s</li>"%(key.encode('utf-8')) |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
415 |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
416 if len(resultSet.keys()) > 0: |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
417 ret += "</ul>" |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
418 |
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
419 ret += "<p>Done.</p>" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
420 return ret+"</body></html>" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
421 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
422 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
423 def updatePersonalwww_html(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
424 """update form for the homepages web form""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
425 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
|
426 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
427 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
428 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
429 def updatePersonalwww(self,uploadfile): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
430 """update personalwww |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
431 @param uploadfile: file handle auf das file |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
432 """ |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
433 dsn=self.getConnectionObj().connection_string |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
434 #dsn="dbname=personalwww" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
435 resultSet=updatePersonalWWW.importFMPXML(uploadfile) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
436 news,conflicts=updatePersonalWWW.checkImport(dsn, resultSet) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
437 |
188
16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
casties
parents:
186
diff
changeset
|
438 self.REQUEST.SESSION['personal_www'] = {'resultSet': resultSet, 'news': news, 'conflicts': conflicts} |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
439 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
440 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
|
441 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
442 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
443 |
55 | 444 def getAllProjectPublications(self): |
445 """get all publications""" | |
446 fw=file("/tmp/allProjectPublications","w") | |
447 projects =self.projects.getProjectsAsList(None,active=0,archived=0) | |
448 | |
449 for project in projects: | |
450 logging.debug(project) | |
451 if hasattr(project,'publicationList'): | |
452 try: | |
453 x =project.publicationList.bibliolist.data | |
454 | |
455 except: | |
456 logging.error("Can't do: %s"%project.absolute_url()) | |
457 continue | |
458 | |
459 id=project.getId() | |
460 for l in x.split("\n"): | |
461 fw.write("%s,%s\n"%(id,l)) | |
462 fw.flush() | |
463 | |
464 fw.close() | |
127 | 465 |
128 | 466 def getBookLinkFromID(self,ident): |
467 """holt die url auf eine buchseite, bekommt identifier MPIWG-Book:XXXX""" | |
468 | |
469 splitted = ident.split(":") | |
470 if len(splitted)!=2: | |
471 logging.debug("getBookLinkFromID: %s not a valid book id, should be MPIWG-Book:XXXX"%ident) | |
185 | 472 return "" |
128 | 473 |
474 books = getattr(self,'books',None) | |
475 if books is None: | |
476 logging.debug("getBookLinkFromID: cannot find books page folder") | |
185 | 477 return "" |
128 | 478 |
479 | |
480 bookobj = getattr(books,splitted[1],None) | |
481 | |
482 if bookobj is None: | |
483 logging.debug("getBookLinkFromID: %s not a valid book id"%ident) | |
185 | 484 return "" |
128 | 485 |
127 | 486 |
128 | 487 return "books/"+splitted[1] |
57 | 488 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
489 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
490 def manage_addMPIWGRootForm(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
491 """form for adding the root""" |
159 | 492 pt=PageTemplateFile('zpt/root/addMPIWGRootForm', globals()).__of__(self) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
493 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
494 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
495 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
|
496 """add a root folder""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
497 newObj=MPIWGRoot(id,title) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
498 self._setObject(id,newObj) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
499 ob=getattr(self,id) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
500 setattr(ob,'connection_id',connection_id) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
501 if RESPONSE is not None: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
502 RESPONSE.redirect('manage_main') |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
503 |