annotate MPIWGProjects.py @ 284:1a103b073c72 default tip

make favicon url host and schema relative.
author casties
date Thu, 25 Jun 2015 17:44:57 +0200
parents c886c0cb3455
children
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
204
670b3507509d fix breadcrumbs for features.
casties
parents: 191
diff changeset
13 from Acquisition import aq_parent
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
14 from Globals import package_home
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
15 import urllib
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
16 import re
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
17 import os
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
231
649f74b167e6 extract getPlaintext to SrvTxtUtils. add character count to project description editor.
casties
parents: 229
diff changeset
25 from SrvTxtUtils import getInt, unicodify, utf8ify, serialize, refreshingImageFileIndexHtml, shortenString, getPlaintext
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
26 from Products.ZDBInterface.ZDBInterfaceFolder import ZDBInterfaceFolder
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
27 from Products.MPIWGManager import MPIWGIcsManager
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
28
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
29 import xmlhelper # Methoden zur Verwaltung der projekt xml
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
30 from HashTree import HashTree
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
31 import MPIWGHelper
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
32
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
33 # TODO: better names for the fields
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
34 fieldLabels = {'WEB_title':'WEB_Title',
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
35 'xdata_01':'Responsible Scientists',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
36 'xdata_02':'Department',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
37 'xdata_03':'Historical Persons',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
38 'xdata_04':'Time period',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
39 'xdata_05':'Sorting number',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
40 'xdata_06':'Keywords',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
41 'xdata_07':'Short title',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
42 'xdata_08':'Other involved scholars' ,
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
43 'xdata_09':'Disciplines',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
44 'xdata_10':'Themes',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
45 'xdata_11':'Object Digitallibrary',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
46 'xdata_12':'Cooperation partners',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
47 'xdata_13':'Funding institutions',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
48 'WEB_project_header':'WEB_project_header',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
49 'WEB_project_description':'WEB_project_description',
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
50 'WEB_related_pub':'WEB_related_pub'}
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
51
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
52 definedFields = fieldLabels.keys() # TODO: should this be sorted?
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
53
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
54 editableFields = ('xdata_07', 'xdata_01', 'xdata_05', 'xdata_08', 'xdata_12', 'xdata_13')
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
55
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
56 # 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
57 # Sonst funktionieren die alten Webseiten nicht mehr.
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
58
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
59 import MPIWGRoot
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
60 import MPIWGLink
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
61 import MPIWGTemplate
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
62
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
63 class MPIWGRoot(MPIWGRoot.MPIWGRoot):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
64 """depricated"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
65
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
66 class MPIWGLink(MPIWGLink.MPIWGLink):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
67 """depricated"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
68
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
69 class MPIWGTemplate(MPIWGTemplate.MPIWGTemplate):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
70 """depricated"""
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
71
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
72
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
73 class MPIWGProject_publication(Folder):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
74 """publications object fuer project"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
75
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
76 meta_type = "MPIWGProject_publication"
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
77
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
78 text = None
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
79 link = None
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
80 bookId = None
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
81
65
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
82 # templates
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
83 edit = PageTemplateFile('zpt/project/related_publication/edit_basic', globals())
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
84
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
85
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
86 redirect = MPIWGHelper.redirect
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
87
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
88
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
89 def hasLinkToBookPage(self):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
90 """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
91 logging.debug("MPIWGProject_publication - begin hasLinkToBookPage")
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
92 if not self.link:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
93 return False # es gibt keinen link
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
94
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
95 paths = self.link.split('/')
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
96 if len(paths) > 2:
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
97 # book page should be in folder books
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
98 bookid = None
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
99 try:
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
100 idx = paths.index('books')
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
101 bookid = paths[idx + 1]
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
102 book = self.en.books[bookid]
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
103 self.bookId = bookid
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
104 return True
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
105
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
106 except:
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
107 logging.debug("hasLinkToBookPage: not a book page link=%s"%self.link)
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
108
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
109 self.bookId = None
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
110 return False
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
111
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
112
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
113 def getBookId(self):
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
114 """Return the book page id."""
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
115 return self.bookId
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
116
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
117
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
118 getUrl = MPIWGHelper.getUrl
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
119
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
120
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
121 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
122 """edit a publication"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
123
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
124 if (not text) and (not description):
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
125 pt = self.edit
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
126 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
127
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
128 if text:
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
129 self.text = text
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
130
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
131 if description:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
132 self.description = description
0
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 link:
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
135 self.link = link
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
136 self.hasLinkToBookPage()
0
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 RESPONSE:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
139 self.redirect(RESPONSE, "../managePublications")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
140
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
141
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
142 class MPIWGProject_relatedProject(SimpleItem):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
143 """publications object fuer project"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
144
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
145 meta_type = "MPIWGProject_relatedProject"
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
146
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
147 objid = None
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
148 projectLabel = None
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
149
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
150 # templates
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
151 edit = PageTemplateFile('zpt/project/related_project/edit_basic', globals())
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
152
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
153
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
154 redirect = MPIWGHelper.redirect
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
155
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 def getProjectId(self):
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
158 """Return the related project id."""
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
159 return self.objid
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
160
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
161
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
162 def getProject(self):
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
163 """Return the related project object."""
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
164 return getattr(self.projects, self.objid, None)
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
165
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
166
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
167 def getProjectTitle(self):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
168 """Return the title of the related project."""
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
169 return getattr(self, 'projectWEB_title', None)
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
170
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
171
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
172 def getProjectLabel(self):
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
173 """Return the label of the related project."""
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
174 label = getattr(self, 'projectLabel', None)
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
175 if not label:
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
176 proj = self.getProject()
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
177 if proj is not None:
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
178 label = proj.getLabel()
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
179
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
180 self.projectLabel = label
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
181
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
182 return label
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
183
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
184
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
185 getUrl = MPIWGHelper.getUrl
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
186
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
187
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
188 def editRelatedProject(self, link=None, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
189 """edit a publication"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
190
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
191 if (not link):
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
192 pt = self.editDescription
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
193 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
194
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
195 # hole die id des projektes
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
196 splitted = link.split("/")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
197
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
198 # teste ob es das project gibt
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
199 if len(splitted) < 1:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
200 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
201
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
202 objid = splitted[-1]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
203 object = getattr(self.projects, objid, None)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
204
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
205 if object is None:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
206 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
207
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
208 self.orginallink = link[0:]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
209 self.objid = objid[0:]
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
210
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
211 self.projectWEB_title = object.getProjectTitle()
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
212 self.projectLabel = object.getLabel()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
213
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
214 self.enabled = True;
0
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 if RESPONSE:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
217 self.redirect(RESPONSE, "../manageRelatedProjects")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
218
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
219
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
220 class MPIWGProject_image(Image):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
221 """Images for Projects"""
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 meta_type = "MPIWGProject_image"
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
224
65
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
225 # templates
96
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
226 oldShowImage = PageTemplateFile('zpt/project/image/projectImageView', globals())
65
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
227 editForm = PageTemplateFile('zpt/project/image/edit_basic', globals())
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
228
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
229 getUrl = MPIWGHelper.getUrl
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
230
96
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
231
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
232 def getCaption(self):
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
233 """Return the image caption."""
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
234 return getattr(self, 'caption', None)
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
235
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
236
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
237 def getLink(self):
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
238 """Return the image link."""
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
239 return getattr(self, 'link', None)
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
240
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
241
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
242 def editImage(self, file=None, caption=None, link=None, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
243 """edit the Image"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
244 if (not file) and (not caption):
65
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
245 pt = self.editForm
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
246 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
247
96
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
248 if file and (not file.filename.strip() == ""):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
249 self.manage_upload(file)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
250
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
251 if caption:
96
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
252 if isinstance(caption, list):
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
253 caption = caption[0]
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
254
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
255 self.caption = caption
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
256
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
257 if link:
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
258 self.link = link
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
259
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
260 if RESPONSE:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
261 self.redirect(RESPONSE, "../manageImages")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
262
24
6a4996805505 more work on projects.
casties
parents: 22
diff changeset
263
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
264 class MPIWGProject_InfoBlock(SimpleItem):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
265 """publications object fuer project"""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
266
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
267 meta_type = "MPIWGProject_InfoBlock"
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
268
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
269 # templates
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
270 edit = PageTemplateFile('zpt/project/infoblock/edit_items', globals())
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
271
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
272
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
273 redirect = MPIWGHelper.redirect
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
274
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
275
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
276 def __init__(self, id, title=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
277 """Create info block."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
278 self.id = id
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
279 self.title = title
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
280 self.place = 0
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
281 self.items = []
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
282
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
283
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
284 def getTitle(self):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
285 """Return the title."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
286 return self.title
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
287
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
288
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
289 def getItems(self):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
290 """Return the list of items."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
291 return self.items
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
292
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
293
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
294 def setItems(self, items):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
295 """Set the list of items."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
296 self.items = items
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
297 self._p_changed = True
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
298
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
299
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
300 def addItem(self, item=None, text=None, link=None, RESPONSE=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
301 """Add an item to the InfoBox"""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
302 if item is None:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
303 item = {'text': text, 'link': link}
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
304
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
305 self.items.append(item)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
306 self._p_changed = True
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
307 if RESPONSE is not None:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
308 self.redirect(RESPONSE, 'edit')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
309
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
310
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
311 def deleteItem(self, idx, RESPONSE=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
312 """Delete an item from the info block."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
313 try:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
314 del self.items[int(idx)]
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
315 self._p_changed = True
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
316 except:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
317 logging.error("InfoBlock deleteItem: error deleting item %s!"%idx)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
318
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
319 if RESPONSE is not None:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
320 self.redirect(RESPONSE, 'edit')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
321
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
322
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
323 def moveItem(self, idx, op, RESPONSE=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
324 """Move items up or down the list."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
325 try:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
326 idx = int(idx)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
327 if op == 'up':
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
328 if idx > 0:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
329 self.items[idx-1], self.items[idx] = self.items[idx], self.items[idx-1]
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
330 elif op == 'down':
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
331 if idx < len(self.items)-1:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
332 self.items[idx], self.items[idx+1] = self.items[idx+1], self.items[idx]
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
333
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
334 self._p_changed = True
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
335 except:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
336 logging.error("InfoBlock moveItem: error moving item at %s!"%idx)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
337
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
338 if RESPONSE is not None:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
339 self.redirect(RESPONSE, 'edit')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
340
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
341
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
342 def editItems(self, REQUEST, RESPONSE=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
343 """Change items from request form."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
344 form = REQUEST.form
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
345 for k in form:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
346 t, n = k.split('_')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
347 if t in ['text', 'link']:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
348 try:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
349 logging.debug("editItems: change[%s].%s = %s"%(n,t,repr(form[k])))
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
350 self.items[int(n)][t] = form[k]
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
351 except:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
352 logging.error("InfoBlock editItems: error changing item %s!"%k)
265
9adba5461dfa 167: Title of projects' info blocks can't be changed
casties
parents: 264
diff changeset
353
9adba5461dfa 167: Title of projects' info blocks can't be changed
casties
parents: 264
diff changeset
354 if k == 'block_title':
9adba5461dfa 167: Title of projects' info blocks can't be changed
casties
parents: 264
diff changeset
355 self.title = form[k]
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
356
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
357 self._p_changed = True
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
358 if RESPONSE is not None:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
359 self.redirect(RESPONSE, 'edit')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
360
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
361
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
362
65
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
363 class MPIWGProject(Folder):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
364 """Class for Projects"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
365
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
366 security = ClassSecurityInfo()
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
367 meta_type = 'MPIWGProject'
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
368
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
369 manage_options = Folder.manage_options + (
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
370 {'label':'Load New File', 'action':'loadNewFileForm'},
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
371 {'label':'Edit', 'action':'editDescription'},
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
372 )
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
373 # {'label':'Edit ProjectInfo','action':'editMPIWGProjectForm'},
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
374 # {'label':'Edit BasisInfo','action':'editMPIWGBasisForm'},
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
375 # {'label':'Edit Publications','action':'editMPIWGRelatedPublicationsForm'},
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
376 # {'label':'Edit Themes & Disciplines','action':'editMPIWGDisciplinesThemesForm'},
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
377 # {'label':'Versionmanager','action':'versionManageForm'},
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
378
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
379 #
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
380 # templates
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
381 #
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
382 project_html = PageTemplateFile('zpt/project/project_index_html', globals())
276
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
383 project_xml = PageTemplateFile('zpt/project/project_index_xml', globals())
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
384 # edit templates
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
385 edit_css = ImageFile('css/edit.css', globals())
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
386 # make css refreshable for development
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
387 edit_css.index_html = refreshingImageFileIndexHtml
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
388 # user-accessible editing templates
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
389 edit_template = PageTemplateFile('zpt/project/edit_template', globals())
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
390 security.declareProtected('View management screens', 'editBasic')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
391 editBasic = PageTemplateFile('zpt/project/edit_basic', globals())
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
392 security.declareProtected('View management screens', 'editDescription')
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
393 editDescription = PageTemplateFile('zpt/project/edit_description', globals())
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
394 security.declareProtected('View management screens', 'editRelatedProjectsForm')
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
395 editRelatedProjectsForm = PageTemplateFile('zpt/project/edit_related_projects', globals())
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
396 editRelatedProjectsError = PageTemplateFile('zpt/project/edit_related_projects_error', globals())
95
1b8be917a167 fix bug with renamed method.
casties
parents: 90
diff changeset
397 security.declareProtected('View management screens', 'editImagesForm')
1b8be917a167 fix bug with renamed method.
casties
parents: 90
diff changeset
398 editImagesForm = PageTemplateFile('zpt/project/edit_images', globals())
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
399 security.declareProtected('View management screens', 'editPublicationsForm')
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
400 editPublicationsForm = PageTemplateFile('zpt/project/edit_publications', globals())
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
401 security.declareProtected('View management screens', 'editInfoBlocksForm')
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
402 editInfoBlocksForm = PageTemplateFile('zpt/project/edit_infoblocks', globals())
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
403 security.declareProtected('View management screens', 'editAdditionalPublicationsForm')
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
404 editAdditionalPublicationsForm = PageTemplateFile('zpt/project/pubman/change_publications', globals())
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
405 security.declareProtected('View management screens', 'editAddAdditionalPublications')
62
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
406 editAddAdditionalPublications = PageTemplateFile('zpt/project/pubman/add_publications', globals())
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
407 security.declareProtected('View management screens', 'edit')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
408 edit = editDescription
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
409 security.declareProtected('View management screens', 'editCalendarForm')
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
410 editCalendarForm = PageTemplateFile('zpt/project/edit_calendar', globals())
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
411 # management templates
90
c940af028112 add styles and meta-tags for search.
casties
parents: 81
diff changeset
412 security.declareProtected('View management screens', 'loadNewFileForm')
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
413 loadNewFileForm = PageTemplateFile('zpt/project/manage_newfile', globals())
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
414 description_only_html = PageTemplateFile('zpt/project/description_only_html', globals())
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
415 # additional pages
74
e424b68244c8 better template for additional project publications.
casties
parents: 65
diff changeset
416 additional_publications_html = PageTemplateFile('zpt/project/pubman/show_publications', globals())
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
417
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
418
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
419 def __init__(self, id, argv=None):
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
420 """initiere classe"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
421 self.creationTime = time.strftime("%Y%m%d%H%M%S", time.localtime())[0:]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
422 self.id = id
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
423 self.title = id
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
424 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
425 self.responsibleScientistsList = [] # enthaelt die Lister der verantwortlichen Wissenschaftler in der Form (NAME, KEY), key ist "" flass Wissenschaftler nicht an unserem Haus
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
426 self.projectThumb = None
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
427
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
428 if argv:
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
429 for arg in definedFields:
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
430 try:
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
431 setattr(self, arg, argv[arg])
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
432 except:
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
433 setattr(self, arg, "")
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
434 else:
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
435 for arg in definedFields:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
436 setattr(self, arg, '')
22
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
437
5ed0b0c21fe5 started to clean up MPIWGProject.
casties
parents: 0
diff changeset
438
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
439 def index_html(self):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
440 """default html representation"""
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
441 # TODO: do we need to do date-stuff?
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
442 # get template
74
e424b68244c8 better template for additional project publications.
casties
parents: 65
diff changeset
443 pt = self.project_html
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
444 # render template
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
445 return pt()
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
446
276
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
447 def index_xml(self):
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
448 """default xml representation"""
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
449 # get template
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
450 pt = self.project_xml
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
451 # render template
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
452 return pt()
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
453
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
454
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
455 redirect = MPIWGHelper.redirect
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
456
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
457
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
458 def getDefinedFields(self):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
459 """show all defined fields."""
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
460 return definedFields
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
461
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
462
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
463 def getFieldLabels(self):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
464 """Return the field labels dict."""
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
465 return fieldLabels
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
466
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
467
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
468 def getEditableFields(self):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
469 """giveListofDatafields"""
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
470 return editableFields
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
471
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
472
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
473 def getNumber(self):
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
474 """returns sorting number"""
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
475 n = getattr(self, 'xdata_05', None)
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
476 if isinstance(n, list):
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
477 # compat with old lists
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
478 return n[0]
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
479 else:
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
480 return n
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
481
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
482
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
483 def getProjectTitle(self, forSorting=False):
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
484 """returns the project title"""
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
485 t = getattr(self, 'WEB_title', None)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
486 if isinstance(t, list):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
487 # compat with old lists
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
488 t = t[0]
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
489
162
47392bf3fcba clean ups and fixes
casties
parents: 156
diff changeset
490 if forSorting and t is not None and len(t) > 0:
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
491 # remove stopwords and signs for sorting
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
492 if t.lower().startswith('a '):
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
493 t = t[2:]
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
494 elif isinstance(t, unicode) and unicodedata.category(t[0])[0] != 'L':
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
495 t = t[1:]
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
496
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
497 return t
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
498
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
499
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
500 def getLabel(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
501 """returns label (or title) of this project"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
502 l = getattr(self, 'xdata_07', None)
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
503 if isinstance(l, list):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
504 # compat with old lists
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
505 l = l[0]
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
506
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
507 if l:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
508 return l
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
509 else:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
510 return self.getProjectTitle()
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
511
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
512
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
513 def getResponsibleScientists(self):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
514 """returns the responsible scientists as string"""
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
515 t = getattr(self, 'xdata_01', None)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
516 if isinstance(t, list):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
517 # compat with old lists
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
518 return t[0]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
519 else:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
520 return t
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
521
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
522
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
523 def getResponsibleScientistsList(self):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
524 """returns a list with the responsible scientists as dicts with name, key, and shortname"""
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
525 return getattr(self, 'responsibleScientistsList', [])
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
526
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
527
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
528 def setResponsibleScientistsList(self, nameDict):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
529 """sets the responsibleScientistsList from nameDict.
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
530 List will be ordered like the responsible scientists field."""
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
531 names = self.getResponsibleScientists()
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
532 if names.find(";") > -1: # rate Trenner ist ;
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
533 nameList = names.split(";")
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
534 else:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
535 nameList = names.split(",")
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
536
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
537 scientistsList = []
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
538 for name in nameList:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
539 name = unicodify(name.strip())
123
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
540 if not name:
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
541 continue
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
542
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
543 logging.debug("setResponsibleScientistsList: name=%s"%repr(name))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
544 if name in nameDict:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
545 # found in data
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
546 data = nameDict[name]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
547 scientistsList.append({'name': name, 'key': data['key'], 'username': data['username']})
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
548 else:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
549 scientistsList.append({'name': name})
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
550
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
551 logging.debug("setResponsibleScientistsList: nameDict=%s new list=%s"%(repr(nameDict),repr(scientistsList)))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
552 self.responsibleScientistsList = scientistsList
123
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
553 # force update of the Properties list in the ZopeDB
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
554 self._p_changed = 1
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
555
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
556
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
557 def getInvolvedScholars(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
558 """returns the other involved scholars"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
559 t = getattr(self, 'xdata_08', None)
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
560 if isinstance(t, list):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
561 # compat with old lists
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
562 return t[0]
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
563 else:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
564 return t
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
565
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
566
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
567 def getCooperationPartners(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
568 """returns the cooperation partners"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
569 t = getattr(self, 'xdata_12', None)
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
570 if isinstance(t, list):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
571 # compat with old lists
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
572 return t[0]
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
573 else:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
574 return t
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
575
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
576
257
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
577 def getProjectType(self):
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
578 """returns the type of project"""
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
579 t = getattr(self, 'projectType', None)
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
580 return t
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
581
264
0cfe34c454ff setter for project type. change default visible project type.
casties
parents: 262
diff changeset
582 def setProjectType(self, s):
0cfe34c454ff setter for project type. change default visible project type.
casties
parents: 262
diff changeset
583 """set the type of project"""
0cfe34c454ff setter for project type. change default visible project type.
casties
parents: 262
diff changeset
584 self.projectType = s
0cfe34c454ff setter for project type. change default visible project type.
casties
parents: 262
diff changeset
585
257
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
586
96
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
587 def getMPIWGProject(self):
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
588 """Return this project for acquisition."""
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
589 return self
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
590
2dd8e3be4a8e add project image link. fix edit image template bug.
casties
parents: 95
diff changeset
591
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
592 def getMPIWGProjectUrl(self):
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
593 """Return this project for acquisition."""
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
594 return self.absolute_url()
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
595
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
596
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
597 getUrl = MPIWGHelper.getUrl
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
598
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
599
65
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
600 def getThumbUrl(self, default=None):
24
6a4996805505 more work on projects.
casties
parents: 22
diff changeset
601 """returns the URL of the project thumbnail image"""
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
602 thumb = getattr(self, 'projectThumb', None)
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
603 if thumb is None:
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
604 # get thumb from list (thumb is last image)
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
605 imgs = self.getImageList()
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
606 if len(imgs) > 0:
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
607 thumb = imgs[-1]
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
608 self.projectThumb = thumb
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
609
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
610 if thumb is None:
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
611 return default
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
612
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
613 return thumb.absolute_url()
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
614
24
6a4996805505 more work on projects.
casties
parents: 22
diff changeset
615
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
616 def getDepartment(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
617 """returns the department of this project"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
618 num = self.getNumber()
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
619 pp = num.find('.')
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
620 if pp > 0:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
621 num = num[:pp]
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
622
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
623 return self.en.getMPIWGRoot().getDepartment(projectNumber=num)
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
624
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
625
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
626 def getDepartmentId(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
627 """returns the id of the department of this project"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
628 dep = self.getDepartment()
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
629 if dep is not None:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
630 return dep.getId()
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
631
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
632 return None
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
633
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
634
102
bde0929d34fb function for excerpts of project descriptions.
casties
parents: 99
diff changeset
635 def getDescription(self, filter=None, length=0):
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
636 """returns the project description"""
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
637 text = getattr(self, 'WEB_project_description', None)
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
638 if isinstance(text, list):
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
639 # compat with old lists
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
640 text = text[0]
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
641
102
bde0929d34fb function for excerpts of project descriptions.
casties
parents: 99
diff changeset
642 if filter == 'plaintext':
bde0929d34fb function for excerpts of project descriptions.
casties
parents: 99
diff changeset
643 # filter out any tags, keep only text
231
649f74b167e6 extract getPlaintext to SrvTxtUtils. add character count to project description editor.
casties
parents: 229
diff changeset
644 text = getPlaintext(text, length=length, wordwrap=True, ignoretags=['style'])
102
bde0929d34fb function for excerpts of project descriptions.
casties
parents: 99
diff changeset
645
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
646 return text
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
647
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
648
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
649 def getSuperProjects(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
650 """returns a list of ancestor projects to the root"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
651 tree = self.getProjectTree()
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
652 return tree.getAncestorsOf(self.getNumber())
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
653
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
654
262
e7b3c7ab9eb5 getSubProjects takes archived (=1) too.
casties
parents: 260
diff changeset
655 def getSubProjects(self, active=1, archived=1, filter=None):
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
656 """returns a list of child projects"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
657 tree = self.getProjectTree()
262
e7b3c7ab9eb5 getSubProjects takes archived (=1) too.
casties
parents: 260
diff changeset
658 return [p for p in tree.getChildrenOf(self.getNumber()) if (filter is None or filter(p)) and p.checkActive(active) and p.checkArchived(archived)]
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
659
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
660
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
661 def getRelatedDigitalSources(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
662 """returns the related digital sources"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
663 t = getattr(self, 'xdata_11', None)
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
664 if isinstance(t, list):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
665 # compat with old lists
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
666 return t[0]
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
667 else:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
668 return t
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
669
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
670
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
671 def getFundingInstitutions(self):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
672 """returns the funding institutions"""
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
673 t = getattr(self, 'xdata_13', None)
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
674 if isinstance(t, list):
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
675 # compat with old lists
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
676 return t[0]
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
677 else:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
678 return t
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
679
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
680
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
681 def getProjectCalendar(self):
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
682 """Return the project calendar object (MPIWGIcsManager)"""
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
683 return self.get('calendar', None)
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
684
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
685
250
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
686 def editProjectCalendar(self, url=None, only_upcoming=None, show_num=None, cat_match=None, RESPONSE=None):
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
687 """Change the project calendar."""
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
688 cal = self.get('calendar', None)
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
689 if url:
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
690 if cal is None:
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
691 # create calendar
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
692 cal = MPIWGIcsManager.MPIWGIcsManager('calendar', 'Project Calendar', url, defaultProps=MPIWGIcsManager.calendar_props)
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
693 self['calendar'] = cal
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
694
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
695 else:
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
696 # calendar exists
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
697 if cal.url != url:
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
698 # remove and re-create
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
699 del self['calendar']
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
700 cal = MPIWGIcsManager.MPIWGIcsManager('calendar', 'Project Calendar', url, defaultProps=MPIWGIcsManager.calendar_props)
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
701 self['calendar'] = cal
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
702
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
703 # show only upcoming
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
704 cal.setFlag('only_upcoming', (only_upcoming == 'yes'))
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
705 # number of events
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
706 cal.setFlag('show_num', getInt(show_num, 5))
250
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
707 # match (project number) in event category
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
708 if cat_match:
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
709 cal.setFlag('cat_match', unicode(cat_match))
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
710 else:
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
711 cal.setFlag('cat_match', None)
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
712
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
713 elif cal is not None:
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
714 # no url - remove calendar
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
715 del self['calendar']
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
716
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
717 if RESPONSE is not None:
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
718 self.redirect(RESPONSE, 'editCalendarForm')
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
719
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
720
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
721
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
722
250
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
723 def getProjectNumberMatcher(self, num, getter=None):
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
724 """Return a function that matches a project number pattern.
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
725
250
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
726 Matches exactly except when num ends with '*'. Uses function getter on arguments.
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
727 """
250
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
728 if num is None:
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
729 return None
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
730
250
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
731 if num.endswith('*'):
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
732 rs = re.sub(r'\.', r'\.', num[:-1]) + r'\b'
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
733 if getter is None:
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
734 return lambda x : re.match(rs, x)
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
735 else:
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
736 return lambda x : re.match(rs, getter(x))
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
737
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
738 else:
250
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
739 if getter is None:
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
740 return lambda x : num == x
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
741 else:
2e507e256726 added filtering by category (including substring) to project calendar display.
casties
parents: 249
diff changeset
742 return lambda x : num == getter(x)
249
f07dc0d2c60c add project calendar (ticket #137).
casties
parents: 231
diff changeset
743
24
6a4996805505 more work on projects.
casties
parents: 22
diff changeset
744
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
745 def _moveObjectPlace(self, objectList, objectId, direction):
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
746 """Move object with objectId from objectList in direction
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
747 by changing its place attribute."""
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
748 if not objectId or not direction:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
749 return
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
750
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
751 for idx in range(len(objectList)):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
752 object = objectList[idx]
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
753 if object.getId() == objectId:
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
754 if direction == 'up':
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
755 if idx > 0:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
756 # move up
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
757 objectList[idx -1].place += 1
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
758 objectList[idx].place -= 1
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
759
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
760 elif direction == 'down':
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
761 if idx < len(objectList) - 1:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
762 # move down
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
763 objectList[idx + 1].place -= 1
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
764 objectList[idx].place += 1
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
765
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
766 return
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
767
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
768
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
769 def getImageList(self):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
770 """returns the sorted list of images for this project"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
771 items = self.objectValues(spec='MPIWGProject_image')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
772 # sort by place
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
773 return sorted(items, key=lambda x:int(getattr(x, 'place', 0)))
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
774
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
775
127
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
776
172
7fe39dcfb6c1 improved editing project images.
casties
parents: 171
diff changeset
777 def addImage(self, fileHd, caption=None, link=None, RESPONSE=None, filename=None):
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
778 """add an MPIWG_Project_image"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
779
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
780 if not filename:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
781 filename = fileHd.filename
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
782
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
783 if not fileHd:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
784 fileHd = file(os.path.join(package_home(globals()), 'blank.gif'))
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
785
171
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
786 filename = filename.replace(' ','_')
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
787
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
788 while filename in self.objectIds(spec='MPIWGProject_image'):
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
789 # file with this name exists
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
790 fs = filename.split('.')
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
791 try:
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
792 part = fs[-2]
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
793 # assume next-to-last part is name
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
794 if part[-2] == '_':
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
795 # *_n -- increment n
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
796 fs[-2] = part[:-1] + chr(ord(part[-1]) + 1)
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
797 else:
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
798 fs[-2] += '_1'
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
799
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
800 filename = '.'.join(fs)
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
801 except:
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
802 filename += '_1'
9d8f202e3895 fix bug when image uploads have same filename.
casties
parents: 169
diff changeset
803
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
804 newImage = MPIWGProject_image(filename, filename, fileHd)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
805
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
806 self._setObject(filename, newImage)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
807 obj = getattr(self, filename)
172
7fe39dcfb6c1 improved editing project images.
casties
parents: 171
diff changeset
808 obj.caption = caption
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
809 obj.enabled = True;
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
810 obj.place = self._getLastImageNumber() + 1
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
811 obj.id = filename
172
7fe39dcfb6c1 improved editing project images.
casties
parents: 171
diff changeset
812 obj.link = link
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
813
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
814 # invalidate thumbnail
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
815 self.projectThumb = None
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
816
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
817 if RESPONSE is not None:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
818 self.redirect(RESPONSE, 'manageImages')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
819
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
820
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
821 def _getLastImageNumber(self):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
822 items = self.getImageList()
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
823 if not items:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
824 return 0
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
825 else:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
826 return getattr(items[-1], 'place', 0)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
827
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
828
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
829 def manageImages(self, name=None, op=None):
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
830 """manage images"""
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
831 self._moveObjectPlace(self.getImageList(), name, op)
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
832
51
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
833 # invalidate thumbnail
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
834 self.projectThumb = None
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
835
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
836 pt = self.editImagesForm
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
837 return pt()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
838
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
839
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
840 def deleteImage(self, id, RESPONSE=None):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
841 """delete Image id"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
842 try:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
843 self.manage_delObjects([id])
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
844 except:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
845 logging.error("ERROR MPIWG: %s %s" % sys.exc_info()[0:2])
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
846
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
847 # invalidate thumbnail
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
848 self.projectThumb = None
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
849
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
850 if RESPONSE:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
851 self.redirect(RESPONSE, 'manageImages')
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
852
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
853
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
854 def getPublicationList(self):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
855 """returns the list of related publications"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
856 items = self.objectValues(spec='MPIWGProject_publication')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
857 # sort by place
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
858 items.sort(key=lambda x:int(getattr(x, 'place', 0)))
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
859 return items
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
860
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
861
64
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
862 def addPublication(self, text=None, link=None, RESPONSE=None):
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
863 """add an MPIWG_Publication"""
64
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
864 if text or link:
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
865 number = self._getLastPublicationNumber() + 1
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
866 name = "publication_" + str(number)
64
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
867 while hasattr(self, name):
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
868 number += 1
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
869 name = "publication_" + str(number)
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
870
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
871 newPublication = MPIWGProject_publication(name)
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
872
64
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
873 self._setObject(name, newPublication)
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
874 obj = getattr(self, name)
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
875 obj.text = text
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
876 obj.link = link
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
877 obj.enabled = True;
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
878 obj.place = self._getLastPublicationNumber() + 1
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
879 obj.id = name
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
880 # hasLinkToBookPage updates bookid if available
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
881 if obj.hasLinkToBookPage() and not text:
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
882 # take title from book page
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
883 try:
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
884 book = self.en.books[obj.bookId]
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
885 obj.text = book.getInfo('title')
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
886 except:
b5ff783027d6 more work on projects.
casties
parents: 63
diff changeset
887 pass
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
888
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
889 if RESPONSE is not None:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
890 self.redirect(RESPONSE, 'managePublications')
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
891
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
892
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
893 def _getLastPublicationNumber(self):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
894 items = self.getPublicationList()
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
895 if not items:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
896 return 0
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
897 else:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
898 return getattr(items[-1], 'place', 0)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
899
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
900
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
901 def managePublications(self, name=None, op=None):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
902 """manage publications"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
903 self._moveObjectPlace(self.getPublicationList(), name, op)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
904
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
905 pt = self.editPublicationsForm
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
906 return pt()
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
907
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
908
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
909 def deletePublication(self, id, RESPONSE=None):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
910 """delete Publication id"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
911 self.manage_delObjects([id])
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
912 if RESPONSE:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
913 self.redirect(RESPONSE, 'managePublications')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
914
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
915
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
916 def getRelatedProjectList(self):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
917 """returns the list of related projects"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
918 items = self.objectValues(spec='MPIWGProject_relatedProject')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
919 # sort by place
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
920 items.sort(key=lambda x:int(getattr(x, 'place', 0)))
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
921 return items
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
922
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
923
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
924 def addRelatedProject(self, link, RESPONSE=None):
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
925 """add a MPIWGProject_relatedProject"""
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
926 number = self._getLastRelatedProjectNumber() + 1
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
927 name = "related_project_" + str(number)
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
928 while hasattr(self, name):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
929 number += 1
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
930 name = "related_project_" + str(number)
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
931
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
932 # hole die id des projektes
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
933 splitted = link.split("/")
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
934
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
935 # teste ob es das project gibt
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
936 if len(splitted) < 1:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
937 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
938
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
939 objid = splitted[-1]
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
940 object = getattr(self.projects, objid, None)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
941
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
942 if object == None:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
943 self.redirect(RESPONSE, 'errorRelatedProjects?link=' + link)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
944 return
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
945
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
946 newPublication = MPIWGProject_relatedProject(name)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
947
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
948 self._setObject(name, newPublication)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
949 obj = getattr(self, name)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
950 obj.orginallink = link[0:]
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
951 obj.objid = objid[0:]
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
952 logging.debug("add relobj:objid" + repr(obj.objid))
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
953 obj.projectWEB_title = object.getProjectTitle()
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
954 logging.debug("add relobj:webtitle" + repr(obj.projectWEB_title))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
955 obj.enabled = True;
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
956 obj.place = self._getLastRelatedProjectNumber() + 1
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
957 obj.id = name
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
958 if RESPONSE is not None:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
959 self.redirect(RESPONSE, 'manageRelatedProjects')
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
960
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
961
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
962 def _getLastRelatedProjectNumber(self):
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
963 items = self.getRelatedProjectList()
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
964 if not items:
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
965 return 0
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
966 else:
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
967 return getattr(items[-1], 'place', 0)
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
968
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
969
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
970 def manageRelatedProjects(self, name=None, op=None):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
971 """manage related projects"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
972 self._moveObjectPlace(self.getRelatedProjectList(), name, op)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
973
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
974 pt = self.editRelatedProjectsForm
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
975 return pt()
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
976
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
977
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
978 def deleteRelatedProject(self, id, RESPONSE=None):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
979 """delete Publication id"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
980 self.manage_delObjects([id])
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
981 if RESPONSE:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
982 self.redirect(RESPONSE, 'manageRelatedProjects')
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
983
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
984
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
985 def errorRelatedProjects(self, link):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
986 """error creating a related project"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
987 pt = self.editRelatedProjectsError
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
988 return pt(link=link)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
989
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
990
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
991 def getInfoBlockList(self):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
992 """returns the list of related projects"""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
993 items = self.objectValues(spec='MPIWGProject_InfoBlock')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
994 # sort by place
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
995 items.sort(key=lambda x:int(getattr(x, 'place', 0)))
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
996 return items
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
997
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
998
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
999 def addInfoBlock(self, block_title=None, item_text=None, item_link=None, RESPONSE=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1000 """add a MPIWGProject_InfoBlock"""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1001 if block_title:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1002 number = self._getLastInfoBlockNumber() + 1
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1003 name = "infoblock_" + str(number)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1004 while hasattr(self, name):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1005 number += 1
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1006 name = "infoblock_" + str(number)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1007
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1008 newBlock = MPIWGProject_InfoBlock(name, block_title)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1009 # add block to project
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1010 self._setObject(name, newBlock)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1011 obj = getattr(self, name)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1012 obj.place = self._getLastInfoBlockNumber() + 1
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1013 if item_text:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1014 obj.addItem(text=item_text, link=item_link)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1015
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1016 if RESPONSE is not None:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1017 self.redirect(RESPONSE, 'manageInfoBlocks')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1018
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1019
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1020 def _getLastInfoBlockNumber(self):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1021 items = self.getInfoBlockList()
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1022 if not items:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1023 return 0
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1024 else:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1025 return getattr(items[-1], 'place', 0)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1026
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1027
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1028 def manageInfoBlocks(self, name=None, op=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1029 """manage related projects"""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1030 self._moveObjectPlace(self.getInfoBlockList(), name, op)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1031
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1032 pt = self.editInfoBlocksForm
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1033 return pt()
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1034
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1035
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1036 def deleteInfoBlock(self, id, RESPONSE=None):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1037 """delete Publication id"""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1038 self.manage_delObjects([id])
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1039 if RESPONSE:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1040 self.redirect(RESPONSE, 'manageInfoBlocks')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1041
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1042
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1043 def getAdditionalPublicationList(self):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1044 """hole publications aus der datenbank"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1045 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
1046 return self.executeZSQL(query,[self.getId()])
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1047
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1048
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1049 def hasAdditionalPublications(self):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1050 """test if extended publication list exists"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1051 query="select count(*) from pubmanbiblio_projects where lower(key_main) = lower(%s)"
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1052 res= self.executeZSQL(query,[self.getId()])
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1053 if res[0].count > 0:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1054 return True
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1055 else:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1056 return False
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1057
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1058
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1059 def addAdditionalPublicationsFromPubman(self,REQUEST):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1060 """addPublications from pubman"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1061 data=REQUEST.form
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1062 if data.get("method",None) is None:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1063 pt = self.editAddAdditionalPublications
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1064 return pt()
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1065
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1066 if data.get("method") == "search":
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1067 entries= self.mpiwgPubman.search(data)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1068 pt = self.editAddAdditionalPublications
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1069 return pt(values=entries)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1070
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1071 if data.get("method") == "add":
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1072 return self.addEntriesToAdditionalPublicationList(data)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1073 #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
1074
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1075
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1076 def addEntriesToAdditionalPublicationList(self,data):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1077 """fuege eintrage aus data zur publications liste.
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1078
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1079 @param data Map mit escidocID --> value
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1080 value muss "add" sein damit hinzugefuegt wird"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1081 for key in data.keys():
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1082 if key.startswith('escidoc:'):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1083 query="INSERT INTO pubmanbiblio_projects (key_main,escidocId) values (%s,%s)"
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1084 if data.get(key)=="add":
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1085 self.executeZSQL(query,[self.getId(),key])
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1086
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1087 if hasattr(self,'REQUEST'):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1088 return self.REQUEST.response.redirect("changeAdditionalPublications")
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1089
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1090
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1091 def changeAdditionalPublications(self,REQUEST):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1092 """change published publications"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1093 data=REQUEST.form
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1094 if data.get("method","change"):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1095 for key in data.keys():
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1096 splitted=key.split("__") #format escidoc_id__p fuer priority, nur escidocid
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1097 value=data[key]
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1098 if len(splitted)==1:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1099 self.deleteFromAdditionalPublicationList(key);
44
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1100
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1101 elif(splitted[1]) == "p":
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1102 self.setAdditionalPublicationPriority(splitted[0],value);
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1103
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1104 pt = self.editAdditionalPublicationsForm
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1105 return pt()
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1106
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1107
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1108 def deleteFromAdditionalPublicationList(self,escidocid):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1109 """Loessche publication with escidoc id from publication list"""
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1110 query ="DELETE FROM pubmanbiblio_projects WHERE escidocid=%s and key_main=%s"
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1111 self.executeZSQL(query,[escidocid,self.getId()]);
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1112
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1113
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1114 def setAdditionalPublicationPriority(self,escidocid,value):
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1115 query="update pubmanbiblio_projects set priority=%s where escidocid=%s and key_main=%s"
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1116 try:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1117 value = int(value)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1118 self.executeZSQL(query,[value,escidocid,self.getId()]);
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1119 except:
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1120 logging.error("couldn't change:")
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1121 logging.error(escidocid)
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1122 logging.error(value)
44
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1123
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1124
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1125 def getActualVersion(self, date=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1126 """actuelle version"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1127 def sortProjectsByTime(x, y):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1128 return cmp(x[1].archiveTime, y[1].archiveTime)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1129
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1130 if not date:
44
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1131 if self.isCurrentVersion():
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1132 return self
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1133 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1134 return None
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1135
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1136 # suche ob aeltere versionen vorhanden sind
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1137
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1138 finds = self.ZopeFind(self, obj_metatypes=['MPIWGProject'])
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1139 if not finds: # wenn nicht dann teste ob die aktuelle version schon existiert hat.
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1140 ad = getattr(self, 'creationTime', '20050101000000')
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1141 if int(date) > int(ad):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1142 return self
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1143 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1144 return None
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1145
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1146 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1147 finds.sort(sortProjectsByTime)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1148
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1149 for find in finds:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1150 # gehe durch die alten Projekte und finde das entprechende
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1151 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
1152 return find[1]
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1153
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1154 # kein passendes gefunden, dann teste ob das aktuelle in frage kommt
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1155 ad = getattr(self, 'creationTime', '20050101000000')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1156
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1157 if int(date) > int(ad):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1158
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1159 return self
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1160 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1161 return None
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1162
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1163
44
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1164 def isCurrentVersion(self):
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1165 """Return if project is the current version."""
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1166 currentTime = time.localtime()
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1167 # print getattr(self,'archiveTime',currentTime)
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1168 return (getattr(self, 'archiveTime', currentTime) >= currentTime)
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1169
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1170
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1171 def copyObjectToArchive(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1172 """kopiere aktuelles objekt ins archiv"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1173 logging.info("copytoarchive 1")
204
670b3507509d fix breadcrumbs for features.
casties
parents: 191
diff changeset
1174 cb = aq_parent(self).manage_copyObjects(self.getId())
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1175 logging.info("copytoarchive 2")
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1176 self.manage_pasteObjects(cb)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1177 logging.info("copytoarchive 3")
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1178 actualTime = time.localtime()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1179
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1180 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
1181 logging.info("copytoarchive 4")
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1182 obj = getattr(self, self.getId() + "_" + time.strftime("%Y%m%d%H%M%S", actualTime))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1183 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
1184 logging.info("copytoarchive 5")
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1185 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
1186 logging.info("copytoarchive 6")
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1187 obj.manage_delObjects(ids)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1188 logging.info("copytoarchive 7")
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1189
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1190
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1191 def setArchiveTime(self, time):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1192 """set Archive Time"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1193 self.archiveTime = time[0:]
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1194
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1195
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1196 def delArchiveTime(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1197 """delete archive time"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1198 del self.archiveTime
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1199
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1200
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1201 def isActiveProject(self):
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
1202 """check if the project is still active, default is true."""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1203 return getattr(self, 'isActiveFlag', True)
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1204
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1205
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1206 def checkActive(self, active):
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1207 """returns if the project state matches the active state.
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1208 active = 0 : all projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1209 active = 1 : active projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1210 active = 2 : inactive projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1211 """
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1212 act = getattr(self, 'isActiveFlag', True)
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1213 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
1214
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1215
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1216 def isArchivedProject(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1217 """check if the project is archived"""
108
782477730916 CLOSED - # 57: Research/ Research Units: Karussell f?r die Projekte in einem Department
casties
parents: 105
diff changeset
1218 completed = getattr(self, 'completedAt', '')
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1219 # completed leer
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1220 if completed == "" :
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1221 return False;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1222 if completed == 0:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1223 return False;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1224
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1225 return True
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1226
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1227
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1228 def checkArchived(self, archived):
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1229 """returns if the project state matches the archived state.
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1230 archived = 0 : all projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1231 archived = 1 : current projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1232 archived = 2 : archived projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1233 """
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1234 arch = self.isArchivedProject()
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1235 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
1236
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1237
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1238 def setActiveFlag(self, status=True):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1239 """set the active flag"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1240 self.isActiveFlag = status
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1241
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1242
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1243 def setCompletedAt(self, date):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1244 """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
1245 # logging.info("DATE:"+repr(date))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1246 transformedDate = self.transformDate(date);
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1247 # logging.info("transformed"+repr(transformedDate))
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1248 if transformedDate is not None:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1249 setattr(self, "completedAt", transformedDate)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1250 return True;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1251 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1252 return False;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1253
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1254 def setStartedAt(self, date):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1255 """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
1256 # logging.info("DATE:"+repr(date))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1257 transformedDate = self.transformDate(date);
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1258 # logging.info("transformed"+repr(transformedDate))
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1259 if transformedDate is not None:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1260 setattr(self, "startedAt", transformedDate)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1261 return True;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1262 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1263 return False;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1264
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1265 def getCompletedAt(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1266 """gibt das transformierte Datum zurueck, an dem das Projekt beendet wurde."""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1267 date = getattr(self, 'completedAt', '')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1268 if date:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1269 return self.reTransformDate(date);
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1270 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1271 return ""
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 def getStartedAt(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1274 """gibt das transformierte Datum zurueck, an dem Projekt begonnen wurde."""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1275 date = getattr(self, 'startedAt', '')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1276 if date:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1277 return self.reTransformDate(date);
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1278 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1279 return '';
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1280
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1281 def reTransformDate(self, date):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1282 """transformiert , transformdate zurueck"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1283 year = int(date / 10000)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1284 month = int((date - year * 10000) / 100)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1285 day = int((date - year * 10000 - month * 100))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1286 if (day == 0) and (month == 0):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1287 return """%s""" % year;
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1288 if day == 0 :
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1289 return """%s.%s""" % (month, year);
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1290
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1291 return """%s.%s.%s""" % (day, month, year);
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1292
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1293
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1294 def transformDate(self, date):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1295 """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
1296 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
1297
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1298 if (date == None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1299 return None;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1300
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1301
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1302 if (date.lstrip().rstrip() == "") :
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1303 return "";
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1304
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1305 splitted = date.split(".")
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1306 length = len(splitted)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1307 year = 0
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1308 month = 0
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1309 day = 0
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1310 if length > 3:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1311 return "";
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1312 if length == 3:
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1313 day = int(splitted[0])
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1314 if length > 1:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1315 month = int(splitted[length - 2])
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1316
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1317 if length > 0:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1318 try:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1319 year = int(splitted[length - 1])
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1320 except:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1321 pass
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1322
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1323 # # logging.info("month:"+(month))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1324 if not (0 <= month < 13):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1325 return None;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1326
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1327 if not(0 <= day < 32):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1328 return None;
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1329
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1330 if (year > 0) and (year < 1900): # jahr nicht vierstellig eingegeben
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1331 year = 2000 + year;
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1332 return year * 10000 + month * 100 + day
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1333
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1334
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1335
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1336 def checkDate(self, date):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1337 """teste ob zum Zeitpunkt date eine andere version existierte"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1338
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1339
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1340 def sortProjectsByTime(x, y):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1341 return cmp(x[1].archiveTime, y[1].archiveTime)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1342
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1343 # suche ob aeltere versionen vorhanden sind
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1344
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1345 finds = self.ZopeFind(self, obj_metatypes=['MPIWGProject'])
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1346 if not finds: # wenn nicht dann teste ob die aktuelle version schon existiert hat.
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1347 ad = getattr(self, 'creationTime', '20050101000000')
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1348 if int(date) > int(ad):
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1349 return self.REQUEST['URL1'] + "/" + self.getId()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1350 else:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1351 return self.REQUEST['URL1'] + "/no_project"
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1352
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1353 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1354 finds.sort(sortProjectsByTime)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1355
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1356 for find in finds:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1357 # gehe durch die alten Projekte und finde das entprechende
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1358 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
1359 return self.REQUEST['URL1'] + "/" + find[1].getId()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1360
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1361 # kein passendes gefunden, dann teste ob das aktuelle in frage kommt
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1362 ad = getattr(self, 'creationTime', '20050101000000')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1363
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1364 if int(date) > int(ad):
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1365 return self.REQUEST['URL1'] + "/" + self.getId()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1366 else:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1367 return self.REQUEST['URL1'] + "/no_project"
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1368
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1369
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1370 def saveFromPreview(self, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1371 """save content aus preview"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1372 self.WEB_project_description = self.previewTemplate.WEB_project_description[0:]
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1373 #self.REQUEST.RESPONSE.redirect("./index.html")
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1374 if RESPONSE is not None:
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1375 return self.editDescription()
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1376
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1377
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1378 def saveEditedContent(self, kupu=None, preview=None, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1379 """save Edited content"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1380 # 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
1381
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1382 if preview:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1383 kupu = preview
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1384
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1385 # find content of body tags
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1386 start = kupu.find("<body>")
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1387 end = kupu.find("</body>")
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1388 newcontent = kupu[start + 6:end]
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1389
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1390 if preview:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1391 return self.preview(newcontent)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1392
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1393 self.copyObjectToArchive()
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1394 self.WEB_project_description = newcontent[0:]
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1395
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1396 #self.REQUEST.RESPONSE.redirect("./index.html")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1397
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1398 if RESPONSE is not None:
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1399 return self.editDescription()
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1400
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1401
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1402 def getBreadcrumbs(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1403 """return list of breadcrumbs from here to the root"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1404 crumbs = []
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1405 # skip direct parent Folder /projects/
204
670b3507509d fix breadcrumbs for features.
casties
parents: 191
diff changeset
1406 parent = aq_parent(aq_parent(self))
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1407 # get parents breadcrumbs
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1408 if hasattr(parent, 'getBreadcrumbs'):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1409 crumbs = parent.getBreadcrumbs()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1410
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1411 # try to get acquisition URL from parent
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1412 if hasattr(parent, 'absolute_url'):
191
90d44df497a6 updated breadcrumb handling, works for members now.
casties
parents: 183
diff changeset
1413 baseUrl = "%s/%s" % (parent.absolute_url(), 'projects')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1414 else:
191
90d44df497a6 updated breadcrumb handling, works for members now.
casties
parents: 183
diff changeset
1415 baseUrl = "/en/research/projects"
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1416
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1417 # add in the internal project hierarchy
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1418 tree = self.getProjectTree()
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1419 ap = tree.getAncestorsOf(self.getNumber())
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1420 # start with grandparents
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1421 for p in ap:
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1422 label = shortenString(p.getLabel(), 13)
191
90d44df497a6 updated breadcrumb handling, works for members now.
casties
parents: 183
diff changeset
1423 crumbs.append({'text':label, 'url':p.getUrl(baseUrl=baseUrl), 'title':p.getLabel(), 'object':p})
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1424
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1425 # add this project
191
90d44df497a6 updated breadcrumb handling, works for members now.
casties
parents: 183
diff changeset
1426 crumbs.append({'text':self.getLabel(), 'url':self.getUrl(baseUrl=baseUrl), 'title':self.getLabel(), 'object':self})
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1427
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1428 return crumbs
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1429
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1430 # TODO: is this used?
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1431 def preview(self, description):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1432 """preview"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1433 # logging.debug("preview description=%s"%description)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1434 tmpPro = getattr(self, "previewTemplate", None)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1435 if not tmpPro:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1436 tmpPro = MPIWGProject("previewTemplate")
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1437 self._setObject("previewTemplate", tmpPro)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1438 for field in definedFields:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1439 setattr(tmpPro, field, getattr(self, field))
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1440 tmpPro.WEB_project_description = description[0:]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1441 tmpPro.invisible = True
97
7b96a85552aa fix bugs in project editing.
casties
parents: 96
diff changeset
1442 pt = PageTemplateFile('zpt/project/edit_preview_frame', globals()).__of__(self)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1443 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1444
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1445
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1446 def isResponsibleScientist(self, key):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1447 """teste ob eine Person in der Liste der respl. scientists auftaucht"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1448 for resp in self.getResponsibleScientistsList():
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1449 logging.debug("resp=%s key=%s"%(repr(resp),repr(key)))
63
fd6931bd49c8 more cleaning up projects.
casties
parents: 62
diff changeset
1450 # TODO: we need to get ASCII keys!!
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
1451 if utf8ify(resp.get('key', '')).lower() == utf8ify(key).lower():
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1452 return True
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1453
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1454 return False
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1455
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1456
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1457 def identifyNames(self, nameList):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1458 """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
1459 und ordnet diese dann Mitarbeiter IDs zu.
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1460
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1461 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
1462
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1463 @param nameList
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1464 """
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1465 if nameList.find(";") > -1: # rate Trenner ist ;
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1466 names = nameList.split(";")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1467 else:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1468 names = nameList.split(",")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1469
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1470 # #nameList=nameList.replace(";",",") # falls ; als Trenner ersetze
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1471 returnNamesDict = {}
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1472
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1473 for name in names:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1474 name = name.strip()
123
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
1475 if not name:
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
1476 continue
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1477 nameSplitted = name.split(" ")
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1478 if len(nameSplitted) > 1: # vor und nachname angegeben)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1479 lastname = nameSplitted[-1]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1480 firstname = nameSplitted[0]
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1481 else:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1482 firstname = ""
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1483 lastname = nameSplitted[0]
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1484
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1485 # finde Mitarbeiter mit den entsprechenden Name
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1486
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1487 # firstname=self.myCapitalize(firstname).encode('utf-8')
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1488 # lastname=self.myCapitalize(lastname).encode('utf-8')
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1489 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
1490 try:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1491 # cataloggedNames=self.MembersCatalog(firstName=firstname,lastName=lastname)
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1492 # TODO: I think this does not work without firstname
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1493 # try to find names in members db by searching for sub-words
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1494 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
1495 if len(cataloggedNames) == 0:
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1496 # PostgreSQL has a bug with \m and words ending in non-ASCII :-(
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1497 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
1498 except:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1499 cataloggedNames = []
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1500 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
1501
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1502 if len(cataloggedNames) > 0:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1503 returnNamesDict[name] = cataloggedNames
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1504 else:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1505 returnNamesDict[name] = []
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1506
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1507 logging.debug("identified names: %s" % repr(returnNamesDict))
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1508 return returnNamesDict
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1509
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1510
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
1511 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
1512 """edit the project and archive the old version"""
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
1513 logging.debug("editMPIWGProject(fromEdit=%s, createNewVersion=%s)"%(fromEdit,createNewVersion))
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
1514 if createNewVersion:
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
1515 self.copyObjectToArchive() # archive the object
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1516
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1517 formdata = self.REQUEST.form
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1518
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1519 # set all definedFields
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1520 for x in definedFields:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1521 if formdata.has_key(x):
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1522 setattr(self, x, unicodify(formdata[x]))
99
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
1523 if x == 'xdata_05':
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
1524 # changing project number invalidates project tree
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
1525 self.resetProjectTree()
0
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 completedAt = formdata.get('completedAt')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1528 if not self.setCompletedAt(completedAt):
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1529 RESPONSE.redirect('./editMPIWGBasisEditor?error=dateWrong')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1530
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1531 startedAt = formdata.get('startedAt')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1532 if not self.setStartedAt(startedAt):
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1533 RESPONSE.redirect('./editMPIWGBasisEditor?error=dateWrong')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1534
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1535 if self.REQUEST.has_key('active'):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1536 self.setActiveFlag(True)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1537 else:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1538 self.setActiveFlag(False)
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1539
257
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
1540 if formdata.has_key('projectType'):
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
1541 if formdata.get('projectType'):
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
1542 self.projectType = formdata.get('projectType')
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
1543 else:
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
1544 self.projectType = None
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
1545
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1546 # make dict of responsible scientists
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1547 checkedScientists = {}
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1548 names = {}
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1549 keys = {}
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
1550 for key in formdata:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1551 # gehe durch das Formular
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1552 keyParts = key.split("_")
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1553 if keyParts[0] == "responsibleScientist":
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1554 # wenn es ein Feld der Form reponsibleScientist_nr_KEY gibt
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1555 nr = keyParts[2]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1556 if keyParts[1] == "name":
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1557 names[nr] = unicodify(formdata[key])
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1558 elif keyParts[1] == "key":
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1559 keys[nr] = formdata[key]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1560
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
1561 for nr in names:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1562 name = names[nr]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1563 key = keys.get(nr, None)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1564 username = None
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1565 if key:
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1566 # get username from db
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
1567 member = self.en.getMPIWGRoot().getStaffFolder().getMember(key=key)
40
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
1568 if member is not None:
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
1569 username = member.getUsername()
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1570
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1571 # schreibe keys und namen in die Liste
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1572 checkedScientists[names[nr]] = {'name' : name, 'key' : key, 'username' : username}
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1573
44
05754bca0114 updated project not current warning.
casties
parents: 43
diff changeset
1574 # update responsibleScientistsList
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1575 self.setResponsibleScientistsList(checkedScientists)
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
1576 self.updateProjectMembers()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1577
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1578 if fromEdit and (RESPONSE is not None):
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1579 return self.editBasic()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1580
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1581 if RESPONSE is not None:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1582 RESPONSE.redirect('manage_main')
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1583
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1584
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1585 def getContent(self, field, filter=None):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1586 """Inhalt des Feldes"""
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1587 val = getattr(self, field, '')
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1588 if isinstance(val, list):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1589 val = val[0]
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1590
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1591 return val
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1592
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1593
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1594 def loadNewFile(self, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1595 """einlesen des neuen files"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1596 fileupload = self.REQUEST['fileupload']
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1597 if fileupload:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1598 file_name = fileupload.filename
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1599 filedata = fileupload.read()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1600
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1601 argv = xmlhelper.proj2hash(filedata)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1602 # print argv.keys()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1603 for arg in definedFields:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1604
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1605 # print arg,argv[arg],getattr(self,arg)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1606 try:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1607 temp = argv[arg][0:]
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1608 # old=getattr(self,arg)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1609 setattr(self, arg, temp)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1610 # print old,getattr(self,arg)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1611 except:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1612 """nothing"""
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1613
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1614 if RESPONSE is not None:
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1615 RESPONSE.redirect('manage_main')
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1616
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1617
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1618 def tagTheProject(self, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1619 """TAG"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1620 id = self.getId();
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1621 tmpl = getattr(self.thesaurus, "main.html")
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1622 if RESPONSE:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1623 RESPONSE.redirect("./thesaurus/main.html?project=" + id)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1624 return
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1625
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1626
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1627 def moveObjectDigitallibraryToInfoBlock(self):
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1628 """Move text from 'Object Digitallibrary' to InfoBlock."""
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1629 text = self.getRelatedDigitalSources()
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1630 if text:
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1631 logging.debug("Moving 'Object Digitallibrary' to InfoBlock: %s"%repr(text))
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1632 self.addInfoBlock(block_title='Related digital sources', item_text=text, item_link=None)
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1633 delattr(self, 'xdata_11')
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1634
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
1635
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1636 def hasRelatedPublicationsOldVersion(self):
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1637 """teste ob es related publications gibt"""
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1638 ret = True;
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
1639 if (getattr(self, 'WEB_related_pub', '') == ''):
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1640 ret = False; # nichts im alten feld
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1641 logging.debug("webrel:" + repr(ret))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1642 if (getattr(self, 'WEB_related_pub_copied', False)):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1643 ret = False; # alte daten sind schon kopiert worden
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1644
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1645 logging.debug("webrel_copied:" + repr(ret))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1646 publications = self.ZopeFind(self, obj_metatypes=['MPIWGProject_publication']);
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1647
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1648 if(len(publications) > 0):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1649 ret = False; # es gibt publicationen in der neuen liste
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1650
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1651 logging.debug("len(publ)" + repr(ret))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1652
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1653 return ret;
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1654
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1655
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1656 def copyPublicationsToList(self, RESPONSE=None):
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1657 """copy publications in to list"""
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1658 publicationTxt = getattr(self, 'WEB_related_pub', '')
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1659 if isinstance(publicationTxt, list):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1660 publicationTxt = publicationTxt[0]
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1661
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1662 pubSplits = publicationTxt.split("<p>")
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1663
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1664 for pubSplit in pubSplits:
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1665 pubSplit = pubSplit.replace("</p>", "")
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1666 self.addPublication(pubSplit)
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1667
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1668 setattr(self, "WEB_related_pub_copied", True);
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1669
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1670 if RESPONSE:
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1671 self.redirect(RESPONSE, 'managePublications')
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1672
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
1673
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1674 def hasInlineImage(self):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1675 """Return the number of inline images in the description."""
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1676 text = self.getDescription()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1677 cnt = text.count('<p class="picture">')
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1678 return cnt
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1679
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1680
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1681 def copyImageToMargin(self, RESPONSE=None):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1682 """copy inline images to marginal images"""
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1683 # getImages from WEB_project_description
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1684 description = self.getDescription()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1685
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1686 text2 = description
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1687 splitted = text2.split("""<p class="picture">""")
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1688
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1689 imageURLs = []
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1690 imageCaptions = []
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1691 for split in splitted[1:]:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1692 tmp = split.split("</p>")
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1693 # return repr(splitted[1])
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1694
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1695 try:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1696 imageURLs.append(tmp[0].split("\"")[1].encode('utf-8'))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1697 except:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1698
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1699 try:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1700 imageURLs.append(tmp[0].split("src=")[1].split(" ")[0].encode('utf-8'))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1701 except:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1702 imageURLs.append("")
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1703
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1704 split2 = "</p>".join(tmp[1:])
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1705 splitted = split2.split("""<p class="picturetitle">""")
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1706 if len(splitted) > 1:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1707 tmp = splitted[1].split("</p>")
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1708 imageCaptions.append(tmp[0].encode('utf-8'))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1709
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1710 else:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1711 # keine caption
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1712 imageCaptions.append("")
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1713
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1714 # eintragen:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1715 for imageURL in imageURLs:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1716 if not imageURL:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1717 # no URL - no image
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1718 continue
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1719
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1720 filename = imageURL.split("/")[-1]
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1721 # lege neues images object an, mit leerem bild
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1722
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1723 if filename in self:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1724 # existiert das bild schon, dann neuen filenamen
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1725 filename = "project_image_" + filename
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1726 if filename in self:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1727 # exists too - assume its already converted
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1728 logging.warn("copyImageToMargin: image %s exists - skipping!"%filename)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1729 continue
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1730
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1731 self.addImage(None, imageCaptions[imageURLs.index(imageURL)], filename=filename)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1732 # hole die bilddaten aus der url
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1733 url = self.absolute_url() + "/" + imageURL
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1734 # url=self.absolute_url()+"/"+filename
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1735
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1736 try: # relative url
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1737 data = urllib.urlopen(url).read()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1738 except:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1739 try: # absolute
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1740 data = urllib.urlopen(self.imageURL).read()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1741 except:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1742 logging.error("copyImageToMargin: can't open: %s" % url)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1743
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1744 obj = getattr(self, filename)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1745 obj.update_data(data)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1746
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1747 # clean description
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1748 logging.debug("copyImageToMargin: description:%s"%repr(description))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1749 dom = ET.fromstring(utf8ify("<html>%s</html>"%description))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1750 for e in dom.findall(".//p[@class='picture']"):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1751 # remove contents
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1752 e.clear()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1753 # remove tag
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1754 e.tag = None
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1755
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1756 for e in dom.findall(".//p[@class='picturetitle']"):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1757 # remove contents
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1758 e.clear()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1759 # remove tag
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1760 e.tag = None
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1761
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1762 # remove html tag
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1763 dom.tag = None
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1764 # set as new description
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1765 description = unicodify(serialize(dom))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1766 logging.debug("copyImageToMargin: new description:%s"%repr(description))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1767 setattr(self, 'WEB_project_description', description)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1768
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1769 if RESPONSE:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1770 self.redirect(RESPONSE, 'manageImages')
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1771
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
1772
169
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1773 def scaleImage(self,REQUEST=None,RESPONSE=None):
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1774 """scale the last image"""
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1775 from PIL import Image;
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1776 from cStringIO import StringIO;
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1777 import ImageFilter
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1778
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1779 images = self.getImageList();
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1780 if len(images)>0:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1781 img = images[-1] #nimmt das letze
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1782
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1783 logging.debug(img)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1784 datStringIO = StringIO();
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1785 """
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1786 data=img.data
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1787 if isinstance(data, str):
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1788 datStringIO.write(data)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1789 else:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1790
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1791 while data is not None:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1792 datStringIO.write(data.data)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1793 data=data.next
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1794
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1795 """
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1796
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1797 logging.debug(img.absolute_url())
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1798
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1799 url = img.absolute_url()
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1800 if not url.startswith("http"):
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1801 url=REQUEST['URL0']+url
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1802 ul = urllib.urlopen(url)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1803 datStringIO = StringIO(ul.read());
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1804
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1805
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1806 try:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1807 pilImg = Image.open(datStringIO)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1808
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1809
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1810 except:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1811 logging.error("scale image input:"+self.getId())
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1812 return
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1813
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1814 w,h = pilImg.size
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1815 logging.debug("oldsize: %s %s"%(w,h))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1816 targetW=120.
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1817 targetH=75.
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1818
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1819 if targetW == w and targetH == h:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1820 return
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1821 facW=targetW/w
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1822
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1823 h1 = int(h*facW)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1824
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1825 if h1<targetH: #bild zu klein in h
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1826 facH=targetH/h
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1827
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1828 w1=int(w*facH)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1829
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1830 fs = min(max(int(1/facH)+1,3),10)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1831 logging.debug(fs)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1832 if (1/facH) > 2:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1833 pilImg = pilImg.filter(ImageFilter.BLUR)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1834
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1835 try:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1836 pilImg = pilImg.filter(ImageFilter.MaxFilter(fs))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1837 except:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1838 pilImg = pilImg.filter(ImageFilter.MaxFilter(fs-1))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1839
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1840 logging.debug("Xnew size: %s %s"%(w1,targetH))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1841 res = pilImg.resize((w1,int(targetH)),Image.ANTIALIAS);
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1842
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1843
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1844 else:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1845 fs = min(max(int(1/facW)+1,3),10)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1846 logging.debug(fs)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1847
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1848 if (1/facW) > 2:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1849 try:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1850 pilImg = pilImg.filter(ImageFilter.BLUR)
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1851 except:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1852 pass #some image types cannot be filter, just ignore
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1853
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1854 try:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1855 pilImg = pilImg.filter(ImageFilter.MaxFilter(fs))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1856 except:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1857
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1858
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1859 try:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1860 pilImg = pilImg.filter(ImageFilter.MaxFilter(fs-1))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1861 except:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1862 pass
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1863 logging.debug("ynew size: %s %s"%(targetW,h1))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1864 res = pilImg.resize((int(targetW),h1))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1865
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1866 nw,nh = res.size
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1867
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1868 cutW1=int(nw/2-(targetW/2))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1869 cutW2=int(nw/2+(targetW/2))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1870
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1871 cutH1=int(nh/2-(targetH/2))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1872 cutH2=int(nh/2+(targetH/2))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1873
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1874 res2 = res.crop((cutW1,cutH1,cutW2,cutH2))
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1875
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1876 outS = StringIO()
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1877
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1878 #res2.save("/tmp/"+self.getId()+".jpg")
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1879
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1880 try:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1881 res2.save(outS,"JPEG")
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1882
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1883 self.addImage(outS, None, RESPONSE, filename="thumb.jpg")
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1884
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1885 except:
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1886 logging.error("scale image:"+self.getId())
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1887
2da62e93a1c6 fix editing related projects.
casties
parents: 162
diff changeset
1888
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1889 def updateProjectMembers(self, updateResponsibleScientistsList=False):
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1890 """Update project-member table."""
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1891 # projects are identified by id
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1892 pid = self.getId()
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1893
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1894 # clear projects_members table
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1895 self.executeZSQL("delete from projects_members where project_id = %s", [pid])
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1896
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1897 for m in self.getResponsibleScientistsList():
42
c00410ae0444 fixed bug in project update.
casties
parents: 40
diff changeset
1898 memberKey = m.get('key', None)
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1899 if not memberKey or not isinstance(memberKey, basestring):
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1900 logging.error("updateProjectMembers: not a valid member key: %s" % repr(memberKey))
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1901 continue
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
1902
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1903 # fill projects_members table
183
8bbf8900273d more utf8ify for member keys again :-(
casties
parents: 179
diff changeset
1904 self.executeZSQL("insert into projects_members (project_id, member_key) values (%s, %s)", (pid, utf8ify(memberKey)))
56
a6ace48c2bf2 publication management f?r projekte
dwinter
parents: 54
diff changeset
1905
a6ace48c2bf2 publication management f?r projekte
dwinter
parents: 54
diff changeset
1906
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
1907
56
a6ace48c2bf2 publication management f?r projekte
dwinter
parents: 54
diff changeset
1908
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1909 def manage_addMPIWGProjectForm(self):
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1910 """form for adding the project"""
156
a9ad7dd7a8b2 clean up projects.
casties
parents: 127
diff changeset
1911 pt = PageTemplateFile('zpt/project/manage_add_MPIWGProject', globals()).__of__(self)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1912 return pt()
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1913
156
a9ad7dd7a8b2 clean up projects.
casties
parents: 127
diff changeset
1914 def manage_addMPIWGProject(self, id, fileupload=None, RESPONSE=None):
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1915 """method to add a project"""
179
136b2d5b3e3d CLOSED - # 108: add project should strip whitespace from id
casties
parents: 178
diff changeset
1916 id = id.strip()
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1917 if fileupload:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1918 filedata = fileupload.read()
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1919 argv = xmlhelper.proj2hash(filedata)
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1920 # print argv
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1921 newObj = MPIWGProject(id, argv)
156
a9ad7dd7a8b2 clean up projects.
casties
parents: 127
diff changeset
1922
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1923 else:
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1924 newObj = MPIWGProject(id)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1925
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1926 self._setObject(id, newObj)
0
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1927
bca61e893fcc first checkin of MPIWGWeb r2 branch from CVS into mercurial
casties
parents:
diff changeset
1928 if RESPONSE is not None:
156
a9ad7dd7a8b2 clean up projects.
casties
parents: 127
diff changeset
1929 url = '%s/%s/editBasic'%(self.absolute_url(), id)
a9ad7dd7a8b2 clean up projects.
casties
parents: 127
diff changeset
1930 RESPONSE.redirect(url)
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1931
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1932
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1933 class MPIWGProjectFolder(ZDBInterfaceFolder):
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1934 """Folder of project objects"""
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1935
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1936 meta_type = "MPIWGProjectFolder"
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1937 security = ClassSecurityInfo()
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1938
276
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1939 allprojects_xml = PageTemplateFile('zpt/project/all_projects_xml', globals())
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1940
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1941 # cached HashTree with project hierarchy
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1942 _v_projectTree = None
53
e718d9a72f19 bibliographie funktionen
dwinter
parents: 45
diff changeset
1943
34
b8ced08ebea9 working on projects.
casties
parents: 33
diff changeset
1944 def getProjectTree(self):
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
1945 """Return the project hierarchy tree (and cache it).
34
b8ced08ebea9 working on projects.
casties
parents: 33
diff changeset
1946
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
1947 Returns HashTree instance."""
229
d4216a848547 fixed problem that reading the project tree changes it.
casties
parents: 228
diff changeset
1948 tree = self._v_projectTree
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1949 if tree is None:
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
1950 tree = HashTree(keySeparator='.', keyFn=getInt)
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1951 for p in self.objectValues(spec='MPIWGProject'):
51
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
1952 # add all projects
257
7288e7729960 added projectType field to MPIWGProjects.
casties
parents: 250
diff changeset
1953 #logging.debug("add to project tree: %s, %s"%(repr(p.getNumber()),p))
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1954 tree.add(p.getNumber(), p)
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1955
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1956 self._v_projectTree = tree
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1957 # logging.debug("getProjectTree: tree=%s"%(tree.root.getSubtreeAsText()))
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1958
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1959 return tree
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1960
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1961
276
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1962 def index_xml(self):
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1963 """default xml representation"""
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1964 # get template
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1965 pt = self.allprojects_xml
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1966 # render template
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1967 return pt()
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1968
c886c0cb3455 added xml export for projects.
casties
parents: 265
diff changeset
1969
260
4eddd388d490 more work on subproject thumbs.
casties
parents: 257
diff changeset
1970 def getProjectsAsList(self, start=None, active=1, archived=1, depthFirst=True, filter=None):
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
1971 """Return flattened list of projects, starting from start.
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
1972
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1973 active = 0 : all projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1974 active = 1 : active projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1975 active = 2 : inactive projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1976 archived = 0 : all projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1977 archived = 1 : current projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1978 archived = 2 : archived projects
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1979 """
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
1980 # logging.debug("getProjectsAsList(start=%s,active=%s,archived=%s)"%(repr(start),active,archived))
34
b8ced08ebea9 working on projects.
casties
parents: 33
diff changeset
1981 tree = self.getProjectTree()
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1982 node = tree.getNode(start)
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1983 if node is None:
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1984 return []
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1985
105
246d87d33f25 CLOSED - # 79: sortierung der liste der projekte pro abteilung
casties
parents: 102
diff changeset
1986 pl = node.getSubtreeAsList(depthFirst=depthFirst)
228
afc96bc56817 also show multiple projects with the same number (including none) in the tree.
casties
parents: 222
diff changeset
1987 #logging.debug("getProjectsAsList: tree=%s"%node.getSubtreeAsText())
afc96bc56817 also show multiple projects with the same number (including none) in the tree.
casties
parents: 222
diff changeset
1988 #logging.debug("getProjectsAsList: node=(%s,%s) pl=%s"%(node.key,node.value,repr(pl)))
114
1acfcaaa5ca3 fixed HashTree.getSubTreeAsList when using breadth first.
casties
parents: 108
diff changeset
1989 #logging.debug("getProjectsAsList: node=(%s,%s) pl=%s"%(node.key,node.value,[p.getNumber() for p in pl]))
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
1990 # return filtered list
260
4eddd388d490 more work on subproject thumbs.
casties
parents: 257
diff changeset
1991 return [p for p in pl if ((filter is None or filter(p)) and p.checkActive(active) and p.checkArchived(archived))]
4eddd388d490 more work on subproject thumbs.
casties
parents: 257
diff changeset
1992 #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
1993
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
1994
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
1995 def getProject(self, projectNumber=None):
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
1996 """Return the matching project"""
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
1997 tree = self.getProjectTree()
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
1998 if projectNumber is not None:
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
1999 return tree.get(projectNumber)
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2000
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2001 return None
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2002
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2003
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2004 def getProjectsOfMember(self, key, active=1, archived=1):
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
2005 """Return a list of all projects of a member.
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2006
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2007 @param key: member's key
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2008 active = 0 : all projects
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2009 active = 1 : active projects
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2010 active = 2 : inactive projects
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2011 archived = 0 : all projects
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2012 archived = 1 : current projects
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2013 archived = 2 : archived projects
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2014 """
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2015 projects = []
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2016 # search project numbers
222
95e0087b9e19 removed some comparisons that ignore person-id case.
casties
parents: 214
diff changeset
2017 res = self.executeZSQL("select * from projects_members where member_key = %s", [key])
77
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2018 # find projects in folder
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2019 for r in res:
77
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2020 p = self.get(r.project_id, None)
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
2021 # check if active
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2022 if p is not None and p.checkActive(active) and p.checkArchived(archived):
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2023 projects.append(p)
77
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2024
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2025 # sort by project number
79
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2026 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
2027 return projects
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2028
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2029
79
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2030 def getMembersWithProjects(self, onlyActive=True):
77
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2031 """Return a list of all members that have projects.
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2032
79
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2033 @param onlyActive: only active members
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2034
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2035 Returns a list of member objects.
77
96b71e761dac more work on project lists.
casties
parents: 74
diff changeset
2036 """
79
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2037 members = []
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2038 sf = self.en.getStaffFolder()
222
95e0087b9e19 removed some comparisons that ignore person-id case.
casties
parents: 214
diff changeset
2039 res = self.executeZSQL('select distinct member_key from projects_members')
79
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2040 if onlyActive:
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2041 for r in res:
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2042 m = sf.getMember(key=r.member_key)
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2043 if m is not None and m.isActive():
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2044 members.append(m)
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2045
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2046 else:
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2047 # not only active
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2048 members = [sf.getMember(key=r.member_key) for r in res]
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2049
7f26c8e6c8e9 more styles for project lists.
casties
parents: 78
diff changeset
2050 return members
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2051
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2052
99
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
2053 def resetProjectTree(self):
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
2054 """Reset the project tree."""
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
2055 self._v_projectTree = None
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
2056
84fa3f62ed85 editing project number clears cached project tree.
casties
parents: 97
diff changeset
2057
51
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2058 security.declareProtected('View management screens', 'changeProjectTree')
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2059 def changeProjectTree(self, RESPONSE=None):
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2060 """change the complete tree"""
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2061 form=self.REQUEST.form
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2062 onlyArchived=int(form.get("onlyArchived",0))
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2063 onlyActive=int(form.get("onlyActive",0))
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2064 dep=form.get("dep",None)
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2065
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2066 fields = self.getProjectsAsList(start=dep, archived=onlyArchived, active=onlyActive)
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2067
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2068 logging.info("GOT TREE!----------------------------------------------------")
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2069 for field in form.keys():
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2070
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2071 splitted=field.split('_')
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2072 if (len(splitted)>1) and (splitted[1]=="runningNumber"):
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2073 #feld hat die Form Nummer_name und runnignNumber
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2074 nr=int(splitted[0]) # nummer des Datensatzes
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2075 project = fields[nr]
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2076
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2077 #
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2078 # change active
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2079 #
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2080 if form.has_key('%s_active'%nr): # active flag is set
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2081 project.setActiveFlag(True)
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2082 else:
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2083 project.setActiveFlag(False)
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2084
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2085 #
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2086 # nummer hat sich geaendert
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2087 #
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2088 entryChanged = False;
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2089 pronum = project.getNumber()
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2090 formnum = form['%s_number'%nr]
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2091
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2092 if not (pronum == formnum):
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2093 logging.debug("Changed!Number+++++++++++++++++++++++++++++++++")
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2094 logging.debug(repr(fields[nr].xdata_05)+" ---> "+ repr(form[str(nr)+'_number']))
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2095 entryChanged = True
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2096
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2097 #
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2098 # completed hat sich geaendert
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2099 #
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2100 td = project.transformDate # hole die funktion zum transformieren des datums
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2101 formstarted = form[str(nr)+'_started']
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2102 formcompleted = form[str(nr)+'_completed']
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2103
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2104 if not (td(project.getCompletedAt()) == td(formcompleted)):
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2105 logging.info(repr(td(project.getCompletedAt()))+" ---> "+ repr(td(form[str(nr)+'_completed'])))
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2106 logging.info("Changed!Completed+++++++++++++++++++++++++++++++++")
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2107 entryChanged = True
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2108
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2109 if not (td(project.getStartedAt()) == td(formstarted)):
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2110 logging.info(repr(td(project.getStartedAt()))+" ---> "+ repr(td(form[str(nr)+'_started'])))
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2111 logging.info("Changed!Started+++++++++++++++++++++++++++++++++")
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2112 entryChanged = True
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2113
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2114 if entryChanged:
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2115 logging.info("Changed!+++++++++++++++++++++++++++++++++")
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2116 project.copyObjectToArchive()
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2117 project.xdata_05 = formnum
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2118 project.setCompletedAt(formcompleted)
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2119 project.setStartedAt(formstarted)
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2120 # reset tree
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2121 self._v_projectTree = None
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2122
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2123 if RESPONSE is not None:
214
f7d8d12b203b reverting to 303 # 130: sortProjects funktioniert nicht
casties
parents: 213
diff changeset
2124 RESPONSE.redirect(self.en.MPIWGrootURL()+'/admin/showTree', status=303)
51
d456fe185649 more work on projects. more cleanup.
casties
parents: 50
diff changeset
2125
52
1ed79b33200c more work on projects and cleanup.
casties
parents: 51
diff changeset
2126
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
2127 security.declareProtected('View management screens', 'updateAllProjectMembers')
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2128 def updateAllProjectMembers(self, updateResponsibleScientistsList=False):
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
2129 """Re-create responsibleScientistsLists and projects_members table from all current projects."""
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2130 # empty table
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2131 self.executeZSQL('truncate table projects_members')
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2132 cnt = 0
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2133 # go through all projects
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2134 for p in self.objectValues(spec='MPIWGProject'):
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2135 cnt += 1
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
2136 logging.debug("updateAllProjectMembers: updating project %s" % p)
36
dbe037d2f574 working on projects.
casties
parents: 35
diff changeset
2137 p.updateProjectMembers(updateResponsibleScientistsList=updateResponsibleScientistsList)
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2138
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
2139 return "updated %s projects!" % cnt
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2140
40
fd8e78bbc5ed more work on projects.
casties
parents: 39
diff changeset
2141
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2142 security.declareProtected('View management screens', 'updateAllProjects')
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2143 def updateAllProjects(self, updateResponsibleScientistsList=False, RESPONSE=None):
43
196db636a8fd fixed sorting of project lists.
casties
parents: 42
diff changeset
2144 """Patch all current projects for legacy problems."""
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2145 cnt = 0
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2146 fulllog = ""
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2147 # go through all projects
123
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2148 for id, project in self.ZopeFind(self, obj_metatypes=['MPIWGProject'], search_sub=1):
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2149 log = ""
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2150 cnt += 1
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2151 #
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2152 # hasRelatedPublicationsOldVersion
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2153 #
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2154 if project.hasRelatedPublicationsOldVersion():
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2155 log += "%s: update relatedPublicationsOldVersion!\n"%project.getId()
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2156 logging.debug("updateAllProjects(%s): update relatedPublicationsOldVersion!"%project.getId())
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2157 project.copyPublicationsToList()
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2158
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2159 #
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2160 # create responsibleScientistsList automatically
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2161 #
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2162 if updateResponsibleScientistsList:
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2163 newScientists = {}
65
63184d71c014 lots of cleaning up.
casties
parents: 64
diff changeset
2164 names = project.identifyNames(project.getResponsibleScientists())
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2165 for name in names:
123
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2166 msg = "%s: regenerating responsibleScientistsList: name=%s\n"%(project.getId(), repr(name))
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2167 log += msg
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2168 logging.debug(msg)
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2169 members = names[name]
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2170 if len(members) > 0:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2171 # take the first matching name
123
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2172 username = None
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2173 if members[0].e_mail:
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2174 username = re.sub('@mpiwg-berlin\.mpg\.de', '', members[0].e_mail)
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2175 newScientists[name] = {'name': name, 'key' : members[0].key, 'username' : username}
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2176
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2177 project.setResponsibleScientistsList(newScientists)
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2178
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2179 else:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2180 #
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2181 # old format responsibleScientistsList
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2182 #
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2183 memberlist = project.getResponsibleScientistsList()
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2184 if len(memberlist) > 0 and isinstance(memberlist[0], tuple):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2185 log += "%s: updating memberlist!\n"%project.getId()
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2186 logging.debug("updateAllProjects(%s): updating memberlist" % project.getId())
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2187 newScientists = {}
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2188 for m in memberlist:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2189 name = m[0]
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2190 key = m[1]
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2191 username = None
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2192 if key:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2193 if isinstance(key, list):
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2194 key = key[0]
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2195
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2196 # get username from db
80
b1893c4c9d2c more display of project pages.
casties
parents: 79
diff changeset
2197 member = self.en.getMPIWGRoot().getStaffFolder().getMember(key=key)
60
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2198 if member is not None:
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2199 username = member.getUsername()
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2200
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2201 newScientists[name] = {'name': name, 'key' : key, 'username' : username}
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2202
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2203 # set new list
dc41deabc8f8 more work on projects. more cleanup.
casties
parents: 58
diff changeset
2204 project.setResponsibleScientistsList(newScientists)
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2205
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2206 #
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2207 # old inline images
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2208 #
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2209 if project.hasInlineImage():
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2210 log += "%s: has inlineImage!\n"%project.getId()
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2211 logging.debug("updateAllProjects(%s): has inlineImage!"%project.getId())
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2212 try:
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2213 project.copyImageToMargin()
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2214 except Exception, e:
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2215 log += "%s: ERROR in copyImageToMargin!\n"%project.getId()
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2216 logging.debug("updateAllProjects(%s): ERROR in copyImageToMargin: %s"%(project.getId(), e))
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2217
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2218
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2219 #
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2220 # remove old attributes
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2221 #
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2222 if hasattr(project, 'definedFields'):
49
e40ff9829108 improved old project inline image handling.
casties
parents: 45
diff changeset
2223 log += "%s: has definedFields!\n"%project.getId()
39
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2224 logging.debug("updateAllProjects(%s): has definedFields!"%project.getId())
bbad6a092861 more work on projects.
casties
parents: 36
diff changeset
2225 delattr(project, 'definedFields')
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
2226
45
5c6ad316e1ce prepare updating project extended publications.
casties
parents: 44
diff changeset
2227 #
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
2228 # update related publications
45
5c6ad316e1ce prepare updating project extended publications.
casties
parents: 44
diff changeset
2229 #
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
2230 for pub in project.getPublicationList():
62
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2231 if not pub.text:
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2232 msg = "%s: publication has no text: %s!\n"%(project.getId(), pub)
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2233 log += msg
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2234 logging.warn(msg)
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2235 if not pub.link:
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2236 msg = "%s: publication has no link either! Deleting: %s!\n"%(project.getId(), pub)
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2237 log += msg
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2238 logging.error(msg)
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2239 project.deletePublication(pub.getId())
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2240
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2241 else:
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2242 # hasLinkToBookPage updates the bookId
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2243 pub.hasLinkToBookPage()
61
04fb655633ef more cleaning up projects.
casties
parents: 60
diff changeset
2244
81
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
2245
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
2246 #
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
2247 # update RelatedDigitalSources
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
2248 #
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
2249 project.moveObjectDigitallibraryToInfoBlock()
975a8d88e315 new editable info blocks for projects.
casties
parents: 80
diff changeset
2250
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2251 #
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2252 # unicodify
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2253 #
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2254 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
2255 'WEB_project_description', 'WEB_related_pub'):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2256 text = getattr(project, field, None)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2257 if isinstance(text, str):
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2258 log += "%s: has non-unicode field %s\n"%(project.getId(), field)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2259 logging.debug("updateAllProjects(%s): has has non-unicode field %s\n"%(project.getId(), field))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2260 setattr(project, field, unicodify(text))
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2261
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2262 fulllog += log
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2263 if RESPONSE is not None:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2264 RESPONSE.write(log)
62
64be5db08495 more cleaning projects.
casties
parents: 61
diff changeset
2265
123
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2266 #
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2267 # remove obsolete static class members (does this make sense?)
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2268 #
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2269 if hasattr(MPIWGProject, 'responsibleScientistsList'):
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2270 log += "MPIWGProject has class member responsibleScientistsList\n"
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2271 logging.debug("MPIWGProject has class member responsibleScientistsList\n")
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2272 del MPIWGProject.responsibleScientistsList
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2273
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2274 if hasattr(MPIWGProject, 'projectThumb'):
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2275 log += "MPIWGProject has class member projectThumb\n"
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2276 logging.debug("MPIWGProject has class member projectThumb\n")
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2277 del MPIWGProject.projectThumb
220f37701e8d fix problem with empty responsible scientists field.
casties
parents: 114
diff changeset
2278
50
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2279 log += "\n DONE! updated %s projects!" % cnt
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2280 fulllog += log
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2281 if RESPONSE is not None:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2282 RESPONSE.write(log)
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2283 RESPONSE.flush()
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2284 else:
e30a4bd074db more cleaning up projects.
casties
parents: 49
diff changeset
2285 return fulllog
127
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2286
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2287 def scaleImages(self,REQUEST=None):
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2288 """scaleImages"""
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2289 prjs = self.getProjectsAsList()
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2290 for prj in prjs:
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2291 prj.scaleImage(REQUEST=REQUEST)
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2292 logging.debug(prj.getId())
4a8a532a05ba scale images
dwinter
parents: 123
diff changeset
2293
33
01b5265264b6 more work on projects.
casties
parents: 29
diff changeset
2294
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2295 def manage_addMPIWGProjectFolderForm(self):
29
224023958871 renamed method.
casties
parents: 27
diff changeset
2296 """form for adding a MPIWGProjectFolder"""
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2297 pt = PageTemplateFile('zpt/project/manage_add_MPIWGProjectFolder', globals()).__of__(self)
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2298 return pt()
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2299
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
2300 def manage_addMPIWGProjectFolder(self, id, title, RESPONSE=None):
29
224023958871 renamed method.
casties
parents: 27
diff changeset
2301 """add a MPIWGProjectFolder"""
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
2302 newObj = MPIWGProjectFolder(id, title)
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2303
35
38cbbeaf266b more work on projects.
casties
parents: 34
diff changeset
2304 self._setObject(id, newObj)
27
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2305
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2306 if RESPONSE is not None:
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2307 RESPONSE.redirect('manage_main')
9a75eb1b31b3 more work on projects.
casties
parents: 24
diff changeset
2308