annotate MPIWGProjects.py @ 51:d456fe185649

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