provide a simple compound view to be used for combinations of data/info views and report views
This commit is contained in:
parent
f91a498342
commit
133a9e8018
8 changed files with 96 additions and 4 deletions
4
browser/compound/__init__.py
Normal file
4
browser/compound/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
package loops.browser.compound
|
||||
"""
|
||||
|
14
browser/compound/configure.zcml
Normal file
14
browser/compound/configure.zcml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<configure
|
||||
xmlns:zope="http://namespaces.zope.org/zope"
|
||||
xmlns:browser="http://namespaces.zope.org/browser"
|
||||
i18n_domain="loops">
|
||||
|
||||
<zope:adapter
|
||||
name="compound.html"
|
||||
for="loops.interfaces.IConcept
|
||||
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.browser.compound.standard.CompoundView"
|
||||
permission="zope.View" />
|
||||
|
||||
</configure>
|
54
browser/compound/standard.py
Normal file
54
browser/compound/standard.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""
|
||||
Definition of compound views.
|
||||
"""
|
||||
|
||||
from zope import interface, component
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from loops.browser.concept import ConceptView
|
||||
from loops.util import _
|
||||
|
||||
|
||||
compound_macros = ViewPageTemplateFile('view_macros.pt')
|
||||
|
||||
|
||||
class CompoundView(ConceptView):
|
||||
|
||||
@Lazy
|
||||
def macro(self):
|
||||
return compound_macros.macros['standard']
|
||||
|
||||
def getParts(self):
|
||||
parts = (self.options('view_parts') or self.typeOptions('view_parts') or [])
|
||||
return self.getPartViews(parts)
|
||||
|
||||
def getPartViews(self, parts):
|
||||
result = []
|
||||
for p in parts:
|
||||
view = component.queryMultiAdapter((self.adapted, self.request), name=p)
|
||||
if view is None:
|
||||
view = component.queryMultiAdapter((self.context, self.request), name=p)
|
||||
if view is not None:
|
||||
view.parent = self
|
||||
result.append(view)
|
||||
return result
|
||||
|
11
browser/compound/view_macros.pt
Normal file
11
browser/compound/view_macros.pt
Normal file
|
@ -0,0 +1,11 @@
|
|||
<html i18n:domain="loops">
|
||||
|
||||
|
||||
<metal:data define-macro="standard">
|
||||
<tal:part repeat="item item/getParts">
|
||||
<metal:part use-macro="item/macro" />
|
||||
</tal:part>
|
||||
</metal:data>
|
||||
|
||||
|
||||
</html>
|
|
@ -235,6 +235,7 @@ class ConceptView(BaseView):
|
|||
subMacro=concept_macros.macros['parents'],
|
||||
priority=20, info=self)
|
||||
|
||||
# the part-based layout is now implemented in loops.browser.compound
|
||||
def getParts(self):
|
||||
parts = (self.params.get('parts') or []) # deprecated!
|
||||
if not parts:
|
||||
|
|
|
@ -765,6 +765,7 @@
|
|||
attribute="cleanup"
|
||||
permission="zope.ManageSite" />
|
||||
|
||||
<include package=".compound" />
|
||||
<include package=".skin" />
|
||||
<include package=".lobo" />
|
||||
<include package=".mobile" />
|
||||
|
|
|
@ -132,6 +132,9 @@ class ResourceView(BaseView):
|
|||
def macro(self):
|
||||
if 'image/' in self.context.contentType:
|
||||
return self.template.macros['image']
|
||||
#elif 'audio/' in self.context.contentType:
|
||||
# self.registerDojoAudio()
|
||||
# return self.template.macros['audio']
|
||||
else:
|
||||
return self.template.macros['download']
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ from loops.browser.concept import ConceptView
|
|||
from loops.browser.form import ObjectForm, EditObject
|
||||
from loops.browser.node import NodeView
|
||||
from loops.common import adapted
|
||||
from loops.organize.interfaces import IPerson
|
||||
from loops.organize.party import getPersonForUser
|
||||
from loops.organize.stateful.browser import StateAction
|
||||
from loops.organize.tracking.browser import BaseTrackView
|
||||
|
@ -312,7 +313,7 @@ class RelatedTaskWorkItems(AllWorkItems):
|
|||
|
||||
|
||||
class PersonWorkItems(BaseWorkItemsView, ConceptView):
|
||||
""" A query view showing work items for a person, the query's parent.
|
||||
""" A view showing work items for a person or the context object's parents.
|
||||
"""
|
||||
|
||||
columns = set(['Task', 'Title', 'Day', 'Start', 'End', 'Duration', 'Info'])
|
||||
|
@ -322,9 +323,12 @@ class PersonWorkItems(BaseWorkItemsView, ConceptView):
|
|||
|
||||
def listWorkItems(self):
|
||||
criteria = self.getCriteria()
|
||||
for target in self.context.getParents([self.defaultPredicate]):
|
||||
un = criteria.setdefault('userName', [])
|
||||
un.append(util.getUidForObject(target))
|
||||
un = criteria.setdefault('userName', [])
|
||||
if IPerson.providedBy(self.adapted):
|
||||
un.append(util.getUidForObject(self.context))
|
||||
else:
|
||||
for target in self.context.getParents([self.defaultPredicate]):
|
||||
un.append(util.getUidForObject(target))
|
||||
return sorted(self.query(**criteria), key=lambda x: x.track.timeStamp)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue