Mercurial > hg > MPIWGWeb
annotate MPIWGProjects.py @ 80:b1893c4c9d2c
more display of project pages.
author | casties |
---|---|
date | Wed, 08 May 2013 19:59:25 +0200 |
parents | 7f26c8e6c8e9 |
children | 975a8d88e315 |
rev | line source |
---|---|
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1 """This contains the class MPIWG Projects |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
2 for organizing and maintaining the different project pages |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
3 |
39 | 4 $author dwinter 26.06.2008 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
5 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
6 """ |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
7 from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
8 from OFS.Image import Image |
22 | 9 from App.ImageFile import ImageFile |
10 from OFS.SimpleItem import SimpleItem | |
11 from OFS.Folder import Folder | |
12 from AccessControl import ClassSecurityInfo | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
13 from Globals import package_home |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
14 import urllib |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
15 import re |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
16 import os |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
17 import email |
22 | 18 import sys |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
19 import logging |
22 | 20 import time |
80 | 21 import unicodedata |
22 | 22 |
49 | 23 import xml.etree.ElementTree as ET |
24 | |
65 | 25 from SrvTxtUtils import getInt, unicodify, utf8ify, serialize, refreshingImageFileIndexHtml, shortenString |
33 | 26 from Products.ZDBInterface.ZDBInterfaceFolder import ZDBInterfaceFolder |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
27 |
80 | 28 import xmlhelper # Methoden zur Verwaltung der projekt xml |
27 | 29 from HashTree import HashTree |
80 | 30 import MPIWGHelper |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
31 |
39 | 32 # TODO: better names for the fields |
35 | 33 fieldLabels = {'WEB_title':'WEB_Title', |
33 | 34 'xdata_01':'Responsible Scientists', |
35 'xdata_02':'Department', | |
36 'xdata_03':'Historical Persons', | |
37 'xdata_04':'Time period', | |
38 'xdata_05':'Sorting number', | |
39 'xdata_06':'Keywords', | |
40 'xdata_07':'Short title', | |
41 'xdata_08':'Other involved scholars' , | |
42 'xdata_09':'Disciplines', | |
43 'xdata_10':'Themes', | |
44 'xdata_11':'Object Digitallibrary', | |
45 'xdata_12':'Cooperation partners', | |
46 'xdata_13':'Funding institutions', | |
47 'WEB_project_header':'WEB_project_header', | |
48 'WEB_project_description':'WEB_project_description', | |
49 'WEB_related_pub':'WEB_related_pub'} | |
50 | |
39 | 51 definedFields = fieldLabels.keys() # TODO: should this be sorted? |
52 | |
50 | 53 editableFields = ('xdata_01', 'xdata_05', 'xdata_07', 'xdata_08', 'xdata_11', 'xdata_12', 'xdata_13') |
33 | 54 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
55 # die folgenden Klassen sind jetzt in einzelne Files ausgelagert aus Kompatibilitaetsgruenden, bleiben die Klassen hier noch drin. |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
56 # Sonst funktionieren die alten Webseiten nicht mehr. |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
57 |
80 | 58 import MPIWGRoot |
59 import MPIWGLink | |
60 import MPIWGTemplate | |
61 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
62 class MPIWGRoot(MPIWGRoot.MPIWGRoot): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
63 """depricated""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
64 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
65 class MPIWGLink(MPIWGLink.MPIWGLink): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
66 """depricated""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
67 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
68 class MPIWGTemplate(MPIWGTemplate.MPIWGTemplate): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
69 """depricated""" |
80 | 70 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
71 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
72 class MPIWGProject_publication(Folder): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
73 """publications object fuer project""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
74 |
35 | 75 meta_type = "MPIWGProject_publication" |
61 | 76 |
77 text = None | |
78 link = None | |
79 bookId = None | |
80 | |
65 | 81 # templates |
63 | 82 editDescription = PageTemplateFile('zpt/project/related_publication/edit_basic', globals()) |
61 | 83 |
84 | |
35 | 85 def redirect(self, RESPONSE, url): |
61 | 86 """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen""" |
35 | 87 timeStamp = time.time() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
88 |
35 | 89 if url.find("?") > -1: # giebt es schon parameter |
90 addStr = "&time=%s" | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
91 else: |
35 | 92 addStr = "?time=%s" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
93 |
35 | 94 RESPONSE.setHeader('Last-Modified', email.Utils.formatdate().split("-")[0] + 'GMT') |
95 logging.debug(email.Utils.formatdate() + ' GMT') | |
96 RESPONSE.redirect(url + addStr % timeStamp) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
97 |
61 | 98 |
99 def hasLinkToBookPage(self): | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
100 """teste ob eingebener link zu einer MPIWG Book page geht""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
101 logging.debug("MPIWGProject_publication - begin hasLinkToBookPage") |
61 | 102 if not self.link: |
35 | 103 return False # es gibt keinen link |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
104 |
61 | 105 paths = self.link.split('/') |
106 if len(paths) > 2: | |
107 # book page should be in folder books | |
108 bookid = None | |
109 try: | |
110 idx = paths.index('books') | |
111 bookid = paths[idx + 1] | |
112 book = self.en.books[bookid] | |
113 self.bookId = bookid | |
114 return True | |
115 | |
116 except: | |
117 logging.debug("hasLinkToBookPage: not a book page link=%s"%self.link) | |
118 | |
119 self.bookId = None | |
120 return False | |
121 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
122 |
61 | 123 def getBookId(self): |
124 """Return the book page id.""" | |
125 return self.bookId | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
126 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
127 |
80 | 128 getUrl = MPIWGHelper.getUrl |
129 | |
130 | |
61 | 131 def editPublication(self, text=None, description=None, link=None, RESPONSE=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
132 """edit a publication""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
133 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
134 if (not text) and (not description): |
63 | 135 pt = self.editDescription |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
136 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
137 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
138 if text: |
61 | 139 self.text = text |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
140 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
141 if description: |
35 | 142 self.description = description |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
143 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
144 if link: |
61 | 145 self.link = link |
146 self.hasLinkToBookPage() | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
147 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
148 if RESPONSE: |
35 | 149 self.redirect(RESPONSE, "../managePublications") |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
150 |
39 | 151 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
152 class MPIWGProject_relatedProject(Folder): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
153 """publications object fuer project""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
154 |
35 | 155 meta_type = "MPIWGProject_relatedProject" |
60 | 156 |
61 | 157 objid = None |
158 projectLabel = None | |
159 | |
80 | 160 # templates |
63 | 161 editDescription = PageTemplateFile('zpt/project/related_project/edit_basic', globals()) |
61 | 162 |
35 | 163 def redirect(self, RESPONSE, url): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
164 """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
165 |
35 | 166 timeStamp = time.time() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
167 |
35 | 168 if url.find("?") > -1: # giebt es schon parameter |
169 addStr = "&time=%s" | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
170 else: |
35 | 171 addStr = "?time=%s" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
172 |
35 | 173 RESPONSE.setHeader('Last-Modified', email.Utils.formatdate().split("-")[0] + 'GMT') |
174 logging.debug(email.Utils.formatdate() + ' GMT') | |
175 RESPONSE.redirect(url + addStr % timeStamp) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
176 |
60 | 177 |
61 | 178 def getProjectId(self): |
179 """Return the related project id.""" | |
180 return self.objid | |
181 | |
182 | |
183 def getProject(self): | |
184 """Return the related project object.""" | |
185 return getattr(self.projects, self.objid, None) | |
186 | |
187 | |
60 | 188 def getProjectTitle(self): |
189 """Return the title of the related project.""" | |
190 return getattr(self, 'projectWEB_title', None) | |
61 | 191 |
60 | 192 |
61 | 193 def getProjectLabel(self): |
194 """Return the label of the related project.""" | |
195 label = getattr(self, 'projectLabel', None) | |
196 if not label: | |
197 proj = self.getProject() | |
198 if proj is not None: | |
199 label = proj.getLabel() | |
200 | |
201 self.projectLabel = label | |
202 | |
203 return label | |
204 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
205 |
80 | 206 getUrl = MPIWGHelper.getUrl |
207 | |
208 | |
35 | 209 def editRelatedProject(self, link=None, RESPONSE=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
210 """edit a publication""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
211 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
212 if (not link): |
63 | 213 pt = self.editDescription |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
214 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
215 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
216 # hole die id des projektes |
35 | 217 splitted = link.split("/") |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
218 |
35 | 219 # teste ob es das project gibt |
220 if len(splitted) < 1: | |
221 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
222 |
35 | 223 objid = splitted[-1] |
224 object = getattr(self.projects, objid, None) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
225 |
61 | 226 if object is None: |
35 | 227 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
228 |
35 | 229 self.orginallink = link[0:] |
230 self.objid = objid[0:] | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
231 |
52 | 232 self.projectWEB_title = object.getProjectTitle() |
61 | 233 self.projectLabel = object.getLabel() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
234 |
35 | 235 self.enabled = True; |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
236 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
237 if RESPONSE: |
35 | 238 self.redirect(RESPONSE, "../manageRelatedProjects") |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
239 |
39 | 240 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
241 class MPIWGProject_image(Image): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
242 """Images for Projects""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
243 |
35 | 244 meta_type = "MPIWGProject_image" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
245 |
65 | 246 # templates |
247 showImage = PageTemplateFile('zpt/project/image/projectImageView', globals()) | |
248 editForm = PageTemplateFile('zpt/project/image/edit_basic', globals()) | |
249 | |
80 | 250 getUrl = MPIWGHelper.getUrl |
251 | |
35 | 252 def editImage(self, file=None, caption=None, RESPONSE=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
253 """edit the Image""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
254 if (not file) and (not caption): |
65 | 255 pt = self.editForm |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
256 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
257 |
35 | 258 if file and (not file.filename.lstrip().rstrip() == ""): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
259 self.manage_upload(file) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
260 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
261 if caption: |
35 | 262 self.caption = caption[0:] |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
263 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
264 if RESPONSE: |
35 | 265 self.redirect(RESPONSE, "../manageImages") |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
266 |
24 | 267 |
65 | 268 class MPIWGProject(Folder): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
269 """Class for Projects""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
270 |
33 | 271 security = ClassSecurityInfo() |
272 meta_type = 'MPIWGProject' | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
273 |
35 | 274 manage_options = Folder.manage_options + ( |
275 {'label':'Load New File', 'action':'loadNewFileForm'}, | |
63 | 276 {'label':'Edit', 'action':'editDescription'}, |
22 | 277 ) |
35 | 278 # {'label':'Edit ProjectInfo','action':'editMPIWGProjectForm'}, |
279 # {'label':'Edit BasisInfo','action':'editMPIWGBasisForm'}, | |
280 # {'label':'Edit Publications','action':'editMPIWGRelatedPublicationsForm'}, | |
281 # {'label':'Edit Themes & Disciplines','action':'editMPIWGDisciplinesThemesForm'}, | |
282 # {'label':'Versionmanager','action':'versionManageForm'}, | |
22 | 283 |
36 | 284 # list of responsible scientists. entries are dicts with name, key, and username. |
35 | 285 responsibleScientistsList = [] |
36 | 286 |
287 # thumbnail image | |
288 projectThumb = None | |
22 | 289 |
33 | 290 # |
291 # templates | |
292 # | |
74
e424b68244c8
better template for additional project publications.
casties
parents:
65
diff
changeset
|
293 project_html = PageTemplateFile('zpt/project/project_template', globals()) |
50 | 294 # edit templates |
22 | 295 edit_css = ImageFile('css/edit.css', globals()) |
296 # make css refreshable for development | |
297 edit_css.index_html = refreshingImageFileIndexHtml | |
61 | 298 # user-accessible editing templates |
63 | 299 security.declareProtected('View management screens', 'editBasic') |
300 editBasic = PageTemplateFile('zpt/project/edit_basic', globals()) | |
301 editDescription = PageTemplateFile('zpt/project/edit_description', globals()) | |
22 | 302 edit_template = PageTemplateFile('zpt/project/edit_template', globals()) |
60 | 303 editRelatedProjectsForm = PageTemplateFile('zpt/project/edit_related_projects', globals()) |
61 | 304 editRelatedProjectsError = PageTemplateFile('zpt/project/edit_related_projects_error', globals()) |
60 | 305 editImagesForm = PageTemplateFile('zpt/project/edit_images', globals()) |
306 editPublicationsForm = PageTemplateFile('zpt/project/edit_publications', globals()) | |
61 | 307 editAdditionalPublicationsForm = PageTemplateFile('zpt/project/pubman/change_publications', globals()) |
62 | 308 editAddAdditionalPublications = PageTemplateFile('zpt/project/pubman/add_publications', globals()) |
63 | 309 security.declareProtected('View management screens', 'edit') |
310 edit = editDescription | |
50 | 311 # management templates |
312 loadNewFileForm = PageTemplateFile('zpt/project/manage_newfile', globals()) | |
313 description_only_html = PageTemplateFile('zpt/project/description_only_html', globals()) | |
61 | 314 # additional pages |
74
e424b68244c8
better template for additional project publications.
casties
parents:
65
diff
changeset
|
315 additional_publications_html = PageTemplateFile('zpt/project/pubman/show_publications', globals()) |
65 | 316 # TODO: remove compat |
22 | 317 edit_MPIWGProject_main = edit_template |
318 | |
319 | |
320 def __init__(self, id, argv=None): | |
321 """initiere classe""" | |
35 | 322 self.creationTime = time.strftime("%Y%m%d%H%M%S", time.localtime())[0:] |
323 self.id = id | |
324 self.title = id | |
325 self.isActiveFlag = True # Flag is true is the project is still active, False if accomplished | |
326 self.responsibleScientistsList = [] # enthaelt die Lister der verantwortlichen Wissenschaftler in der Form (NAME, KEY), key ist "" flass Wissenschaftler nicht an unserem Haus | |
22 | 327 |
328 if argv: | |
329 for arg in definedFields: | |
330 try: | |
35 | 331 setattr(self, arg, argv[arg]) |
22 | 332 except: |
35 | 333 setattr(self, arg, "") |
22 | 334 else: |
335 for arg in definedFields: | |
35 | 336 setattr(self, arg, '') |
22 | 337 |
338 | |
35 | 339 def index_html(self): |
340 """default html representation""" | |
341 # TODO: do we need to do date-stuff? | |
342 # get template | |
74
e424b68244c8
better template for additional project publications.
casties
parents:
65
diff
changeset
|
343 pt = self.project_html |
35 | 344 # render template |
345 return pt() | |
346 | |
347 def redirect(self, RESPONSE, url): | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
348 """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
349 |
35 | 350 timeStamp = time.time() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
351 |
35 | 352 if url.find("?") > -1: # giebt es schon parameter |
353 addStr = "&time=%s" | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
354 else: |
35 | 355 addStr = "?time=%s" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
356 |
35 | 357 RESPONSE.setHeader('Last-Modified', email.Utils.formatdate().split("-")[0] + 'GMT') |
358 logging.debug(email.Utils.formatdate() + ' GMT') | |
359 RESPONSE.redirect(url + addStr % timeStamp) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
360 |
27 | 361 |
60 | 362 def getDefinedFields(self): |
363 """show all defined fields.""" | |
364 return definedFields | |
365 | |
366 | |
367 def getFieldLabels(self): | |
368 """Return the field labels dict.""" | |
369 return fieldLabels | |
370 | |
371 | |
372 def getEditableFields(self): | |
373 """giveListofDatafields""" | |
374 return editableFields | |
375 | |
376 | |
27 | 377 def getNumber(self): |
378 """returns sorting number""" | |
33 | 379 n = getattr(self, 'xdata_05', None) |
380 if isinstance(n, list): | |
381 # compat with old lists | |
382 return n[0] | |
383 else: | |
384 return n | |
27 | 385 |
35 | 386 |
80 | 387 def getProjectTitle(self, forSorting=False): |
35 | 388 """returns the project title""" |
389 t = getattr(self, 'WEB_title', None) | |
390 if isinstance(t, list): | |
391 # compat with old lists | |
80 | 392 t = t[0] |
393 | |
394 if forSorting and t is not None: | |
395 # remove stopwords and signs for sorting | |
396 if t.lower().startswith('a '): | |
397 t = t[2:] | |
398 elif isinstance(t, unicode) and unicodedata.category(t[0])[0] != 'L': | |
399 t = t[1:] | |
400 | |
401 return t | |
35 | 402 |
39 | 403 |
404 def getLabel(self): | |
405 """returns label (or title) of this project""" | |
406 l = getattr(self, 'xdata_07', None) | |
407 if isinstance(l, list): | |
408 # compat with old lists | |
409 l = l[0] | |
410 | |
411 if l: | |
412 return l | |
413 else: | |
414 return self.getProjectTitle() | |
415 | |
416 | |
35 | 417 def getResponsibleScientists(self): |
418 """returns the responsible scientists as string""" | |
419 t = getattr(self, 'xdata_01', None) | |
420 if isinstance(t, list): | |
421 # compat with old lists | |
422 return t[0] | |
423 else: | |
424 return t | |
425 | |
426 | |
427 def getResponsibleScientistsList(self): | |
428 """returns a list with the responsible scientists as dicts with name, key, and shortname""" | |
429 return self.responsibleScientistsList | |
430 | |
431 | |
432 def setResponsibleScientistsList(self, nameDict): | |
433 """sets the responsibleScientistsList from nameDict. | |
434 List will be ordered like the responsible scientists field.""" | |
435 names = self.getResponsibleScientists() | |
436 if names.find(";") > -1: # rate Trenner ist ; | |
437 nameList = names.split(";") | |
438 else: | |
439 nameList = names.split(",") | |
440 | |
441 scientistsList = [] | |
442 for name in nameList: | |
443 name = unicodify(name.strip()) | |
444 logging.debug("setResponsibleScientistsList: name=%s"%repr(name)) | |
445 if name in nameDict: | |
446 # found in data | |
447 data = nameDict[name] | |
448 scientistsList.append({'name': name, 'key': data['key'], 'username': data['username']}) | |
449 else: | |
450 scientistsList.append({'name': name}) | |
451 | |
452 logging.debug("setResponsibleScientistsList: nameDict=%s new list=%s"%(repr(nameDict),repr(scientistsList))) | |
453 self.responsibleScientistsList = scientistsList | |
454 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
455 |
39 | 456 def getInvolvedScholars(self): |
457 """returns the other involved scholars""" | |
458 t = getattr(self, 'xdata_08', None) | |
459 if isinstance(t, list): | |
460 # compat with old lists | |
461 return t[0] | |
462 else: | |
463 return t | |
464 | |
465 | |
466 def getCooperationPartners(self): | |
467 """returns the cooperation partners""" | |
468 t = getattr(self, 'xdata_12', None) | |
469 if isinstance(t, list): | |
470 # compat with old lists | |
471 return t[0] | |
472 else: | |
473 return t | |
474 | |
61 | 475 |
476 def getMPIWGProjectUrl(self): | |
477 """Return this project for acquisition.""" | |
478 return self.absolute_url() | |
479 | |
39 | 480 |
80 | 481 getUrl = MPIWGHelper.getUrl |
27 | 482 |
483 | |
65 | 484 def getThumbUrl(self, default=None): |
24 | 485 """returns the URL of the project thumbnail image""" |
36 | 486 thumb = self.projectThumb |
487 if thumb is None: | |
52 | 488 # get thumb from list (thumb is last image) |
36 | 489 imgs = self.getImageList() |
490 if len(imgs) > 0: | |
52 | 491 thumb = imgs[-1] |
36 | 492 self.projectThumb = thumb |
493 | |
494 if thumb is None: | |
52 | 495 return default |
36 | 496 |
497 return thumb.absolute_url() | |
498 | |
24 | 499 |
39 | 500 def getDepartment(self): |
501 """returns the department of this project""" | |
502 num = self.getNumber() | |
503 pp = num.find('.') | |
504 if pp > 0: | |
505 num = num[:pp] | |
506 | |
80 | 507 return self.en.getMPIWGRoot().getDepartment(projectNumber=num) |
39 | 508 |
509 | |
510 def getDepartmentId(self): | |
511 """returns the id of the department of this project""" | |
512 dep = self.getDepartment() | |
513 if dep is not None: | |
514 return dep.getId() | |
515 | |
516 return None | |
517 | |
518 | |
519 def getDescription(self, filter=False): | |
520 """returns the project description""" | |
49 | 521 text = getattr(self, 'WEB_project_description', None) |
522 if isinstance(text, list): | |
39 | 523 # compat with old lists |
49 | 524 text = text[0] |
525 | |
526 return text | |
527 | |
39 | 528 |
529 def getSuperProjects(self): | |
530 """returns a list of ancestor projects to the root""" | |
531 tree = self.getProjectTree() | |
532 return tree.getAncestorsOf(self.getNumber()) | |
533 | |
534 | |
535 def getSubProjects(self, active=1): | |
536 """returns a list of child projects""" | |
537 tree = self.getProjectTree() | |
538 return [p for p in tree.getChildrenOf(self.getNumber()) if p.checkActive(active)] | |
539 | |
540 | |
541 def getRelatedDigitalSources(self): | |
542 """returns the related digital sources""" | |
543 t = getattr(self, 'xdata_11', None) | |
544 if isinstance(t, list): | |
545 # compat with old lists | |
546 return t[0] | |
547 else: | |
548 return t | |
43 | 549 |
39 | 550 |
551 def getFundingInstitutions(self): | |
552 """returns the funding institutions""" | |
553 t = getattr(self, 'xdata_13', None) | |
554 if isinstance(t, list): | |
555 # compat with old lists | |
556 return t[0] | |
557 else: | |
558 return t | |
559 | |
24 | 560 |
63 | 561 def _moveObjectPlace(self, objectList, objectId, direction): |
60 | 562 """Move object with objectId from objectList in direction |
563 by changing its place attribute.""" | |
564 if not objectId or not direction: | |
565 return | |
566 | |
567 for idx in range(len(objectList)): | |
568 object = objectList[idx] | |
61 | 569 if object.getId() == objectId: |
60 | 570 if direction == 'up': |
571 if idx > 0: | |
572 # move up | |
573 objectList[idx -1].place += 1 | |
574 objectList[idx].place -= 1 | |
575 | |
576 elif direction == 'down': | |
577 if idx < len(objectList) - 1: | |
578 # move down | |
579 objectList[idx + 1].place -= 1 | |
580 objectList[idx].place += 1 | |
581 | |
582 return | |
583 | |
63 | 584 |
585 def getImageList(self): | |
586 """returns the sorted list of images for this project""" | |
587 items = self.objectValues(spec='MPIWGProject_image') | |
588 # sort by place | |
589 return sorted(items, key=lambda x:int(getattr(x, 'place', 0))) | |
590 | |
591 | |
592 def addImage(self, fileHd, caption, RESPONSE=None, filename=None): | |
593 """add an MPIWG_Project_image""" | |
594 | |
595 if not filename: | |
596 filename = fileHd.filename | |
597 | |
598 if not fileHd: | |
599 fileHd = file(os.path.join(package_home(globals()), 'blank.gif')) | |
600 | |
601 newImage = MPIWGProject_image(filename, filename, fileHd) | |
602 | |
603 self._setObject(filename, newImage) | |
604 obj = getattr(self, filename) | |
605 obj.caption = caption[:] | |
606 obj.enabled = True; | |
607 obj.place = self._getLastImageNumber() + 1 | |
608 obj.id = filename | |
609 | |
610 # invalidate thumbnail | |
611 self.projectThumb = None | |
612 | |
613 if RESPONSE is not None: | |
614 self.redirect(RESPONSE, 'manageImages') | |
615 | |
616 | |
617 def _getLastImageNumber(self): | |
618 items = self.getImageList() | |
619 if not items: | |
620 return 0 | |
621 else: | |
622 return getattr(items[-1], 'place', 0) | |
623 | |
624 | |
61 | 625 def manageImages(self, name=None, op=None): |
60 | 626 """manage images""" |
63 | 627 self._moveObjectPlace(self.getImageList(), name, op) |
60 | 628 |
51 | 629 # invalidate thumbnail |
630 self.projectThumb = None | |
60 | 631 |
632 pt = self.editImagesForm | |
50 | 633 return pt() |
634 | |
60 | 635 |
63 | 636 def deleteImage(self, id, RESPONSE=None): |
637 """delete Image id""" | |
638 try: | |
639 self.manage_delObjects([id]) | |
640 except: | |
641 logging.error("ERROR MPIWG: %s %s" % sys.exc_info()[0:2]) | |
642 | |
643 # invalidate thumbnail | |
644 self.projectThumb = None | |
645 | |
646 if RESPONSE: | |
647 self.redirect(RESPONSE, 'manageImages') | |
50 | 648 |
63 | 649 |
650 def getPublicationList(self): | |
651 """returns the list of related publications""" | |
652 items = self.objectValues(spec='MPIWGProject_publication') | |
653 # sort by place | |
654 items.sort(key=lambda x:int(getattr(x, 'place', 0))) | |
655 return items | |
656 | |
50 | 657 |
64 | 658 def addPublication(self, text=None, link=None, RESPONSE=None): |
50 | 659 """add an MPIWG_Publication""" |
64 | 660 if text or link: |
661 number = self._getLastPublicationNumber() + 1 | |
50 | 662 name = "publication_" + str(number) |
64 | 663 while hasattr(self, name): |
664 number += 1 | |
665 name = "publication_" + str(number) | |
666 | |
667 newPublication = MPIWGProject_publication(name) | |
50 | 668 |
64 | 669 self._setObject(name, newPublication) |
670 obj = getattr(self, name) | |
671 obj.text = text | |
672 obj.link = link | |
673 obj.enabled = True; | |
674 obj.place = self._getLastPublicationNumber() + 1 | |
675 obj.id = name | |
676 # hasLinkToBookPage updates bookid if available | |
677 if obj.hasLinkToBookPage() and not text: | |
678 # take title from book page | |
679 try: | |
680 book = self.en.books[obj.bookId] | |
681 obj.text = book.getInfo('title') | |
682 except: | |
683 pass | |
50 | 684 |
685 if RESPONSE is not None: | |
686 self.redirect(RESPONSE, 'managePublications') | |
687 | |
60 | 688 |
63 | 689 def _getLastPublicationNumber(self): |
690 items = self.getPublicationList() | |
691 if not items: | |
692 return 0 | |
693 else: | |
694 return getattr(items[-1], 'place', 0) | |
695 | |
696 | |
697 def managePublications(self, name=None, op=None): | |
698 """manage publications""" | |
699 self._moveObjectPlace(self.getPublicationList(), name, op) | |
700 | |
701 pt = self.editPublicationsForm | |
702 return pt() | |
50 | 703 |
63 | 704 |
705 def deletePublication(self, id, RESPONSE=None): | |
706 """delete Publication id""" | |
707 self.manage_delObjects([id]) | |
708 if RESPONSE: | |
709 self.redirect(RESPONSE, 'managePublications') | |
710 | |
711 | |
712 def getRelatedProjectList(self): | |
713 """returns the list of related projects""" | |
714 items = self.objectValues(spec='MPIWGProject_relatedProject') | |
715 # sort by place | |
716 items.sort(key=lambda x:int(getattr(x, 'place', 0))) | |
717 return items | |
718 | |
60 | 719 |
50 | 720 def addRelatedProject(self, link, RESPONSE=None): |
60 | 721 """add a MPIWGProject_relatedProject""" |
63 | 722 number = self._getLastRelatedProjectNumber() + 1 |
61 | 723 name = "related_project_" + str(number) |
50 | 724 while hasattr(self, name): |
725 number += 1 | |
61 | 726 name = "related_project_" + str(number) |
50 | 727 |
728 # hole die id des projektes | |
729 splitted = link.split("/") | |
730 | |
731 # teste ob es das project gibt | |
732 if len(splitted) < 1: | |
733 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link) | |
734 | |
735 objid = splitted[-1] | |
736 object = getattr(self.projects, objid, None) | |
737 | |
738 if object == None: | |
739 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link) | |
740 return | |
741 | |
742 newPublication = MPIWGProject_relatedProject(name) | |
743 | |
744 self._setObject(name, newPublication) | |
745 obj = getattr(self, name) | |
746 obj.orginallink = link[0:] | |
747 obj.objid = objid[0:] | |
748 logging.debug("add relobj:objid" + repr(obj.objid)) | |
60 | 749 obj.projectWEB_title = object.getProjectTitle() |
50 | 750 logging.debug("add relobj:webtitle" + repr(obj.projectWEB_title)) |
751 obj.enabled = True; | |
63 | 752 obj.place = self._getLastRelatedProjectNumber() + 1 |
50 | 753 obj.id = name |
754 if RESPONSE is not None: | |
755 self.redirect(RESPONSE, 'manageRelatedProjects') | |
756 | |
757 | |
63 | 758 def _getLastRelatedProjectNumber(self): |
61 | 759 items = self.getRelatedProjectList() |
760 if not items: | |
50 | 761 return 0 |
762 else: | |
61 | 763 return getattr(items[-1], 'place', 0) |
60 | 764 |
50 | 765 |
63 | 766 def manageRelatedProjects(self, name=None, op=None): |
767 """manage related projects""" | |
768 self._moveObjectPlace(self.getRelatedProjectList(), name, op) | |
769 | |
770 pt = self.editRelatedProjectsForm | |
771 return pt() | |
772 | |
773 | |
774 def deleteRelatedProject(self, id, RESPONSE=None): | |
775 """delete Publication id""" | |
776 self.manage_delObjects([id]) | |
777 if RESPONSE: | |
778 self.redirect(RESPONSE, 'manageRelatedProjects') | |
779 | |
60 | 780 |
63 | 781 def errorRelatedProjects(self, link): |
782 """error creating a related project""" | |
783 pt = self.editRelatedProjectsError | |
784 return pt(link=link) | |
785 | |
786 | |
787 def getAdditionalPublicationList(self): | |
788 """hole publications aus der datenbank""" | |
789 query="select * from pubmanbiblio_projects where lower(key_main) = lower(%s) order by priority DESC" | |
790 return self.executeZSQL(query,[self.getId()]) | |
791 | |
792 | |
793 def hasAdditionalPublications(self): | |
794 """test if extended publication list exists""" | |
795 query="select count(*) from pubmanbiblio_projects where lower(key_main) = lower(%s)" | |
796 res= self.executeZSQL(query,[self.getId()]) | |
797 if res[0].count > 0: | |
798 return True | |
799 else: | |
800 return False | |
50 | 801 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
802 |
63 | 803 def addAdditionalPublicationsFromPubman(self,REQUEST): |
804 """addPublications from pubman""" | |
805 data=REQUEST.form | |
806 if data.get("method",None) is None: | |
807 pt = self.editAddAdditionalPublications | |
808 return pt() | |
809 | |
810 if data.get("method") == "search": | |
811 entries= self.mpiwgPubman.search(data) | |
812 pt = self.editAddAdditionalPublications | |
813 return pt(values=entries) | |
814 | |
815 if data.get("method") == "add": | |
816 return self.addEntriesToAdditionalPublicationList(data) | |
817 #pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/staff/pubman','add_publications.zpt')).__of__(self) | |
818 | |
819 | |
820 def addEntriesToAdditionalPublicationList(self,data): | |
821 """fuege eintrage aus data zur publications liste. | |
822 | |
823 @param data Map mit escidocID --> value | |
824 value muss "add" sein damit hinzugefuegt wird""" | |
825 for key in data.keys(): | |
826 if key.startswith('escidoc:'): | |
827 query="INSERT INTO pubmanbiblio_projects (key_main,escidocId) values (%s,%s)" | |
828 if data.get(key)=="add": | |
829 self.executeZSQL(query,[self.getId(),key]) | |
830 | |
831 if hasattr(self,'REQUEST'): | |
832 return self.REQUEST.response.redirect("changeAdditionalPublications") | |
833 | |
834 | |
835 def changeAdditionalPublications(self,REQUEST): | |
836 """change published publications""" | |
837 data=REQUEST.form | |
838 if data.get("method","change"): | |
839 for key in data.keys(): | |
840 splitted=key.split("__") #format escidoc_id__p fuer priority, nur escidocid | |
841 value=data[key] | |
842 if len(splitted)==1: | |
843 self.deleteFromAdditionalPublicationList(key); | |
44 | 844 |
63 | 845 elif(splitted[1]) == "p": |
846 self.setAdditionalPublicationPriority(splitted[0],value); | |
847 | |
848 pt = self.editAdditionalPublicationsForm | |
849 return pt() | |
850 | |
851 | |
852 def deleteFromAdditionalPublicationList(self,escidocid): | |
853 """Loessche publication with escidoc id from publication list""" | |
854 query ="DELETE FROM pubmanbiblio_projects WHERE escidocid=%s and key_main=%s" | |
855 self.executeZSQL(query,[escidocid,self.getId()]); | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
856 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
857 |
63 | 858 def setAdditionalPublicationPriority(self,escidocid,value): |
859 query="update pubmanbiblio_projects set priority=%s where escidocid=%s and key_main=%s" | |
860 try: | |
861 value = int(value) | |
862 self.executeZSQL(query,[value,escidocid,self.getId()]); | |
863 except: | |
864 logging.error("couldn't change:") | |
865 logging.error(escidocid) | |
866 logging.error(value) | |
44 | 867 |
50 | 868 |
35 | 869 def getActualVersion(self, date=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
870 """actuelle version""" |
35 | 871 def sortProjectsByTime(x, y): |
872 return cmp(x[1].archiveTime, y[1].archiveTime) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
873 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
874 if not date: |
44 | 875 if self.isCurrentVersion(): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
876 return self |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
877 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
878 return None |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
879 |
35 | 880 # suche ob aeltere versionen vorhanden sind |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
881 |
35 | 882 finds = self.ZopeFind(self, obj_metatypes=['MPIWGProject']) |
883 if not finds: # wenn nicht dann teste ob die aktuelle version schon existiert hat. | |
884 ad = getattr(self, 'creationTime', '20050101000000') | |
885 if int(date) > int(ad): | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
886 return self |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
887 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
888 return None |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
889 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
890 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
891 finds.sort(sortProjectsByTime) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
892 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
893 for find in finds: |
35 | 894 # gehe durch die alten Projekte und finde das entprechende |
895 if (int(find[1].archiveTime) > int(date)) and (int(date) > int(getattr(find[1], 'creationTime', '20050101000000'))): | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
896 return find[1] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
897 |
35 | 898 # kein passendes gefunden, dann teste ob das aktuelle in frage kommt |
899 ad = getattr(self, 'creationTime', '20050101000000') | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
900 |
35 | 901 if int(date) > int(ad): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
902 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
903 return self |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
904 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
905 return None |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
906 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
907 |
44 | 908 def isCurrentVersion(self): |
909 """Return if project is the current version.""" | |
910 currentTime = time.localtime() | |
911 # print getattr(self,'archiveTime',currentTime) | |
912 return (getattr(self, 'archiveTime', currentTime) >= currentTime) | |
913 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
914 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
915 def copyObjectToArchive(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
916 """kopiere aktuelles objekt ins archiv""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
917 logging.info("copytoarchive 1") |
35 | 918 cb = self.aq_parent.manage_copyObjects(self.getId()) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
919 logging.info("copytoarchive 2") |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
920 self.manage_pasteObjects(cb) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
921 logging.info("copytoarchive 3") |
35 | 922 actualTime = time.localtime() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
923 |
35 | 924 self.manage_renameObject(self.getId(), self.getId() + "_" + time.strftime("%Y%m%d%H%M%S", actualTime)) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
925 logging.info("copytoarchive 4") |
35 | 926 obj = getattr(self, self.getId() + "_" + time.strftime("%Y%m%d%H%M%S", actualTime)) |
927 obj.setArchiveTime(time.strftime("%Y%m%d%H%M%S", actualTime)) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
928 logging.info("copytoarchive 5") |
35 | 929 ids = [x[0] for x in self.ZopeFind(obj, obj_metatypes=['MPIWGProject'])] |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
930 logging.info("copytoarchive 6") |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
931 obj.manage_delObjects(ids) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
932 logging.info("copytoarchive 7") |
60 | 933 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
934 |
35 | 935 def setArchiveTime(self, time): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
936 """set Archive Time""" |
35 | 937 self.archiveTime = time[0:] |
60 | 938 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
939 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
940 def delArchiveTime(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
941 """delete archive time""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
942 del self.archiveTime |
60 | 943 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
944 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
945 def isActiveProject(self): |
39 | 946 """check if the project is still active, default is true.""" |
35 | 947 return getattr(self, 'isActiveFlag', True) |
60 | 948 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
949 |
27 | 950 def checkActive(self, active): |
951 """returns if the project state matches the active state. | |
952 active = 0 : all projects | |
953 active = 1 : active projects | |
954 active = 2 : inactive projects | |
955 """ | |
35 | 956 act = getattr(self, 'isActiveFlag', True) |
27 | 957 return (active == 1 and act) or (active == 0) or (active == 2 and not act) |
60 | 958 |
27 | 959 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
960 def isArchivedProject(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
961 """check if the project is archived""" |
35 | 962 completed = self.getCompletedAt() |
963 # completed leer | |
964 if completed == "" : | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
965 return False; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
966 if completed == 0: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
967 return False; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
968 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
969 return True |
60 | 970 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
971 |
27 | 972 def checkArchived(self, archived): |
973 """returns if the project state matches the archived state. | |
974 archived = 0 : all projects | |
975 archived = 1 : current projects | |
976 archived = 2 : archived projects | |
977 """ | |
978 arch = self.isArchivedProject() | |
979 return (archived == 1 and not arch) or (archived == 0) or (archived == 2 and arch) | |
60 | 980 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
981 |
35 | 982 def setActiveFlag(self, status=True): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
983 """set the active flag""" |
35 | 984 self.isActiveFlag = status |
60 | 985 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
986 |
35 | 987 def setCompletedAt(self, date): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
988 """set the date of completion, date should be in the form DD.MM.YYYY or MM.YYYY or YYYY""" |
35 | 989 # logging.info("DATE:"+repr(date)) |
990 transformedDate = self.transformDate(date); | |
991 # logging.info("transformed"+repr(transformedDate)) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
992 if transformedDate is not None: |
35 | 993 setattr(self, "completedAt", transformedDate) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
994 return True; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
995 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
996 return False; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
997 |
35 | 998 def setStartedAt(self, date): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
999 """set the date of start, date should be in the form DD.MM.YYYY or MM.YYYY or YYYY""" |
35 | 1000 # logging.info("DATE:"+repr(date)) |
1001 transformedDate = self.transformDate(date); | |
1002 # logging.info("transformed"+repr(transformedDate)) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1003 if transformedDate is not None: |
35 | 1004 setattr(self, "startedAt", transformedDate) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1005 return True; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1006 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1007 return False; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1008 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1009 def getCompletedAt(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1010 """gibt das transformierte Datum zurueck, an dem das Projekt beendet wurde.""" |
35 | 1011 date = getattr(self, 'completedAt', '') |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1012 if date: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1013 return self.reTransformDate(date); |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1014 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1015 return "" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1016 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1017 def getStartedAt(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1018 """gibt das transformierte Datum zurueck, an dem Projekt begonnen wurde.""" |
35 | 1019 date = getattr(self, 'startedAt', '') |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1020 if date: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1021 return self.reTransformDate(date); |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1022 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1023 return ''; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1024 |
35 | 1025 def reTransformDate(self, date): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1026 """transformiert , transformdate zurueck""" |
35 | 1027 year = int(date / 10000) |
1028 month = int((date - year * 10000) / 100) | |
1029 day = int((date - year * 10000 - month * 100)) | |
1030 if (day == 0) and (month == 0): | |
1031 return """%s""" % year; | |
1032 if day == 0 : | |
1033 return """%s.%s""" % (month, year); | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1034 |
35 | 1035 return """%s.%s.%s""" % (day, month, year); |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1036 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1037 |
35 | 1038 def transformDate(self, date): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1039 """transformiert ein Datum von DD.MM.YYYY, MM.YYYY,YYYY nach YYYYMMDD, alle nicht angebenen Werte |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1040 werden auf 0 gesetzt, es wird null zurueckgegeben falls das Datum ungueltig ist""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1041 |
35 | 1042 if (date == None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1043 return None; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1044 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1045 |
35 | 1046 if (date.lstrip().rstrip() == "") : |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1047 return ""; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1048 |
35 | 1049 splitted = date.split(".") |
1050 length = len(splitted) | |
1051 year = 0 | |
1052 month = 0 | |
1053 day = 0 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1054 if length > 3: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1055 return ""; |
35 | 1056 if length == 3: |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1057 day = int(splitted[0]) |
35 | 1058 if length > 1: |
1059 month = int(splitted[length - 2]) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1060 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1061 if length > 0: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1062 try: |
35 | 1063 year = int(splitted[length - 1]) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1064 except: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1065 pass |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1066 |
35 | 1067 # # logging.info("month:"+(month)) |
1068 if not (0 <= month < 13): | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1069 return None; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1070 |
35 | 1071 if not(0 <= day < 32): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1072 return None; |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1073 |
35 | 1074 if (year > 0) and (year < 1900): # jahr nicht vierstellig eingegeben |
1075 year = 2000 + year; | |
1076 return year * 10000 + month * 100 + day | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1077 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1078 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1079 |
35 | 1080 def checkDate(self, date): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1081 """teste ob zum Zeitpunkt date eine andere version existierte""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1082 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1083 |
35 | 1084 def sortProjectsByTime(x, y): |
1085 return cmp(x[1].archiveTime, y[1].archiveTime) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1086 |
35 | 1087 # suche ob aeltere versionen vorhanden sind |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1088 |
35 | 1089 finds = self.ZopeFind(self, obj_metatypes=['MPIWGProject']) |
1090 if not finds: # wenn nicht dann teste ob die aktuelle version schon existiert hat. | |
1091 ad = getattr(self, 'creationTime', '20050101000000') | |
1092 if int(date) > int(ad): | |
1093 return self.REQUEST['URL1'] + "/" + self.getId() | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1094 else: |
35 | 1095 return self.REQUEST['URL1'] + "/no_project" |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1096 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1097 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1098 finds.sort(sortProjectsByTime) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1099 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1100 for find in finds: |
35 | 1101 # gehe durch die alten Projekte und finde das entprechende |
1102 if (int(find[1].archiveTime) > int(date)) and (int(date) > int(getattr(find[1], 'creationTime', '20050101000000'))): | |
1103 return self.REQUEST['URL1'] + "/" + find[1].getId() | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1104 |
35 | 1105 # kein passendes gefunden, dann teste ob das aktuelle in frage kommt |
1106 ad = getattr(self, 'creationTime', '20050101000000') | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1107 |
60 | 1108 if int(date) > int(ad): |
35 | 1109 return self.REQUEST['URL1'] + "/" + self.getId() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1110 else: |
35 | 1111 return self.REQUEST['URL1'] + "/no_project" |
60 | 1112 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1113 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1114 def saveFromPreview(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1115 """save content aus preview""" |
35 | 1116 self.WEB_project_description = self.previewTemplate.WEB_project_description[0:] |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1117 self.REQUEST.RESPONSE.redirect("./index.html") |
63 | 1118 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1119 |
35 | 1120 def saveEditedContent(self, kupu=None, preview=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1121 """save Edited content""" |
35 | 1122 # logging.debug("saveEditedContent kupu=%s preview=%s"%(kupu,preview)) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1123 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1124 if preview: |
35 | 1125 kupu = preview |
1126 # find content of body tags | |
1127 start = kupu.find("<body>") | |
1128 end = kupu.find("</body>") | |
1129 newcontent = kupu[start + 6:end] | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1130 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1131 if preview: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1132 return self.preview(newcontent) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1133 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1134 self.copyObjectToArchive() |
35 | 1135 self.WEB_project_description = newcontent[0:] |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1136 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1137 self.REQUEST.RESPONSE.redirect("./index.html") |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1138 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1139 return True |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1140 |
60 | 1141 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1142 def getBreadcrumbs(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1143 """return list of breadcrumbs from here to the root""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1144 crumbs = [] |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1145 # skip direct parent Folder /projects/ |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1146 parent = self.aq_parent.aq_parent |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1147 # get parents breadcrumbs |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1148 if hasattr(parent, 'getBreadcrumbs'): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1149 crumbs = parent.getBreadcrumbs() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1150 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1151 # try to get acquisition URL from parent |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1152 if hasattr(parent, 'absolute_url'): |
35 | 1153 baseUrl = "%s/%s/" % (parent.absolute_url(), 'projects') |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1154 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1155 baseUrl = "/en/research/projects/" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1156 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1157 # add in the internal project hierarchy |
52 | 1158 tree = self.getProjectTree() |
1159 ap = tree.getAncestorsOf(self.getNumber()) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1160 # start with grandparents |
52 | 1161 for p in ap: |
1162 label = shortenString(p.getLabel(), 13) | |
1163 crumbs.append((label, p.getUrl(baseUrl=baseUrl), p)) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1164 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1165 # add this project |
52 | 1166 crumbs.append((self.getLabel(), self.getUrl(baseUrl=baseUrl), self)) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1167 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1168 return crumbs |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1169 |
52 | 1170 # TODO: is this used? |
35 | 1171 def preview(self, description): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1172 """preview""" |
35 | 1173 # logging.debug("preview description=%s"%description) |
1174 tmpPro = getattr(self, "previewTemplate", None) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1175 if not tmpPro: |
35 | 1176 tmpPro = MPIWGProject("previewTemplate") |
1177 self._setObject("previewTemplate", tmpPro) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1178 for field in definedFields: |
35 | 1179 setattr(tmpPro, field, getattr(self, field)) |
1180 tmpPro.WEB_project_description = description[0:] | |
1181 tmpPro.invisible = True | |
1182 pt = PageTemplateFile('zpt/previewFrame.zpt', globals()).__of__(self) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1183 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1184 |
35 | 1185 # return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"/previewTemplate") |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1186 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1187 |
35 | 1188 def isResponsibleScientist(self, key): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1189 """teste ob eine Person in der Liste der respl. scientists auftaucht""" |
35 | 1190 for resp in self.getResponsibleScientistsList(): |
60 | 1191 logging.debug("resp=%s key=%s"%(repr(resp),repr(key))) |
63 | 1192 # TODO: we need to get ASCII keys!! |
80 | 1193 if utf8ify(resp.get('key', '')).lower() == utf8ify(key).lower(): |
35 | 1194 return True |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1195 |
35 | 1196 return False |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1197 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1198 |
35 | 1199 def identifyNames(self, nameList): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1200 """Bekommt eine Komma oder Semikolon getrennte Liste mit Name der Form Vorname MittelName(n) Nachname |
33 | 1201 und ordnet diese dann Mitarbeiter IDs zu. |
1202 | |
1203 Returns a dict with full names as keys and a row of person objects from the database as values. | |
1204 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1205 @param nameList |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1206 """ |
35 | 1207 if nameList.find(";") > -1: # rate Trenner ist ; |
1208 names = nameList.split(";") | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1209 else: |
35 | 1210 names = nameList.split(",") |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1211 |
35 | 1212 # #nameList=nameList.replace(";",",") # falls ; als Trenner ersetze |
1213 returnNamesDict = {} | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1214 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1215 for name in names: |
35 | 1216 name = name.strip() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1217 nameSplitted = name.split(" ") |
35 | 1218 if len(nameSplitted) > 1: # vor und nachname angegeben) |
1219 lastname = nameSplitted[-1] | |
1220 firstname = nameSplitted[0] | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1221 else: |
35 | 1222 firstname = "" |
1223 lastname = nameSplitted[0] | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1224 |
35 | 1225 # finde Mitarbeiter mit den entsprechenden Name |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1226 |
35 | 1227 # firstname=self.myCapitalize(firstname).encode('utf-8') |
1228 # lastname=self.myCapitalize(lastname).encode('utf-8') | |
1229 logging.debug("Search: %s %s %s" % (name, repr(firstname), repr(lastname))) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1230 try: |
35 | 1231 # cataloggedNames=self.MembersCatalog(firstName=firstname,lastName=lastname) |
33 | 1232 # TODO: I think this does not work without firstname |
1233 # try to find names in members db by searching for sub-words | |
1234 cataloggedNames = self.executeZSQL("select * from personal_www where first_name ~* ('\m'||%s||'\M') and last_name ~* ('\m'||%s||'\M')", (firstname, lastname)) | |
1235 if len(cataloggedNames) == 0: | |
1236 # PostgreSQL has a bug with \m and words ending in non-ASCII :-( | |
1237 cataloggedNames = self.executeZSQL("select * from personal_www where %s in (select regexp_split_to_table(lower(first_name), '\s+')) and %s in (select regexp_split_to_table(lower(last_name), '\s+'))", (firstname.lower(), lastname.lower())) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1238 except: |
35 | 1239 cataloggedNames = [] |
1240 logging.error("ERROR: identifyNames %s %s" % sys.exc_info()[0:2]) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1241 |
35 | 1242 if len(cataloggedNames) > 0: |
1243 returnNamesDict[name] = cataloggedNames | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1244 else: |
35 | 1245 returnNamesDict[name] = [] |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1246 |
50 | 1247 logging.debug("identified names: %s" % repr(returnNamesDict)) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1248 return returnNamesDict |
33 | 1249 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1250 |
49 | 1251 def editMPIWGProject(self, fromEdit=None, createNewVersion=True, RESPONSE=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1252 """edit the project and archive the old version""" |
49 | 1253 logging.debug("editMPIWGProject(fromEdit=%s, createNewVersion=%s)"%(fromEdit,createNewVersion)) |
1254 if createNewVersion: | |
1255 self.copyObjectToArchive() # archive the object | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1256 |
35 | 1257 formdata = self.REQUEST.form |
1258 | |
1259 # set all definedFields | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1260 for x in definedFields: |
35 | 1261 if formdata.has_key(x): |
50 | 1262 setattr(self, x, unicodify(formdata[x])) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1263 |
35 | 1264 # TODO: What does this do? |
1265 completedAt = formdata.get('completedAt') | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1266 if not self.setCompletedAt(completedAt): |
35 | 1267 RESPONSE.redirect('./editMPIWGBasisEditor?error=dateWrong') |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1268 |
35 | 1269 startedAt = formdata.get('startedAt') |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1270 if not self.setStartedAt(startedAt): |
35 | 1271 RESPONSE.redirect('./editMPIWGBasisEditor?error=dateWrong') |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1272 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1273 if self.REQUEST.has_key('active'): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1274 self.setActiveFlag(True) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1275 else: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1276 self.setActiveFlag(False) |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1277 |
35 | 1278 # make dict of responsible scientists |
1279 checkedScientists = {} | |
1280 names = {} | |
1281 keys = {} | |
43 | 1282 for key in formdata: |
35 | 1283 # gehe durch das Formular |
1284 keyParts = key.split("_") | |
1285 if keyParts[0] == "responsibleScientist": | |
1286 # wenn es ein Feld der Form reponsibleScientist_nr_KEY gibt | |
1287 nr = keyParts[2] | |
1288 if keyParts[1] == "name": | |
50 | 1289 names[nr] = unicodify(formdata[key]) |
35 | 1290 elif keyParts[1] == "key": |
1291 keys[nr] = formdata[key] | |
1292 | |
43 | 1293 for nr in names: |
35 | 1294 name = names[nr] |
1295 key = keys.get(nr, None) | |
1296 username = None | |
1297 if key: | |
1298 # get username from db | |
80 | 1299 member = self.en.getMPIWGRoot().getStaffFolder().getMember(key=key) |
40 | 1300 if member is not None: |
1301 username = member.getUsername() | |
35 | 1302 |
1303 # schreibe keys und namen in die Liste | |
1304 checkedScientists[names[nr]] = {'name' : name, 'key' : key, 'username' : username} | |
1305 | |
44 | 1306 # update responsibleScientistsList |
35 | 1307 self.setResponsibleScientistsList(checkedScientists) |
39 | 1308 self.updateProjectMembers() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1309 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1310 if fromEdit and (RESPONSE is not None): |
35 | 1311 return self.editBasic() |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1312 |
60 | 1313 if RESPONSE is not None: |
1314 RESPONSE.redirect('manage_main') | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1315 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1316 |
60 | 1317 def getContent(self, field, filter=None): |
1318 """Inhalt des Feldes""" | |
1319 val = getattr(self, field, '') | |
1320 if isinstance(val, list): | |
1321 val = val[0] | |
1322 | |
1323 return val | |
1324 | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1325 |
35 | 1326 def loadNewFile(self, RESPONSE=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1327 """einlesen des neuen files""" |
35 | 1328 fileupload = self.REQUEST['fileupload'] |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1329 if fileupload: |
35 | 1330 file_name = fileupload.filename |
1331 filedata = fileupload.read() | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1332 |
35 | 1333 argv = xmlhelper.proj2hash(filedata) |
1334 # print argv.keys() | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1335 for arg in definedFields: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1336 |
35 | 1337 # print arg,argv[arg],getattr(self,arg) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1338 try: |
35 | 1339 temp = argv[arg][0:] |
1340 # old=getattr(self,arg) | |
1341 setattr(self, arg, temp) | |
1342 # print old,getattr(self,arg) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1343 except: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1344 """nothing""" |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1345 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1346 if RESPONSE is not None: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1347 RESPONSE.redirect('manage_main') |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1348 |
60 | 1349 |
35 | 1350 def tagTheProject(self, RESPONSE=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1351 """TAG""" |
35 | 1352 id = self.getId(); |
1353 tmpl = getattr(self.thesaurus, "main.html") | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1354 if RESPONSE: |
35 | 1355 RESPONSE.redirect("./thesaurus/main.html?project=" + id) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1356 return |
36 | 1357 |
1358 | |
50 | 1359 def hasRelatedPublicationsOldVersion(self): |
52 | 1360 """teste ob es related publications gibt""" |
50 | 1361 ret = True; |
61 | 1362 if (getattr(self, 'WEB_related_pub', '') == ''): |
50 | 1363 ret = False; # nichts im alten feld |
1364 logging.debug("webrel:" + repr(ret)) | |
1365 if (getattr(self, 'WEB_related_pub_copied', False)): | |
1366 ret = False; # alte daten sind schon kopiert worden | |
1367 | |
1368 logging.debug("webrel_copied:" + repr(ret)) | |
1369 publications = self.ZopeFind(self, obj_metatypes=['MPIWGProject_publication']); | |
1370 | |
1371 if(len(publications) > 0): | |
1372 ret = False; # es gibt publicationen in der neuen liste | |
60 | 1373 |
50 | 1374 logging.debug("len(publ)" + repr(ret)) |
1375 | |
1376 return ret; | |
1377 | |
1378 | |
52 | 1379 def copyPublicationsToList(self, RESPONSE=None): |
1380 """copy publications in to list""" | |
60 | 1381 publicationTxt = getattr(self, 'WEB_related_pub', '') |
1382 if isinstance(publicationTxt, list): | |
1383 publicationTxt = publicationTxt[0] | |
52 | 1384 |
1385 pubSplits = publicationTxt.split("<p>") | |
1386 | |
1387 for pubSplit in pubSplits: | |
1388 pubSplit = pubSplit.replace("</p>", "") | |
1389 self.addPublication(pubSplit) | |
1390 | |
1391 setattr(self, "WEB_related_pub_copied", True); | |
1392 | |
1393 if RESPONSE: | |
1394 self.redirect(RESPONSE, 'managePublications') | |
1395 | |
1396 | |
50 | 1397 def hasInlineImage(self): |
1398 """Return the number of inline images in the description.""" | |
1399 text = self.getDescription() | |
1400 cnt = text.count('<p class="picture">') | |
1401 return cnt | |
1402 | |
1403 | |
1404 def copyImageToMargin(self, RESPONSE=None): | |
1405 """copy inline images to marginal images""" | |
1406 # getImages from WEB_project_description | |
1407 description = self.getDescription() | |
1408 | |
1409 text2 = description | |
1410 splitted = text2.split("""<p class="picture">""") | |
1411 | |
1412 imageURLs = [] | |
1413 imageCaptions = [] | |
1414 for split in splitted[1:]: | |
1415 tmp = split.split("</p>") | |
1416 # return repr(splitted[1]) | |
1417 | |
1418 try: | |
1419 imageURLs.append(tmp[0].split("\"")[1].encode('utf-8')) | |
1420 except: | |
1421 | |
1422 try: | |
1423 imageURLs.append(tmp[0].split("src=")[1].split(" ")[0].encode('utf-8')) | |
1424 except: | |
1425 imageURLs.append("") | |
1426 | |
1427 split2 = "</p>".join(tmp[1:]) | |
1428 splitted = split2.split("""<p class="picturetitle">""") | |
1429 if len(splitted) > 1: | |
1430 tmp = splitted[1].split("</p>") | |
1431 imageCaptions.append(tmp[0].encode('utf-8')) | |
1432 | |
1433 else: | |
1434 # keine caption | |
1435 imageCaptions.append("") | |
1436 | |
1437 # eintragen: | |
1438 for imageURL in imageURLs: | |
1439 if not imageURL: | |
1440 # no URL - no image | |
1441 continue | |
1442 | |
1443 filename = imageURL.split("/")[-1] | |
1444 # lege neues images object an, mit leerem bild | |
1445 | |
1446 if filename in self: | |
1447 # existiert das bild schon, dann neuen filenamen | |
1448 filename = "project_image_" + filename | |
1449 if filename in self: | |
1450 # exists too - assume its already converted | |
1451 logging.warn("copyImageToMargin: image %s exists - skipping!"%filename) | |
1452 continue | |
1453 | |
1454 self.addImage(None, imageCaptions[imageURLs.index(imageURL)], filename=filename) | |
1455 # hole die bilddaten aus der url | |
1456 url = self.absolute_url() + "/" + imageURL | |
1457 # url=self.absolute_url()+"/"+filename | |
1458 | |
1459 try: # relative url | |
1460 data = urllib.urlopen(url).read() | |
1461 except: | |
1462 try: # absolute | |
1463 data = urllib.urlopen(self.imageURL).read() | |
1464 except: | |
1465 logging.error("copyImageToMargin: can't open: %s" % url) | |
1466 | |
1467 obj = getattr(self, filename) | |
1468 obj.update_data(data) | |
1469 | |
1470 # clean description | |
1471 logging.debug("copyImageToMargin: description:%s"%repr(description)) | |
1472 dom = ET.fromstring(utf8ify("<html>%s</html>"%description)) | |
1473 for e in dom.findall(".//p[@class='picture']"): | |
1474 # remove contents | |
1475 e.clear() | |
1476 # remove tag | |
1477 e.tag = None | |
1478 | |
1479 for e in dom.findall(".//p[@class='picturetitle']"): | |
1480 # remove contents | |
1481 e.clear() | |
1482 # remove tag | |
1483 e.tag = None | |
1484 | |
1485 # remove html tag | |
1486 dom.tag = None | |
1487 # set as new description | |
1488 description = unicodify(serialize(dom)) | |
1489 logging.debug("copyImageToMargin: new description:%s"%repr(description)) | |
1490 setattr(self, 'WEB_project_description', description) | |
1491 | |
1492 if RESPONSE: | |
1493 self.redirect(RESPONSE, 'manageImages') | |
1494 | |
1495 | |
36 | 1496 def updateProjectMembers(self, updateResponsibleScientistsList=False): |
60 | 1497 """Update project-member table.""" |
1498 # projects are identified by id | |
1499 pid = self.getId() | |
1500 | |
36 | 1501 # clear projects_members table |
60 | 1502 self.executeZSQL("delete from projects_members where project_id = %s", [pid]) |
36 | 1503 |
60 | 1504 for m in self.getResponsibleScientistsList(): |
42 | 1505 memberKey = m.get('key', None) |
36 | 1506 if not memberKey or not isinstance(memberKey, basestring): |
1507 logging.error("updateProjectMembers: not a valid member key: %s" % repr(memberKey)) | |
1508 continue | |
1509 | |
60 | 1510 # fill projects_members table |
1511 self.executeZSQL("insert into projects_members (project_id, member_key) values (%s, %s)", (pid, memberKey)) | |
56 | 1512 |
1513 | |
60 | 1514 |
56 | 1515 |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1516 def manage_addMPIWGProjectForm(self): |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1517 """form for adding the project""" |
35 | 1518 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'addMPIWGProjectForm.zpt')).__of__(self) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1519 return pt() |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1520 |
35 | 1521 def manage_addMPIWGProject(self, id, RESPONSE=None): |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1522 """method to add a project""" |
35 | 1523 # print argv |
1524 fileupload = self.REQUEST.get('fileupload', None) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1525 if fileupload: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1526 |
35 | 1527 file_name = fileupload.filename |
1528 filedata = fileupload.read() | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1529 |
35 | 1530 argv = xmlhelper.proj2hash(filedata) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1531 |
35 | 1532 # print argv |
1533 newObj = MPIWGProject(id, argv) | |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1534 else: |
35 | 1535 newObj = MPIWGProject(id) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1536 |
35 | 1537 self._setObject(id, newObj) |
0
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1538 |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1539 if RESPONSE is not None: |
bca61e893fcc
first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff
changeset
|
1540 RESPONSE.redirect('manage_main') |
27 | 1541 |
1542 | |
33 | 1543 class MPIWGProjectFolder(ZDBInterfaceFolder): |
27 | 1544 """Folder of project objects""" |
1545 | |
35 | 1546 meta_type = "MPIWGProjectFolder" |
1547 security = ClassSecurityInfo() | |
1548 | |
27 | 1549 # cached HashTree with project hierarchy |
1550 _v_projectTree = None | |
53 | 1551 |
34 | 1552 def getProjectTree(self): |
43 | 1553 """Return the project hierarchy tree (and cache it). |
34 | 1554 |
43 | 1555 Returns HashTree instance.""" |
27 | 1556 tree = self._v_projectTree |
1557 if tree is None: | |
43 | 1558 tree = HashTree(keySeparator='.', keyFn=getInt) |
27 | 1559 for p in self.objectValues(spec='MPIWGProject'): |
51 | 1560 # add all projects |
27 | 1561 tree.add(p.getNumber(), p) |
1562 | |
1563 self._v_projectTree = tree | |
35 | 1564 # logging.debug("getProjectTree: tree=%s"%(tree.root.getSubtreeAsText())) |
27 | 1565 |
1566 return tree | |
1567 | |
1568 | |
51 | 1569 def getProjectsAsList(self, start=None, active=1, archived=1): |
43 | 1570 """Return flattened list of projects, starting from start. |
33 | 1571 |
27 | 1572 active = 0 : all projects |
1573 active = 1 : active projects | |
1574 active = 2 : inactive projects | |
1575 archived = 0 : all projects | |
1576 archived = 1 : current projects | |
1577 archived = 2 : archived projects | |
1578 """ | |
35 | 1579 # logging.debug("getProjectsAsList(start=%s,active=%s,archived=%s)"%(repr(start),active,archived)) |
34 | 1580 tree = self.getProjectTree() |
27 | 1581 node = tree.getNode(start) |
1582 if node is None: | |
1583 return [] | |
1584 | |
29 | 1585 pl = node.getSubtreeAsList() |
35 | 1586 # logging.debug("getProjectsAsList: node=(%s,%s) pl=%s"%(node.key,node.value,pl)) |
27 | 1587 # return filtered list |
1588 return [p for p in pl if (p.checkActive(active) and p.checkArchived(archived))] | |
33 | 1589 |
39 | 1590 |
1591 def getProject(self, projectNumber=None): | |
43 | 1592 """Return the matching project""" |
39 | 1593 tree = self.getProjectTree() |
1594 if projectNumber is not None: | |
1595 return tree.get(projectNumber) | |
1596 | |
1597 return None | |
1598 | |
33 | 1599 |
1600 def getProjectsOfMember(self, key, active=1, archived=1): | |
43 | 1601 """Return a list of all projects of a member. |
33 | 1602 |
1603 @param key: member's key | |
1604 active = 0 : all projects | |
1605 active = 1 : active projects | |
1606 active = 2 : inactive projects | |
1607 archived = 0 : all projects | |
1608 archived = 1 : current projects | |
1609 archived = 2 : archived projects | |
1610 """ | |
1611 projects = [] | |
1612 # search project numbers | |
1613 res = self.executeZSQL("select * from projects_members where lower(member_key) = %s", [key.lower()]) | |
77 | 1614 # find projects in folder |
33 | 1615 for r in res: |
77 | 1616 p = self.get(r.project_id, None) |
43 | 1617 # check if active |
33 | 1618 if p is not None and p.checkActive(active) and p.checkArchived(archived): |
1619 projects.append(p) | |
77 | 1620 |
1621 # sort by project number | |
79 | 1622 projects.sort(key=lambda p:[getInt(n) for n in p.getNumber().split('.')]) |
77 | 1623 return projects |
1624 | |
1625 | |
79 | 1626 def getMembersWithProjects(self, onlyActive=True): |
77 | 1627 """Return a list of all members that have projects. |
1628 | |
79 | 1629 @param onlyActive: only active members |
1630 | |
1631 Returns a list of member objects. | |
77 | 1632 """ |
79 | 1633 members = [] |
1634 sf = self.en.getStaffFolder() | |
78 | 1635 res = self.executeZSQL("select distinct member_key from projects_members") |
79 | 1636 if onlyActive: |
1637 for r in res: | |
1638 m = sf.getMember(key=r.member_key) | |
1639 if m is not None and m.isActive(): | |
1640 members.append(m) | |
1641 | |
1642 else: | |
1643 # not only active | |
1644 members = [sf.getMember(key=r.member_key) for r in res] | |
1645 | |
1646 return members | |
27 | 1647 |
1648 | |
51 | 1649 security.declareProtected('View management screens', 'changeProjectTree') |
1650 def changeProjectTree(self, RESPONSE=None): | |
1651 """change the complete tree""" | |
1652 form=self.REQUEST.form | |
1653 onlyArchived=int(form.get("onlyArchived",0)) | |
1654 onlyActive=int(form.get("onlyActive",0)) | |
1655 dep=form.get("dep",None) | |
1656 | |
1657 fields = self.getProjectsAsList(start=dep, archived=onlyArchived, active=onlyActive) | |
1658 | |
1659 logging.info("GOT TREE!----------------------------------------------------") | |
1660 for field in form.keys(): | |
1661 | |
1662 splitted=field.split('_') | |
1663 if (len(splitted)>1) and (splitted[1]=="runningNumber"): | |
1664 #feld hat die Form Nummer_name und runnignNumber | |
1665 nr=int(splitted[0]) # nummer des Datensatzes | |
1666 project = fields[nr] | |
1667 | |
1668 # | |
1669 # change active | |
1670 # | |
1671 if form.has_key('%s_active'%nr): # active flag is set | |
1672 project.setActiveFlag(True) | |
1673 else: | |
1674 project.setActiveFlag(False) | |
1675 | |
1676 # | |
1677 # nummer hat sich geaendert | |
1678 # | |
1679 entryChanged = False; | |
1680 pronum = project.getNumber() | |
1681 formnum = form['%s_number'%nr] | |
1682 | |
1683 if not (pronum == formnum): | |
1684 logging.debug("Changed!Number+++++++++++++++++++++++++++++++++") | |
1685 logging.debug(repr(fields[nr].xdata_05)+" ---> "+ repr(form[str(nr)+'_number'])) | |
1686 entryChanged = True | |
1687 | |
1688 # | |
1689 # completed hat sich geaendert | |
1690 # | |
1691 td = project.transformDate # hole die funktion zum transformieren des datums | |
1692 formstarted = form[str(nr)+'_started'] | |
1693 formcompleted = form[str(nr)+'_completed'] | |
1694 | |
1695 if not (td(project.getCompletedAt()) == td(formcompleted)): | |
1696 logging.info(repr(td(project.getCompletedAt()))+" ---> "+ repr(td(form[str(nr)+'_completed']))) | |
1697 logging.info("Changed!Completed+++++++++++++++++++++++++++++++++") | |
1698 entryChanged = True | |
1699 | |
1700 if not (td(project.getStartedAt()) == td(formstarted)): | |
1701 logging.info(repr(td(project.getStartedAt()))+" ---> "+ repr(td(form[str(nr)+'_started']))) | |
1702 logging.info("Changed!Started+++++++++++++++++++++++++++++++++") | |
1703 entryChanged = True | |
1704 | |
1705 if entryChanged: | |
1706 logging.info("Changed!+++++++++++++++++++++++++++++++++") | |
1707 project.copyObjectToArchive() | |
1708 project.xdata_05 = formnum | |
1709 project.setCompletedAt(formcompleted) | |
1710 project.setStartedAt(formstarted) | |
1711 # reset tree | |
1712 self._v_projectTree = None | |
1713 | |
1714 if RESPONSE is not None: | |
1715 RESPONSE.redirect(self.en.MPIWGrootURL()+'/admin/showTree') | |
1716 | |
52 | 1717 |
60 | 1718 # TODO: this is broken. is this used? |
52 | 1719 def getAllProjectsAndTagsAsCSV(self,archived=1,RESPONSE=None): |
1720 """alle projekte auch die nicht getaggten""" | |
1721 retList=[] | |
1722 headers=['projectId','sortingNumber','projectName','scholars','startedAt','completedAt','lastChangeThesaurusAt','lastChangeProjectAt','projectCreatedAt','persons','places','objects'] | |
1723 headers.extend(list(self.thesaurus.tags.keys())) | |
1724 retList.append("\t".join(headers)) | |
1725 if not hasattr(self,'thesaurus'): | |
1726 return "NON thesaurus (there have to be a MPIWGthesaurus object, with object ID thesaurus)" | |
1727 | |
1728 projectTags = self.thesaurus.getProjectsAndTags() | |
1729 for project in self.getProjectFields('WEB_title_or_short'): | |
1730 proj = project[0] | |
1731 p_name = project[1] | |
1732 retProj=[] | |
1733 #if (not proj.isArchivedProject() and archived==1) or (proj.isArchivedProject() and archived==2): | |
1734 retProj.append(self.utf8ify(proj.getId())) | |
1735 retProj.append(self.utf8ify(proj.getContent('xdata_05'))) | |
1736 retProj.append(self.utf8ify(p_name)) | |
1737 retProj.append(self.utf8ify(proj.getContent('xdata_01'))) | |
1738 retProj.append(self.utf8ify(proj.getStartedAt())) | |
1739 retProj.append(self.utf8ify(proj.getCompletedAt())) | |
1740 changeDate=self.thesaurus.lastChangeInThesaurus.get(proj.getId(),'') | |
1741 n = re.sub("[:\- ]","",str(changeDate)) | |
1742 retProj.append(n) | |
1743 retProj.append(self.utf8ify(getattr(proj,'creationTime','20050101000000'))) | |
1744 retProj.append("")#TODO: project created at | |
1745 retProj.append(";".join([person[1] for person in self.thesaurus.getPersonsFromProject(proj.getId())])) | |
1746 retProj.append(";".join([person[1] for person in self.thesaurus.getHistoricalPlacesFromProject(proj.getId())])) | |
1747 retProj.append(";".join([person[1] for person in self.thesaurus.getObjectsFromProject(proj.getId())])) | |
1748 retProj+=self.thesaurus.getTags(proj.getId(),projectTags) | |
1749 retList.append("\t".join(retProj)) | |
1750 | |
1751 if RESPONSE: | |
1752 | |
1753 RESPONSE.setHeader('Content-Disposition','attachment; filename="ProjectsAndTags.tsv"') | |
1754 RESPONSE.setHeader('Content-Type', "application/octet-stream") | |
1755 | |
1756 return "\n".join(retList); | |
1757 | |
51 | 1758 |
35 | 1759 security.declareProtected('View management screens', 'updateAllProjectMembers') |
33 | 1760 def updateAllProjectMembers(self, updateResponsibleScientistsList=False): |
43 | 1761 """Re-create responsibleScientistsLists and projects_members table from all current projects.""" |
33 | 1762 # empty table |
1763 self.executeZSQL('truncate table projects_members') | |
1764 cnt = 0 | |
1765 # go through all projects | |
1766 for p in self.objectValues(spec='MPIWGProject'): | |
1767 cnt += 1 | |
1768 memberlist = [] | |
35 | 1769 logging.debug("updateAllProjectMembers: updating project %s" % p) |
36 | 1770 p.updateProjectMembers(updateResponsibleScientistsList=updateResponsibleScientistsList) |
33 | 1771 |
35 | 1772 return "updated %s projects!" % cnt |
33 | 1773 |
40 | 1774 |
39 | 1775 security.declareProtected('View management screens', 'updateAllProjects') |
50 | 1776 def updateAllProjects(self, updateResponsibleScientistsList=False, RESPONSE=None): |
43 | 1777 """Patch all current projects for legacy problems.""" |
39 | 1778 cnt = 0 |
50 | 1779 fulllog = "" |
39 | 1780 # go through all projects |
44 | 1781 for (id, project) in self.ZopeFind(self, obj_metatypes=['MPIWGProject'], search_sub=1): |
50 | 1782 log = "" |
39 | 1783 cnt += 1 |
1784 # | |
1785 # hasRelatedPublicationsOldVersion | |
1786 # | |
1787 if project.hasRelatedPublicationsOldVersion(): | |
49 | 1788 log += "%s: update relatedPublicationsOldVersion!\n"%project.getId() |
39 | 1789 logging.debug("updateAllProjects(%s): update relatedPublicationsOldVersion!"%project.getId()) |
1790 project.copyPublicationsToList() | |
1791 | |
1792 # | |
60 | 1793 # create responsibleScientistsList automatically |
39 | 1794 # |
60 | 1795 if updateResponsibleScientistsList: |
39 | 1796 newScientists = {} |
65 | 1797 names = project.identifyNames(project.getResponsibleScientists()) |
60 | 1798 for name in names: |
1799 logging.debug("updateAllProjectMembers: name=%s" % repr(name)) | |
1800 members = names[name] | |
1801 if len(members) > 0: | |
1802 # take the first matching name | |
1803 newScientists[name] = {'name': name, 'key' : members[0].key, 'username' : re.sub('@mpiwg-berlin\.mpg\.de', '', members[0].e_mail)} | |
39 | 1804 |
1805 project.setResponsibleScientistsList(newScientists) | |
60 | 1806 |
1807 else: | |
1808 # | |
1809 # old format responsibleScientistsList | |
1810 # | |
1811 memberlist = project.getResponsibleScientistsList() | |
1812 if len(memberlist) > 0 and isinstance(memberlist[0], tuple): | |
1813 log += "%s: updating memberlist!\n"%project.getId() | |
1814 logging.debug("updateAllProjects(%s): updating memberlist" % project.getId()) | |
1815 newScientists = {} | |
1816 for m in memberlist: | |
1817 name = m[0] | |
1818 key = m[1] | |
1819 username = None | |
1820 if key: | |
1821 if isinstance(key, list): | |
1822 key = key[0] | |
1823 | |
1824 # get username from db | |
80 | 1825 member = self.en.getMPIWGRoot().getStaffFolder().getMember(key=key) |
60 | 1826 if member is not None: |
1827 username = member.getUsername() | |
1828 | |
1829 newScientists[name] = {'name': name, 'key' : key, 'username' : username} | |
1830 | |
1831 # set new list | |
1832 project.setResponsibleScientistsList(newScientists) | |
39 | 1833 |
1834 # | |
49 | 1835 # old inline images |
1836 # | |
1837 if project.hasInlineImage(): | |
1838 log += "%s: has inlineImage!\n"%project.getId() | |
1839 logging.debug("updateAllProjects(%s): has inlineImage!"%project.getId()) | |
1840 try: | |
1841 project.copyImageToMargin() | |
1842 except Exception, e: | |
1843 log += "%s: ERROR in copyImageToMargin!\n"%project.getId() | |
1844 logging.debug("updateAllProjects(%s): ERROR in copyImageToMargin: %s"%(project.getId(), e)) | |
1845 | |
1846 | |
1847 # | |
39 | 1848 # remove old attributes |
1849 # | |
1850 if hasattr(project, 'definedFields'): | |
49 | 1851 log += "%s: has definedFields!\n"%project.getId() |
39 | 1852 logging.debug("updateAllProjects(%s): has definedFields!"%project.getId()) |
1853 delattr(project, 'definedFields') | |
61 | 1854 |
45 | 1855 # |
61 | 1856 # update related publications |
45 | 1857 # |
61 | 1858 for pub in project.getPublicationList(): |
62 | 1859 if not pub.text: |
1860 msg = "%s: publication has no text: %s!\n"%(project.getId(), pub) | |
1861 log += msg | |
1862 logging.warn(msg) | |
1863 if not pub.link: | |
1864 msg = "%s: publication has no link either! Deleting: %s!\n"%(project.getId(), pub) | |
1865 log += msg | |
1866 logging.error(msg) | |
1867 project.deletePublication(pub.getId()) | |
1868 | |
1869 else: | |
1870 # hasLinkToBookPage updates the bookId | |
1871 pub.hasLinkToBookPage() | |
61 | 1872 |
50 | 1873 # |
1874 # unicodify | |
1875 # | |
1876 for field in ('WEB_title', 'xdata_01', 'xdata_07', 'xdata_08', 'xdata_11', 'xdata_12', 'xdata_13', | |
1877 'WEB_project_description', 'WEB_related_pub'): | |
1878 text = getattr(project, field, None) | |
1879 if isinstance(text, str): | |
1880 log += "%s: has non-unicode field %s\n"%(project.getId(), field) | |
1881 logging.debug("updateAllProjects(%s): has has non-unicode field %s\n"%(project.getId(), field)) | |
1882 setattr(project, field, unicodify(text)) | |
1883 | |
1884 fulllog += log | |
1885 if RESPONSE is not None: | |
1886 RESPONSE.write(log) | |
62 | 1887 |
50 | 1888 log += "\n DONE! updated %s projects!" % cnt |
1889 fulllog += log | |
1890 if RESPONSE is not None: | |
1891 RESPONSE.write(log) | |
1892 RESPONSE.flush() | |
1893 else: | |
1894 return fulllog | |
39 | 1895 |
33 | 1896 |
27 | 1897 def manage_addMPIWGProjectFolderForm(self): |
29 | 1898 """form for adding a MPIWGProjectFolder""" |
27 | 1899 pt = PageTemplateFile('zpt/project/manage_add_MPIWGProjectFolder', globals()).__of__(self) |
1900 return pt() | |
1901 | |
35 | 1902 def manage_addMPIWGProjectFolder(self, id, title, RESPONSE=None): |
29 | 1903 """add a MPIWGProjectFolder""" |
35 | 1904 newObj = MPIWGProjectFolder(id, title) |
27 | 1905 |
35 | 1906 self._setObject(id, newObj) |
27 | 1907 |
1908 if RESPONSE is not None: | |
1909 RESPONSE.redirect('manage_main') | |
1910 |