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