merge branch master
This commit is contained in:
		
						commit
						7ed73e28b5
					
				
					 6 changed files with 69 additions and 7 deletions
				
			
		| 
						 | 
					@ -69,7 +69,7 @@ from loops.resource import Resource
 | 
				
			||||||
from loops.security.common import canAccessObject, canListObject, canWriteObject
 | 
					from loops.security.common import canAccessObject, canListObject, canWriteObject
 | 
				
			||||||
from loops.type import ITypeConcept
 | 
					from loops.type import ITypeConcept
 | 
				
			||||||
from loops import util
 | 
					from loops import util
 | 
				
			||||||
from loops.util import _
 | 
					from loops.util import _, saveRequest
 | 
				
			||||||
from loops import version
 | 
					from loops import version
 | 
				
			||||||
from loops.versioning.interfaces import IVersionable
 | 
					from loops.versioning.interfaces import IVersionable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -145,6 +145,7 @@ class BaseView(GenericView, I18NView):
 | 
				
			||||||
                raise Unauthorized(str(self.contextInfo))
 | 
					                raise Unauthorized(str(self.contextInfo))
 | 
				
			||||||
        except ForbiddenAttribute:  # ignore when testing
 | 
					        except ForbiddenAttribute:  # ignore when testing
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					        saveRequest(request)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def checkPermissions(self):
 | 
					    def checkPermissions(self):
 | 
				
			||||||
        return canAccessObject(self.context)
 | 
					        return canAccessObject(self.context)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,6 +41,10 @@ book_template = ViewPageTemplateFile('view_macros.pt')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Base(object):
 | 
					class Base(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Lazy
 | 
				
			||||||
 | 
					    def book_macros(self):
 | 
				
			||||||
 | 
					        return book_template.macros
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Lazy
 | 
					    @Lazy
 | 
				
			||||||
    def isPartOfPredicate(self):
 | 
					    def isPartOfPredicate(self):
 | 
				
			||||||
        return self.conceptManager['ispartof']
 | 
					        return self.conceptManager['ispartof']
 | 
				
			||||||
| 
						 | 
					@ -50,6 +54,29 @@ class Base(object):
 | 
				
			||||||
        for p in self.context.getParents([self.isPartOfPredicate]):
 | 
					        for p in self.context.getParents([self.isPartOfPredicate]):
 | 
				
			||||||
            return self.nodeView.getViewForTarget(p)
 | 
					            return self.nodeView.getViewForTarget(p)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Lazy
 | 
				
			||||||
 | 
					    def neighbours(self):
 | 
				
			||||||
 | 
					        pred = succ = None
 | 
				
			||||||
 | 
					        parent = self.breadcrumbsParent
 | 
				
			||||||
 | 
					        if parent is not None:
 | 
				
			||||||
 | 
					            myself = None
 | 
				
			||||||
 | 
					            children = list(parent.context.getChildren([self.isPartOfPredicate]))
 | 
				
			||||||
 | 
					            for idx, c in enumerate(children):
 | 
				
			||||||
 | 
					                if c == self.context:
 | 
				
			||||||
 | 
					                    if idx > 0:
 | 
				
			||||||
 | 
					                        pred = self.nodeView.getViewForTarget(children[idx-1])
 | 
				
			||||||
 | 
					                    if idx < len(children) - 1:
 | 
				
			||||||
 | 
					                        succ = self.nodeView.getViewForTarget(children[idx+1])
 | 
				
			||||||
 | 
					        return pred, succ
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Lazy
 | 
				
			||||||
 | 
					    def predecessor(self):
 | 
				
			||||||
 | 
					        return self.neighbours[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Lazy
 | 
				
			||||||
 | 
					    def successor(self):
 | 
				
			||||||
 | 
					        return self.neighbours[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Lazy
 | 
					    @Lazy
 | 
				
			||||||
    def tabview(self):
 | 
					    def tabview(self):
 | 
				
			||||||
        if self.editable:
 | 
					        if self.editable:
 | 
				
			||||||
| 
						 | 
					@ -73,6 +100,10 @@ class SectionView(Base, ConceptView):
 | 
				
			||||||
    def documentTypeType(self):
 | 
					    def documentTypeType(self):
 | 
				
			||||||
        return self.conceptManager['documenttype']
 | 
					        return self.conceptManager['documenttype']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Lazy
 | 
				
			||||||
 | 
					    def showNavigation(self):
 | 
				
			||||||
 | 
					        return self.typeOptions.show_navigation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Lazy
 | 
					    @Lazy
 | 
				
			||||||
    def sectionType(self):
 | 
					    def sectionType(self):
 | 
				
			||||||
        return self.conceptManager['section']
 | 
					        return self.conceptManager['section']
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,24 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<metal:section define-macro="section">
 | 
					<metal:section define-macro="section">
 | 
				
			||||||
 | 
					  <metal:navigation define-macro="navigation"
 | 
				
			||||||
 | 
					                    tal:condition="item/showNavigation">
 | 
				
			||||||
 | 
					    <div tal:define="parent nocall:item/breadcrumbsParent;
 | 
				
			||||||
 | 
					                     pred nocall:item/predecessor;
 | 
				
			||||||
 | 
					                     succ nocall:item/successor">
 | 
				
			||||||
 | 
					      <a tal:condition="nocall:pred"
 | 
				
			||||||
 | 
					         tal:attributes="href pred/targetUrl;
 | 
				
			||||||
 | 
					                         title pred/title">
 | 
				
			||||||
 | 
					        <img src="/@@/cybertools.icons/arrow_left.png" /></a>
 | 
				
			||||||
 | 
					      <a tal:attributes="href parent/targetUrl;
 | 
				
			||||||
 | 
					                          title parent/title">
 | 
				
			||||||
 | 
					        <img src="/@@/cybertools.icons/arrow_up.png" /></a>
 | 
				
			||||||
 | 
					      <a  tal:condition="nocall:succ"
 | 
				
			||||||
 | 
					          tal:attributes="href succ/targetUrl;
 | 
				
			||||||
 | 
					                          title succ/title">
 | 
				
			||||||
 | 
					        <img src="/@@/cybertools.icons/arrow_right.png" /></a>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </metal:navigation>
 | 
				
			||||||
  <metal:info use-macro="view/concept_macros/concepttitle" />
 | 
					  <metal:info use-macro="view/concept_macros/concepttitle" />
 | 
				
			||||||
  <div tal:repeat="related item/textResources">
 | 
					  <div tal:repeat="related item/textResources">
 | 
				
			||||||
    <div class="span-4">
 | 
					    <div class="span-4">
 | 
				
			||||||
| 
						 | 
					@ -57,6 +75,9 @@
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 | 
					  <br style="clear: both" />
 | 
				
			||||||
 | 
					  <metal:navigation use-macro="item/book_macros/navigation" />
 | 
				
			||||||
 | 
					  <br />
 | 
				
			||||||
</metal:section>
 | 
					</metal:section>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,15 +78,16 @@ class OfficeFile(ExternalFileAdapter):
 | 
				
			||||||
    @Lazy
 | 
					    @Lazy
 | 
				
			||||||
    def docPropertyDom(self):
 | 
					    def docPropertyDom(self):
 | 
				
			||||||
        fn = self.docFilename
 | 
					        fn = self.docFilename
 | 
				
			||||||
 | 
					        dummy = dict(core=[], custom=[])
 | 
				
			||||||
        root, ext = os.path.splitext(fn)
 | 
					        root, ext = os.path.splitext(fn)
 | 
				
			||||||
        if not ext.lower() in self.fileExtensions:
 | 
					        if not ext.lower() in self.fileExtensions:
 | 
				
			||||||
            return []
 | 
					            return dummy
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            zf = ZipFile(fn, 'r')
 | 
					            zf = ZipFile(fn, 'r')
 | 
				
			||||||
        except IOError, e:
 | 
					        except IOError, e:
 | 
				
			||||||
            from logging import getLogger
 | 
					            from logging import getLogger
 | 
				
			||||||
            self.logger.warn(e)
 | 
					            self.logger.warn(e)
 | 
				
			||||||
            return []
 | 
					            return dummy
 | 
				
			||||||
        if self.corePropFileName not in zf.namelist():
 | 
					        if self.corePropFileName not in zf.namelist():
 | 
				
			||||||
            self.logger.warn('Core properties not found in file %s.' %
 | 
					            self.logger.warn('Core properties not found in file %s.' %
 | 
				
			||||||
                             self.externalAddress)
 | 
					                             self.externalAddress)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +61,7 @@ actions.register('editTopic', 'portlet', DialogAction,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
actions.register('createQualification', 'portlet', DialogAction,
 | 
					actions.register('createQualification', 'portlet', DialogAction,
 | 
				
			||||||
        title=_(u'Create Qualification Record...'),
 | 
					        title=_(u'Create Qualification Record...'),
 | 
				
			||||||
        description=_(u'Create a work item for this person.'),
 | 
					        description=_(u'Create a qualification record for this person.'),
 | 
				
			||||||
        viewName='create_qualification.html',
 | 
					        viewName='create_qualification.html',
 | 
				
			||||||
        dialogName='createQualification',
 | 
					        dialogName='createQualification',
 | 
				
			||||||
        prerequisites=['registerDojoDateWidget', 'registerDojoNumberWidget',
 | 
					        prerequisites=['registerDojoDateWidget', 'registerDojoNumberWidget',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								util.py
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								util.py
									
										
									
									
									
								
							| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  Copyright (c) 2011 Helmut Merz helmutm@cy55.de
 | 
					#  Copyright (c) 2012 Helmut Merz helmutm@cy55.de
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  This program is free software; you can redistribute it and/or modify
 | 
					#  This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
#  it under the terms of the GNU General Public License as published by
 | 
					#  it under the terms of the GNU General Public License as published by
 | 
				
			||||||
| 
						 | 
					@ -18,8 +18,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Utility functions.
 | 
					Utility functions.
 | 
				
			||||||
 | 
					 | 
				
			||||||
$Id$
 | 
					 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
| 
						 | 
					@ -28,6 +26,7 @@ from zope.interface import directlyProvides, directlyProvidedBy
 | 
				
			||||||
from zope.intid.interfaces import IIntIds
 | 
					from zope.intid.interfaces import IIntIds
 | 
				
			||||||
from zope.i18nmessageid import MessageFactory
 | 
					from zope.i18nmessageid import MessageFactory
 | 
				
			||||||
from zope.schema import vocabulary
 | 
					from zope.schema import vocabulary
 | 
				
			||||||
 | 
					from zope import thread
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cybertools
 | 
					import cybertools
 | 
				
			||||||
from loops.browser.util import html_quote
 | 
					from loops.browser.util import html_quote
 | 
				
			||||||
| 
						 | 
					@ -134,3 +133,12 @@ def getLogDirectory(request=None):
 | 
				
			||||||
    return os.path.join(os.path.dirname(varDir), 'log')
 | 
					    return os.path.join(os.path.dirname(varDir), 'log')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# store thread-local stuff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local_data = thread.local()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def saveRequest(request):
 | 
				
			||||||
 | 
					    local_data.request = request
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def getRequest():
 | 
				
			||||||
 | 
					    return local_data.request
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue