more on versioning: a first version listing macro
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1657 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
52d7ef2025
commit
cbba77503a
8 changed files with 151 additions and 14 deletions
|
@ -240,6 +240,18 @@ class BaseView(GenericView):
|
||||||
|
|
||||||
# versioning
|
# versioning
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def versionId(self):
|
||||||
|
context = self.context
|
||||||
|
versionable = IVersionable(context, None)
|
||||||
|
return versionable and versionable.versionId or ''
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def currentVersionId(self):
|
||||||
|
context = self.context
|
||||||
|
versionable = IVersionable(context, None)
|
||||||
|
return versionable and versionable.currentVersion.versionId or ''
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def versionInfo(self):
|
def versionInfo(self):
|
||||||
context = self.context
|
context = self.context
|
||||||
|
|
|
@ -47,6 +47,7 @@ from loops.interfaces import IConcept
|
||||||
from loops.concept import Concept, ConceptTypeSourceList, PredicateSourceList
|
from loops.concept import Concept, ConceptTypeSourceList, PredicateSourceList
|
||||||
from loops.browser.common import EditForm, BaseView, LoopsTerms
|
from loops.browser.common import EditForm, BaseView, LoopsTerms
|
||||||
from loops import util
|
from loops import util
|
||||||
|
from loops.versioning.util import getVersion
|
||||||
|
|
||||||
|
|
||||||
class ConceptEditForm(EditForm):
|
class ConceptEditForm(EditForm):
|
||||||
|
@ -276,6 +277,7 @@ class ConceptRelationView(BaseView):
|
||||||
else:
|
else:
|
||||||
self.context = relation.first
|
self.context = relation.first
|
||||||
self.other = relation.second
|
self.other = relation.second
|
||||||
|
self.context = getVersion(self.context, request)
|
||||||
self.predicate = relation.predicate
|
self.predicate = relation.predicate
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th i18n:translate="label_title">Title</th>
|
<th i18n:translate="label_title">Title</th>
|
||||||
<th i18n:translate="label_type">Type</th>
|
<th i18n:translate="label_type">Type</th>
|
||||||
|
<th i18n:translate="label_version">V</th>
|
||||||
<th i18n:translate="label_size">Size</th>
|
<th i18n:translate="label_size">Size</th>
|
||||||
<th i18n:translate="label_modifdate">Modification Date</th>
|
<th i18n:translate="label_modifdate">Modification Date</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -102,6 +103,9 @@
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td><span tal:replace="related/longTypeTitle">Type</span></td>
|
<td><span tal:replace="related/longTypeTitle">Type</span></td>
|
||||||
|
<td style="text-align: center">
|
||||||
|
<span tal:replace="related/versionId">1.1</span>
|
||||||
|
</td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
<span tal:replace="related/context/sizeForDisplay">Type</span>
|
<span tal:replace="related/context/sizeForDisplay">Type</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -37,7 +37,6 @@ from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
from zope.lifecycleevent import Attributes
|
from zope.lifecycleevent import Attributes
|
||||||
from zope.formlib.form import Form, FormFields
|
from zope.formlib.form import Form, FormFields
|
||||||
from zope.formlib.namedtemplate import NamedTemplate
|
from zope.formlib.namedtemplate import NamedTemplate
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
|
||||||
from zope.proxy import removeAllProxies
|
from zope.proxy import removeAllProxies
|
||||||
from zope.security import canAccess, canWrite
|
from zope.security import canAccess, canWrite
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
|
@ -99,11 +98,12 @@ class NodeView(BaseView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def item(self):
|
def item(self):
|
||||||
|
viewName = self.request.get('loops.viewName') or ''
|
||||||
|
# was there a .target... element in the URL?
|
||||||
#target = self.virtualTargetObject # ignores page even for direktly assignd target
|
#target = self.virtualTargetObject # ignores page even for direktly assignd target
|
||||||
target = self.request.annotations.get('loops.view', {}).get('target')
|
target = self.request.annotations.get('loops.view', {}).get('target')
|
||||||
# was there a .target... element in the URL?
|
|
||||||
if target is not None:
|
if target is not None:
|
||||||
basicView = zapi.getMultiAdapter((target, self.request))
|
basicView = zapi.getMultiAdapter((target, self.request), name=viewName)
|
||||||
# xxx: obsolete when self.targetObject is virtual target:
|
# xxx: obsolete when self.targetObject is virtual target:
|
||||||
return basicView.view
|
return basicView.view
|
||||||
return self.page
|
return self.page
|
||||||
|
|
57
versioning/browser.py
Normal file
57
versioning/browser.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007 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 classes for versioning.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from zope import interface, component
|
||||||
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
|
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
||||||
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
||||||
|
from loops.browser.common import BaseView
|
||||||
|
from loops.versioning.interfaces import IVersionable
|
||||||
|
from loops.versioning.util import getVersion
|
||||||
|
|
||||||
|
|
||||||
|
class ListVersions(BaseView):
|
||||||
|
|
||||||
|
template = ViewPageTemplateFile('version_macros.pt')
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def macro(self):
|
||||||
|
return self.template.macros['versions']
|
||||||
|
|
||||||
|
def __init__(self, context, request):
|
||||||
|
super(ListVersions, self).__init__(context, request)
|
||||||
|
cont = self.controller
|
||||||
|
if (cont is not None and not IUnauthenticatedPrincipal.providedBy(
|
||||||
|
self.request.principal)):
|
||||||
|
cont.macros.register('portlet_right', 'versions', title='Versions',
|
||||||
|
subMacro=self.template.macros['portlet_versions'],
|
||||||
|
info=self)
|
||||||
|
|
||||||
|
def versions(self):
|
||||||
|
versionable = IVersionable(self.context)
|
||||||
|
versions = versionable.versions
|
||||||
|
for v in sorted(versions):
|
||||||
|
yield BaseView(versions[v], self.request)
|
||||||
|
|
|
@ -16,4 +16,13 @@
|
||||||
set_schema="loops.versioning.interfaces.IVersionable" />
|
set_schema="loops.versioning.interfaces.IVersionable" />
|
||||||
</zope:class>
|
</zope:class>
|
||||||
|
|
||||||
|
<!-- user interface -->
|
||||||
|
|
||||||
|
<browser:page
|
||||||
|
name="listversions"
|
||||||
|
for="loops.interfaces.IResource"
|
||||||
|
class="loops.versioning.browser.ListVersions"
|
||||||
|
permission="zope.View"
|
||||||
|
/>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
|
@ -36,17 +36,16 @@ def getVersion(obj, request):
|
||||||
versionable = IVersionable(obj, None)
|
versionable = IVersionable(obj, None)
|
||||||
if versionable is None:
|
if versionable is None:
|
||||||
return obj
|
return obj
|
||||||
if not versionRequest:
|
if versionRequest:
|
||||||
# find and return a standard version
|
# we might have a versionId in the request
|
||||||
v = versionable.releasedVersion
|
v = versionable.versions.get(versionRequest)
|
||||||
if v is None:
|
if v is not None:
|
||||||
v = versionable.currentVersion
|
return v
|
||||||
return v
|
# find and return a standard version
|
||||||
# we might have a versionId in the request
|
v = versionable.releasedVersion
|
||||||
v = versionable.versions.get(versionRequest)
|
if v is None:
|
||||||
if v is not None:
|
v = versionable.currentVersion
|
||||||
return v
|
return v
|
||||||
return obj
|
|
||||||
|
|
||||||
|
|
||||||
def getMaster(obj):
|
def getMaster(obj):
|
||||||
|
|
54
versioning/version_macros.pt
Normal file
54
versioning/version_macros.pt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<metal:resources define-macro="versions">
|
||||||
|
<div tal:attributes="class string:content-$level;
|
||||||
|
ondblclick python: item.openEditWindow('resources.html')"
|
||||||
|
tal:define="versions python: list(item.versions())"
|
||||||
|
tal:condition="versions">
|
||||||
|
<h2>Versions</h2><br />
|
||||||
|
<table class="listing">
|
||||||
|
<tr>
|
||||||
|
<th i18n:translate="label_title">Title</th>
|
||||||
|
<th i18n:translate="label_type">Type</th>
|
||||||
|
<th i18n:translate="label_version">V</th>
|
||||||
|
<th i18n:translate="label_size">Size</th>
|
||||||
|
<th i18n:translate="label_modifdate">Modification Date</th>
|
||||||
|
</tr>
|
||||||
|
<tal:items repeat="related versions">
|
||||||
|
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
||||||
|
description related/description">
|
||||||
|
<tr tal:attributes="class class">
|
||||||
|
<td valign="top">
|
||||||
|
<a href="#"
|
||||||
|
tal:attributes="href string:${view/url}/.target${related/uniqueId};
|
||||||
|
title description">
|
||||||
|
<span tal:replace="related/title">Resource Title</span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td><span tal:replace="related/longTypeTitle">Type</span></td>
|
||||||
|
<td style="text-align: center">
|
||||||
|
<span tal:replace="related/versionId">1.1</span>
|
||||||
|
</td>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<span tal:replace="related/context/sizeForDisplay">Type</span>
|
||||||
|
</td>
|
||||||
|
<td><span tal:replace="related/modified">Type</span></td>
|
||||||
|
</tr>
|
||||||
|
</tal:item>
|
||||||
|
</tal:items>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</metal:resources>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- portlets -->
|
||||||
|
|
||||||
|
<metal:versions define-macro="portlet_versions">
|
||||||
|
<!--<div tal:repeat="concept macro/info/versions">
|
||||||
|
<a href="#"
|
||||||
|
tal:attributes="href string:${view/url}/.target${concept/uniqueId}">
|
||||||
|
<span tal:replace="concept/title">Concept</span>
|
||||||
|
(<i tal:content="concept/typeTitle">Type</i>)
|
||||||
|
</a>
|
||||||
|
</div>-->
|
||||||
|
</metal:versions>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue