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>
|
||||
</td>
|
||||
<td><span tal:replace="related/longTypeTitle">Type</span></td>
|
||||
<td style="text-align: center">
|
||||
<span tal:replace="related/versionId">1.1</span>
|
||||
<td style="text-align: center"
|
||||
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 style="text-align: right">
|
||||
<span tal:replace="related/context/sizeForDisplay">Type</span>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<span id="xedit_icon"
|
||||
tal:condition="target/xeditable | nothing">
|
||||
<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
|
||||
src="edit.gif" alt="Edit"
|
||||
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 cybertools.typology.interfaces import IType
|
||||
from loops.interfaces import IBaseResource, IDocument, IMediaAsset, ITextDocument
|
||||
from loops.browser.common import EditForm, BaseView, Action
|
||||
from loops.browser.concept import ConceptRelationView, ConceptConfigureView
|
||||
from loops.browser.node import NodeView, node_macros
|
||||
from loops.interfaces import ITypeConcept
|
||||
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 = {
|
||||
'text/plain': 'zope.source.plaintext',
|
||||
|
@ -103,6 +105,13 @@ class ResourceView(BaseView):
|
|||
cont.macros.register('portlet_right', 'related', title='Related Items',
|
||||
subMacro=self.template.macros['related'],
|
||||
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
|
||||
def view(self):
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<tal:xedit condition="item/xeditable"> |
|
||||
<a href="#" title="Edit with External Editor"
|
||||
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
|
||||
</a>
|
||||
</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.common import AdapterBase
|
||||
from loops.type import TypeInterfaceSourceList
|
||||
from loops.versioning.util import getVersion
|
||||
from loops import util
|
||||
from loops.util import _
|
||||
|
||||
|
@ -101,7 +102,7 @@ class BaseQuery(object):
|
|||
queue.append(child)
|
||||
for c in concepts:
|
||||
result.add(c)
|
||||
result.update(c.getResources())
|
||||
result.update(getVersion(r) for r in c.getResources())
|
||||
return result
|
||||
|
||||
|
||||
|
@ -136,7 +137,9 @@ class FullQuery(BaseQuery):
|
|||
result = result.intersection(rc)
|
||||
else:
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<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>
|
||||
|
@ -60,11 +61,18 @@
|
|||
description row/description">
|
||||
<tr tal:attributes="class class">
|
||||
<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"
|
||||
tal:content="row/title" />
|
||||
</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">
|
||||
<span tal:replace="row/context/sizeForDisplay|string:">Size</span>
|
||||
</td>
|
||||
|
|
|
@ -32,23 +32,17 @@ from loops.versioning.interfaces import IVersionable
|
|||
from loops.versioning.util import getVersion
|
||||
|
||||
|
||||
version_macros = ViewPageTemplateFile('version_macros.pt')
|
||||
|
||||
|
||||
class ListVersions(BaseView):
|
||||
|
||||
template = ViewPageTemplateFile('version_macros.pt')
|
||||
template = version_macros
|
||||
|
||||
@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
|
||||
|
|
|
@ -43,6 +43,11 @@ class IVersionable(Interface):
|
|||
'version-independent attributes and central '
|
||||
'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:
|
||||
|
||||
versions = Attribute(u'A dictionary of all versions of this object')
|
||||
|
|
|
@ -25,11 +25,11 @@ $Id$
|
|||
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
|
||||
provided and return it.
|
||||
"""
|
||||
versionRequest = request.form.get('version')
|
||||
versionRequest = request and request.get('version') or None
|
||||
if versionRequest == 'this':
|
||||
# we really want this object, not another version
|
||||
return obj
|
||||
|
@ -54,3 +54,10 @@ def getMaster(obj):
|
|||
return obj
|
||||
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')"
|
||||
tal:define="versions python: list(item.versions())"
|
||||
tal:condition="versions">
|
||||
<h1 tal:content="item/title">Title</h1>
|
||||
<h2>Versions</h2><br />
|
||||
<table class="listing">
|
||||
<tr>
|
||||
|
@ -18,7 +19,7 @@
|
|||
<tr tal:attributes="class class">
|
||||
<td valign="top">
|
||||
<a href="#"
|
||||
tal:attributes="href string:${view/url}/.target${related/uniqueId};
|
||||
tal:attributes="href string:${view/url}/.target${related/uniqueId}?version=this;
|
||||
title description">
|
||||
<span tal:replace="related/title">Resource Title</span>
|
||||
</a>
|
||||
|
@ -42,13 +43,11 @@
|
|||
<!-- portlets -->
|
||||
|
||||
<metal:versions define-macro="portlet_versions">
|
||||
<!--<div tal:repeat="concept macro/info/versions">
|
||||
<div>
|
||||
<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>)
|
||||
tal:attributes="href string:${view/url}/.target${macro/info/uniqueId}?loops.viewName=listversions">
|
||||
<span i18n:translate="">All versions</span>
|
||||
</a>
|
||||
</div>-->
|
||||
</div>
|
||||
</metal:versions>
|
||||
|
||||
|
||||
|
|
|
@ -91,6 +91,14 @@ class VersionableResource(object):
|
|||
""" The adapted master... """
|
||||
return IVersionable(self.master)
|
||||
|
||||
@Lazy
|
||||
def parent(self):
|
||||
return self.getVersioningAttribute('parent', None)
|
||||
|
||||
@Lazy
|
||||
def comment(self):
|
||||
return self.getVersioningAttribute('comment', u'')
|
||||
|
||||
@property
|
||||
def versions(self):
|
||||
return self.versionableMaster.getVersioningAttribute('versions', {})
|
||||
|
@ -104,7 +112,7 @@ class VersionableResource(object):
|
|||
m = self.versionableMaster
|
||||
return self.versionableMaster.getVersioningAttribute('releasedVersion', None)
|
||||
|
||||
def createVersion(self, level=1):
|
||||
def createVersion(self, level=1, comment=u''):
|
||||
context = self.context
|
||||
versionableMaster = self.versionableMaster
|
||||
# get the new version numbers
|
||||
|
@ -123,6 +131,8 @@ class VersionableResource(object):
|
|||
versionableObj.setVersioningAttribute('versionNumbers', tuple(vn))
|
||||
versionableObj.setVersioningAttribute('variantIds', self.variantIds)
|
||||
versionableObj.setVersioningAttribute('master', self.master)
|
||||
versionableObj.setVersioningAttribute('parent', context)
|
||||
versionableObj.setVersioningAttribute('comment', comment)
|
||||
# generate name for new object, register in parent
|
||||
versionId = versionableObj.versionId
|
||||
name = self.generateName(getName(context),
|
||||
|
|
Loading…
Add table
Reference in a new issue