From 9cbc45818e40a57adb7ff46ebc83b87c980348d7 Mon Sep 17 00:00:00 2001 From: helmutm Date: Fri, 2 Jan 2009 10:06:11 +0000 Subject: [PATCH] provide a query view for linking to other loops sites in the same instance git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3107 fd906abe-77d9-0310-91a1-e0d9ade77398 --- browser/common.py | 3 +- configure.zcml | 1 + organize/comment/browser.py | 3 +- system/configure.zcml | 2 ++ system/site/__init__.py | 4 +++ system/site/browser.py | 67 +++++++++++++++++++++++++++++++++++++ system/site/configure.zcml | 16 +++++++++ system/site/view_macros.pt | 18 ++++++++++ 8 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 system/site/__init__.py create mode 100644 system/site/browser.py create mode 100644 system/site/configure.zcml create mode 100644 system/site/view_macros.pt diff --git a/browser/common.py b/browser/common.py index d089a79..9014ca5 100644 --- a/browser/common.py +++ b/browser/common.py @@ -393,7 +393,8 @@ class BaseView(GenericView, I18NView): @Lazy def options(self): - return IOptions(self.context) + #return IOptions(self.context) + return IOptions(self.adapted) @Lazy def globalOptions(self): diff --git a/configure.zcml b/configure.zcml index cfe36a9..c05be78 100644 --- a/configure.zcml +++ b/configure.zcml @@ -468,6 +468,7 @@ + diff --git a/organize/comment/browser.py b/organize/comment/browser.py index 99cba35..238401e 100644 --- a/organize/comment/browser.py +++ b/organize/comment/browser.py @@ -51,7 +51,8 @@ class CommentsView(NodeView): @Lazy def allowed(self): - return self.globalOptions('organize.allowComments') + return (self.virtualTargetObject is not None and + self.globalOptions('organize.allowComments')) @Lazy def addUrl(self): diff --git a/system/configure.zcml b/system/configure.zcml index f69d141..2441ce6 100644 --- a/system/configure.zcml +++ b/system/configure.zcml @@ -8,4 +8,6 @@ + + diff --git a/system/site/__init__.py b/system/site/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/system/site/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/system/site/browser.py b/system/site/browser.py new file mode 100644 index 0000000..b31e79b --- /dev/null +++ b/system/site/browser.py @@ -0,0 +1,67 @@ +# +# Copyright (c) 2008 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 +# + +""" +View class(es) for work items. + +$Id$ +""" + +from zope.cachedescriptors.property import Lazy +from zope.app.pagetemplate import ViewPageTemplateFile +from zope.security import canAccess +from zope.traversing.api import getParent, getRoot, traverse +from zope.traversing.browser import absoluteURL + +from loops.browser.common import BaseView +from loops.browser.concept import ConceptView +from loops import util +from loops.util import _ + + +site_macros = ViewPageTemplateFile('view_macros.pt') + + +class SitesListing(ConceptView): + + @Lazy + def site_macros(self): + return site_macros.macros + + @property + def macro(self): + return self.site_macros['sites_listing'] + + @Lazy + def root(self): + return getRoot(self.context) + + @Lazy + def sites(self): + result = [] + paths = self.options('system.sites') or [] + for p in paths: + s = traverse(self.root, p) + if canAccess(s, 'title'): + result.append(SiteDetails(s, self.request)) + return result + + +class SiteDetails(BaseView): + + pass diff --git a/system/site/configure.zcml b/system/site/configure.zcml new file mode 100644 index 0000000..5d6ebe1 --- /dev/null +++ b/system/site/configure.zcml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/system/site/view_macros.pt b/system/site/view_macros.pt new file mode 100644 index 0000000..a363ddc --- /dev/null +++ b/system/site/view_macros.pt @@ -0,0 +1,18 @@ + + + + + + + +

loops Sites

+ +
+ + +