annotate MPIWGProjects.py @ 36:dbe037d2f574

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