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