diff --git a/browser/compound/__init__.py b/browser/compound/__init__.py new file mode 100644 index 0000000..e12cdd8 --- /dev/null +++ b/browser/compound/__init__.py @@ -0,0 +1,4 @@ +""" +package loops.browser.compound +""" + diff --git a/browser/compound/configure.zcml b/browser/compound/configure.zcml new file mode 100644 index 0000000..fac57ba --- /dev/null +++ b/browser/compound/configure.zcml @@ -0,0 +1,14 @@ + + + + + diff --git a/browser/compound/standard.py b/browser/compound/standard.py new file mode 100644 index 0000000..4e5576f --- /dev/null +++ b/browser/compound/standard.py @@ -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 + diff --git a/browser/compound/view_macros.pt b/browser/compound/view_macros.pt new file mode 100644 index 0000000..eac9cc3 --- /dev/null +++ b/browser/compound/view_macros.pt @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/browser/concept.py b/browser/concept.py index b550830..f06c419 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -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: diff --git a/browser/configure.zcml b/browser/configure.zcml index 70f3b2c..75e5d7d 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -765,6 +765,7 @@ attribute="cleanup" permission="zope.ManageSite" /> + diff --git a/browser/resource.py b/browser/resource.py index 8ec1e95..0960cb2 100644 --- a/browser/resource.py +++ b/browser/resource.py @@ -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'] diff --git a/organize/work/browser.py b/organize/work/browser.py index 564f90b..9cbeda3 100644 --- a/organize/work/browser.py +++ b/organize/work/browser.py @@ -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)