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