comparison MPIWGProjects.py @ 65:63184d71c014

lots of cleaning up.
author casties
date Fri, 03 May 2013 18:23:01 +0200
parents b5ff783027d6
children e424b68244c8
comparison
equal deleted inserted replaced
64:b5ff783027d6 65:63184d71c014
3 3
4 $author dwinter 26.06.2008 4 $author dwinter 26.06.2008
5 5
6 """ 6 """
7 from Products.PageTemplates.PageTemplateFile import PageTemplateFile 7 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
8 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
9 from Products.ZCatalog.CatalogPathAwareness import CatalogAware
10 from OFS.Image import Image 8 from OFS.Image import Image
11 from App.ImageFile import ImageFile 9 from App.ImageFile import ImageFile
12 from OFS.SimpleItem import SimpleItem 10 from OFS.SimpleItem import SimpleItem
13 from OFS.Folder import Folder 11 from OFS.Folder import Folder
14 from OFS.Image import Image
15 from OFS.Cache import Cacheable
16 from AccessControl import ClassSecurityInfo 12 from AccessControl import ClassSecurityInfo
17 from AccessControl import getSecurityManager
18 from Globals import package_home 13 from Globals import package_home
19 import urllib 14 import urllib
20 import re 15 import re
21 import os 16 import os
22 import email 17 import email
23 import xmlhelper # Methoden zur Verwaltung der projekt xml 18 import xmlhelper # Methoden zur Verwaltung der projekt xml
24 import xmlrpclib
25 import sys 19 import sys
26 from types import *
27 import logging 20 import logging
28 import time 21 import time
29 22
30 import xml.etree.ElementTree as ET 23 import xml.etree.ElementTree as ET
31 24
32 from SrvTxtUtils import getInt, unicodify, utf8ify, serialize, refreshingImageFileIndexHtml 25 from SrvTxtUtils import getInt, unicodify, utf8ify, serialize, refreshingImageFileIndexHtml, shortenString
33 from Products.MPIWGBibliography.BibliographyManager import BibliographyManager
34 from bibliography import *
35 from Products.ZDBInterface.ZDBInterfaceFolder import ZDBInterfaceFolder 26 from Products.ZDBInterface.ZDBInterfaceFolder import ZDBInterfaceFolder
36 # import xml.dom.minidom
37 # from Ft.Xml.XPath import Evaluate
38 # from Ft.Xml.XPath.Context import Context
39 # from Ft.Xml.Domlette import NonvalidatingReader,PrettyPrint, Print
40 # from Ft.Xml import EMPTY_NAMESPACE
41 # import copy
42 # import updatePersonalWWW
43
44 # import MPIWGStaff
45 27
46 from HashTree import HashTree 28 from HashTree import HashTree
47 from MPIWGHelper import *
48 29
49 import MPIWGRoot 30 import MPIWGRoot
50 import MPIWGLink 31 import MPIWGLink
51 import MPIWGTemplate 32 import MPIWGTemplate
52
53 import transaction
54
55 33
56 # TODO: better names for the fields 34 # TODO: better names for the fields
57 fieldLabels = {'WEB_title':'WEB_Title', 35 fieldLabels = {'WEB_title':'WEB_Title',
58 'xdata_01':'Responsible Scientists', 36 'xdata_01':'Responsible Scientists',
59 'xdata_02':'Department', 37 'xdata_02':'Department',
95 73
96 text = None 74 text = None
97 link = None 75 link = None
98 bookId = None 76 bookId = None
99 77
78 # templates
100 editDescription = PageTemplateFile('zpt/project/related_publication/edit_basic', globals()) 79 editDescription = PageTemplateFile('zpt/project/related_publication/edit_basic', globals())
101 80
102 81
103 def redirect(self, RESPONSE, url): 82 def redirect(self, RESPONSE, url):
104 """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen""" 83 """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen"""
253 class MPIWGProject_image(Image): 232 class MPIWGProject_image(Image):
254 """Images for Projects""" 233 """Images for Projects"""
255 234
256 meta_type = "MPIWGProject_image" 235 meta_type = "MPIWGProject_image"
257 236
258 def showImage(self, imageUrl=None): 237 # templates
259 """show Images at an extra page""" 238 showImage = PageTemplateFile('zpt/project/image/projectImageView', globals())
260 #self.getContent('WEB_project_description', filter='yes') # get the content and store image infos into session 239 editForm = PageTemplateFile('zpt/project/image/edit_basic', globals())
261 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'projectImageView.zpt')).__of__(self) 240
262 return pt()
263
264 def editImage(self, file=None, caption=None, RESPONSE=None): 241 def editImage(self, file=None, caption=None, RESPONSE=None):
265 """edit the Image""" 242 """edit the Image"""
266 if (not file) and (not caption): 243 if (not file) and (not caption):
267 pt = PageTemplateFile(os.path.join(package_home(globals()), 'zpt', 'edit_imageForm.zpt')).__of__(self) 244 pt = self.editForm
268 return pt() 245 return pt()
269 246
270 if file and (not file.filename.lstrip().rstrip() == ""): 247 if file and (not file.filename.lstrip().rstrip() == ""):
271 self.manage_upload(file) 248 self.manage_upload(file)
272 249
275 252
276 if RESPONSE: 253 if RESPONSE:
277 self.redirect(RESPONSE, "../manageImages") 254 self.redirect(RESPONSE, "../manageImages")
278 255
279 256
280 class MPIWGProject(CatalogAware, Folder, Cacheable): 257 class MPIWGProject(Folder):
281 """Class for Projects""" 258 """Class for Projects"""
282 259
283 security = ClassSecurityInfo() 260 security = ClassSecurityInfo()
284 meta_type = 'MPIWGProject' 261 meta_type = 'MPIWGProject'
285 262
323 # management templates 300 # management templates
324 loadNewFileForm = PageTemplateFile('zpt/project/manage_newfile', globals()) 301 loadNewFileForm = PageTemplateFile('zpt/project/manage_newfile', globals())
325 description_only_html = PageTemplateFile('zpt/project/description_only_html', globals()) 302 description_only_html = PageTemplateFile('zpt/project/description_only_html', globals())
326 # additional pages 303 # additional pages
327 additionalPublications = PageTemplateFile('zpt/project/pubman/show_publications', globals()) 304 additionalPublications = PageTemplateFile('zpt/project/pubman/show_publications', globals())
328 305 # TODO: remove compat
329 # TODO: this should go away
330 extendedBibliography = PageTemplateFile('zpt/project/extendedBibliography_template', globals())
331 # TODO: compat
332 edit_MPIWGProject_main = edit_template 306 edit_MPIWGProject_main = edit_template
333 307
334 308
335 def __init__(self, id, argv=None): 309 def __init__(self, id, argv=None):
336 """initiere classe""" 310 """initiere classe"""
492 return self.absolute_url() 466 return self.absolute_url()
493 467
494 return '%s/%s' % (baseUrl, self.getId()) 468 return '%s/%s' % (baseUrl, self.getId())
495 469
496 470
497 def getThumbUrl(self, default='http://defaultthumb.jpg'): 471 def getThumbUrl(self, default=None):
498 """returns the URL of the project thumbnail image""" 472 """returns the URL of the project thumbnail image"""
499 thumb = self.projectThumb 473 thumb = self.projectThumb
500 if thumb is None: 474 if thumb is None:
501 # get thumb from list (thumb is last image) 475 # get thumb from list (thumb is last image)
502 imgs = self.getImageList() 476 imgs = self.getImageList()
503 url = default
504 if len(imgs) > 0: 477 if len(imgs) > 0:
505 thumb = imgs[-1] 478 thumb = imgs[-1]
506 self.projectThumb = thumb 479 self.projectThumb = thumb
507 480
508 if thumb is None: 481 if thumb is None:
1785 # 1758 #
1786 # create responsibleScientistsList automatically 1759 # create responsibleScientistsList automatically
1787 # 1760 #
1788 if updateResponsibleScientistsList: 1761 if updateResponsibleScientistsList:
1789 newScientists = {} 1762 newScientists = {}
1790 names = project.identifyNames(p.getResponsibleScientists()) 1763 names = project.identifyNames(project.getResponsibleScientists())
1791 for name in names: 1764 for name in names:
1792 logging.debug("updateAllProjectMembers: name=%s" % repr(name)) 1765 logging.debug("updateAllProjectMembers: name=%s" % repr(name))
1793 members = names[name] 1766 members = names[name]
1794 if len(members) > 0: 1767 if len(members) > 0:
1795 # take the first matching name 1768 # take the first matching name