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