basic versioning OK, including search, versions portlet
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1658 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
cbba77503a
commit
0c789f3966
11 changed files with 70 additions and 31 deletions
|
@ -103,8 +103,12 @@
|
||||||
</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">
|
<td style="text-align: center"
|
||||||
<span tal:replace="related/versionId">1.1</span>
|
tal:define="versionId related/versionId">
|
||||||
|
<a href="#"
|
||||||
|
tal:content="versionId"
|
||||||
|
tal:omit-tag="python: versionId=='1.1'"
|
||||||
|
tal:attributes="href string:${view/url}/.target${related/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||||
</td>
|
</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>
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<span id="xedit_icon"
|
<span id="xedit_icon"
|
||||||
tal:condition="target/xeditable | nothing">
|
tal:condition="target/xeditable | nothing">
|
||||||
<a href="#" title="Edit" style="padding: 5px"
|
<a href="#" title="Edit" style="padding: 5px"
|
||||||
tal:attributes="href string:${item/realTargetUrl}/external_edit;
|
tal:attributes="href string:${item/realTargetUrl}/external_edit?version=this;
|
||||||
title string:Edit '${target/title}' with External Editor"><img
|
title string:Edit '${target/title}' with External Editor"><img
|
||||||
src="edit.gif" alt="Edit"
|
src="edit.gif" alt="Edit"
|
||||||
tal:attributes="src context/++resource++edit.gif" /></a>
|
tal:attributes="src context/++resource++edit.gif" /></a>
|
||||||
|
|
|
@ -36,12 +36,14 @@ from zope.security import canAccess, canWrite
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
|
|
||||||
from cybertools.typology.interfaces import IType
|
from cybertools.typology.interfaces import IType
|
||||||
from loops.interfaces import IBaseResource, IDocument, IMediaAsset, ITextDocument
|
|
||||||
from loops.browser.common import EditForm, BaseView, Action
|
from loops.browser.common import EditForm, BaseView, Action
|
||||||
from loops.browser.concept import ConceptRelationView, ConceptConfigureView
|
from loops.browser.concept import ConceptRelationView, ConceptConfigureView
|
||||||
from loops.browser.node import NodeView, node_macros
|
from loops.browser.node import NodeView, node_macros
|
||||||
from loops.interfaces import ITypeConcept
|
|
||||||
from loops.browser.util import html_quote
|
from loops.browser.util import html_quote
|
||||||
|
from loops.interfaces import IBaseResource, IDocument, IMediaAsset, ITextDocument
|
||||||
|
from loops.interfaces import ITypeConcept
|
||||||
|
from loops.versioning.browser import version_macros
|
||||||
|
from loops.versioning.interfaces import IVersionable
|
||||||
|
|
||||||
renderingFactories = {
|
renderingFactories = {
|
||||||
'text/plain': 'zope.source.plaintext',
|
'text/plain': 'zope.source.plaintext',
|
||||||
|
@ -103,6 +105,13 @@ class ResourceView(BaseView):
|
||||||
cont.macros.register('portlet_right', 'related', title='Related Items',
|
cont.macros.register('portlet_right', 'related', title='Related Items',
|
||||||
subMacro=self.template.macros['related'],
|
subMacro=self.template.macros['related'],
|
||||||
position=0, info=self)
|
position=0, info=self)
|
||||||
|
if not IUnauthenticatedPrincipal.providedBy(self.request.principal):
|
||||||
|
versionable = IVersionable(self.context, None)
|
||||||
|
if versionable is not None and len(versionable.versions) > 1:
|
||||||
|
cont.macros.register('portlet_right', 'versions',
|
||||||
|
title='Version ' + versionable.versionId,
|
||||||
|
subMacro=version_macros.macros['portlet_versions'],
|
||||||
|
position=1, info=self)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def view(self):
|
def view(self):
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<tal:xedit condition="item/xeditable"> |
|
<tal:xedit condition="item/xeditable"> |
|
||||||
<a href="#" title="Edit with External Editor"
|
<a href="#" title="Edit with External Editor"
|
||||||
tal:define="url string:${view/url}/.target${view/targetId}"
|
tal:define="url string:${view/url}/.target${view/targetId}"
|
||||||
tal:attributes="href string:$url/external_edit">
|
tal:attributes="href string:$url/external_edit?version=this">
|
||||||
Open for editing
|
Open for editing
|
||||||
</a>
|
</a>
|
||||||
</tal:xedit>
|
</tal:xedit>
|
||||||
|
|
7
query.py
7
query.py
|
@ -32,6 +32,7 @@ from cybertools.typology.interfaces import IType
|
||||||
from loops.interfaces import IConcept
|
from loops.interfaces import IConcept
|
||||||
from loops.common import AdapterBase
|
from loops.common import AdapterBase
|
||||||
from loops.type import TypeInterfaceSourceList
|
from loops.type import TypeInterfaceSourceList
|
||||||
|
from loops.versioning.util import getVersion
|
||||||
from loops import util
|
from loops import util
|
||||||
from loops.util import _
|
from loops.util import _
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ class BaseQuery(object):
|
||||||
queue.append(child)
|
queue.append(child)
|
||||||
for c in concepts:
|
for c in concepts:
|
||||||
result.add(c)
|
result.add(c)
|
||||||
result.update(c.getResources())
|
result.update(getVersion(r) for r in c.getResources())
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +137,9 @@ class FullQuery(BaseQuery):
|
||||||
result = result.intersection(rc)
|
result = result.intersection(rc)
|
||||||
else:
|
else:
|
||||||
result = rc
|
result = rc
|
||||||
result = set(r for r in result if r.getLoopsRoot() == self.loopsRoot)
|
result = set(r for r in result
|
||||||
|
if r.getLoopsRoot() == self.loopsRoot
|
||||||
|
and getVersion(r) == r)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,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>
|
||||||
|
@ -60,11 +61,18 @@
|
||||||
description row/description">
|
description row/description">
|
||||||
<tr tal:attributes="class class">
|
<tr tal:attributes="class class">
|
||||||
<td>
|
<td>
|
||||||
<a tal:attributes="href string:${view/url}/.target${row/uniqueId};
|
<a tal:attributes="href string:${view/url}/.target${row/uniqueId}?version=this;
|
||||||
title description"
|
title description"
|
||||||
tal:content="row/title" />
|
tal:content="row/title" />
|
||||||
</td>
|
</td>
|
||||||
<td tal:content="row/longTypeTitle|row/typeTitle">Type</td>
|
<td tal:content="row/longTypeTitle|row/typeTitle">Type</td>
|
||||||
|
<td style="text-align: center"
|
||||||
|
tal:define="versionId row/versionId|string:">
|
||||||
|
<a href="#"
|
||||||
|
tal:content="versionId"
|
||||||
|
tal:omit-tag="python: versionId and versionId=='1.1'"
|
||||||
|
tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a>
|
||||||
|
</td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
<span tal:replace="row/context/sizeForDisplay|string:">Size</span>
|
<span tal:replace="row/context/sizeForDisplay|string:">Size</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -32,23 +32,17 @@ from loops.versioning.interfaces import IVersionable
|
||||||
from loops.versioning.util import getVersion
|
from loops.versioning.util import getVersion
|
||||||
|
|
||||||
|
|
||||||
|
version_macros = ViewPageTemplateFile('version_macros.pt')
|
||||||
|
|
||||||
|
|
||||||
class ListVersions(BaseView):
|
class ListVersions(BaseView):
|
||||||
|
|
||||||
template = ViewPageTemplateFile('version_macros.pt')
|
template = version_macros
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return self.template.macros['versions']
|
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):
|
def versions(self):
|
||||||
versionable = IVersionable(self.context)
|
versionable = IVersionable(self.context)
|
||||||
versions = versionable.versions
|
versions = versionable.versions
|
||||||
|
|
|
@ -43,6 +43,11 @@ class IVersionable(Interface):
|
||||||
'version-independent attributes and central '
|
'version-independent attributes and central '
|
||||||
'versioning metadata')
|
'versioning metadata')
|
||||||
|
|
||||||
|
parent = Attribute(u'The version this one was created from')
|
||||||
|
|
||||||
|
comment = Attribute(u'Somme informative text provided when creating '
|
||||||
|
'this version')
|
||||||
|
|
||||||
# attributes taken from the master version:
|
# attributes taken from the master version:
|
||||||
|
|
||||||
versions = Attribute(u'A dictionary of all versions of this object')
|
versions = Attribute(u'A dictionary of all versions of this object')
|
||||||
|
|
|
@ -25,11 +25,11 @@ $Id$
|
||||||
from loops.versioning.interfaces import IVersionable
|
from loops.versioning.interfaces import IVersionable
|
||||||
|
|
||||||
|
|
||||||
def getVersion(obj, request):
|
def getVersion(obj, request=None):
|
||||||
""" Check if another version should be used for the object
|
""" Check if another version should be used for the object
|
||||||
provided and return it.
|
provided and return it.
|
||||||
"""
|
"""
|
||||||
versionRequest = request.form.get('version')
|
versionRequest = request and request.get('version') or None
|
||||||
if versionRequest == 'this':
|
if versionRequest == 'this':
|
||||||
# we really want this object, not another version
|
# we really want this object, not another version
|
||||||
return obj
|
return obj
|
||||||
|
@ -54,3 +54,10 @@ def getMaster(obj):
|
||||||
return obj
|
return obj
|
||||||
return versionable.master
|
return versionable.master
|
||||||
|
|
||||||
|
|
||||||
|
def cleanupVersionsOnList(lst):
|
||||||
|
result = []
|
||||||
|
for el in lst:
|
||||||
|
result.append(el)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
ondblclick python: item.openEditWindow('resources.html')"
|
ondblclick python: item.openEditWindow('resources.html')"
|
||||||
tal:define="versions python: list(item.versions())"
|
tal:define="versions python: list(item.versions())"
|
||||||
tal:condition="versions">
|
tal:condition="versions">
|
||||||
|
<h1 tal:content="item/title">Title</h1>
|
||||||
<h2>Versions</h2><br />
|
<h2>Versions</h2><br />
|
||||||
<table class="listing">
|
<table class="listing">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
<tr tal:attributes="class class">
|
<tr tal:attributes="class class">
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<a href="#"
|
<a href="#"
|
||||||
tal:attributes="href string:${view/url}/.target${related/uniqueId};
|
tal:attributes="href string:${view/url}/.target${related/uniqueId}?version=this;
|
||||||
title description">
|
title description">
|
||||||
<span tal:replace="related/title">Resource Title</span>
|
<span tal:replace="related/title">Resource Title</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -42,13 +43,11 @@
|
||||||
<!-- portlets -->
|
<!-- portlets -->
|
||||||
|
|
||||||
<metal:versions define-macro="portlet_versions">
|
<metal:versions define-macro="portlet_versions">
|
||||||
<!--<div tal:repeat="concept macro/info/versions">
|
<div>
|
||||||
<a href="#"
|
<a href="#"
|
||||||
tal:attributes="href string:${view/url}/.target${concept/uniqueId}">
|
tal:attributes="href string:${view/url}/.target${macro/info/uniqueId}?loops.viewName=listversions">
|
||||||
<span tal:replace="concept/title">Concept</span>
|
<span i18n:translate="">All versions</span>
|
||||||
(<i tal:content="concept/typeTitle">Type</i>)
|
|
||||||
</a>
|
</a>
|
||||||
</div>-->
|
</div>
|
||||||
</metal:versions>
|
</metal:versions>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,14 @@ class VersionableResource(object):
|
||||||
""" The adapted master... """
|
""" The adapted master... """
|
||||||
return IVersionable(self.master)
|
return IVersionable(self.master)
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def parent(self):
|
||||||
|
return self.getVersioningAttribute('parent', None)
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def comment(self):
|
||||||
|
return self.getVersioningAttribute('comment', u'')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def versions(self):
|
def versions(self):
|
||||||
return self.versionableMaster.getVersioningAttribute('versions', {})
|
return self.versionableMaster.getVersioningAttribute('versions', {})
|
||||||
|
@ -104,7 +112,7 @@ class VersionableResource(object):
|
||||||
m = self.versionableMaster
|
m = self.versionableMaster
|
||||||
return self.versionableMaster.getVersioningAttribute('releasedVersion', None)
|
return self.versionableMaster.getVersioningAttribute('releasedVersion', None)
|
||||||
|
|
||||||
def createVersion(self, level=1):
|
def createVersion(self, level=1, comment=u''):
|
||||||
context = self.context
|
context = self.context
|
||||||
versionableMaster = self.versionableMaster
|
versionableMaster = self.versionableMaster
|
||||||
# get the new version numbers
|
# get the new version numbers
|
||||||
|
@ -123,6 +131,8 @@ class VersionableResource(object):
|
||||||
versionableObj.setVersioningAttribute('versionNumbers', tuple(vn))
|
versionableObj.setVersioningAttribute('versionNumbers', tuple(vn))
|
||||||
versionableObj.setVersioningAttribute('variantIds', self.variantIds)
|
versionableObj.setVersioningAttribute('variantIds', self.variantIds)
|
||||||
versionableObj.setVersioningAttribute('master', self.master)
|
versionableObj.setVersioningAttribute('master', self.master)
|
||||||
|
versionableObj.setVersioningAttribute('parent', context)
|
||||||
|
versionableObj.setVersioningAttribute('comment', comment)
|
||||||
# generate name for new object, register in parent
|
# generate name for new object, register in parent
|
||||||
versionId = versionableObj.versionId
|
versionId = versionableObj.versionId
|
||||||
name = self.generateName(getName(context),
|
name = self.generateName(getName(context),
|
||||||
|
|
Loading…
Add table
Reference in a new issue