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