annotate MPIWGProjects.py @ 80:b1893c4c9d2c

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