annotate MPIWGProjects.py @ 45:5c6ad316e1ce

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