annotate MPIWGProjects.py @ 49:e40ff9829108

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