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