allow supression of versioning for single resources via an additional field
This commit is contained in:
parent
56bc752702
commit
739f309ab7
7 changed files with 50 additions and 22 deletions
|
@ -642,8 +642,11 @@ class EditObject(FormController, I18NView):
|
|||
|
||||
def checkCreateVersion(self, obj):
|
||||
form = self.request.form
|
||||
if form.get('version.create'):
|
||||
versionable = IVersionable(obj)
|
||||
notVersioned = bool(form.get('version.not_versioned'))
|
||||
if notVersioned != versionable.notVersioned:
|
||||
versionable.notVersioned = notVersioned
|
||||
if not notVersioned and form.get('version.create'):
|
||||
level = int(form.get('version.level', 0))
|
||||
version = versionable.createVersion(level)
|
||||
notify(ObjectCreatedEvent(version))
|
||||
|
|
|
@ -229,12 +229,25 @@
|
|||
|
||||
|
||||
<metal:versioning define-macro="versioning"
|
||||
tal:define="versionInfo view/versionInfo"
|
||||
tal:define="versionInfo view/versionInfo;
|
||||
notVersioned view/versionable/notVersioned|nothing"
|
||||
tal:condition="versionInfo">
|
||||
<tr>
|
||||
<td colspan="5" i18n:translate="" class="headline">Versioning</td>
|
||||
<td colspan="1" i18n:translate="" class="headline">Versioning</td>
|
||||
<td colspan="4">
|
||||
<span i18n:attributes="title"
|
||||
title="Check this field if you want to suppress versioning for this resource.">
|
||||
<input type="checkbox"
|
||||
name="version.not_versioned" id="version.not_versioned"
|
||||
value="not_versioned"
|
||||
tal:attributes="checked notVersioned" />
|
||||
<label style="display: inline"
|
||||
for="version.not_versioned"><span i18n:translate="">
|
||||
Suppress Versioning</span></label>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr tal:condition="not:notVersioned">
|
||||
<td colspan="2">
|
||||
<span i18n:translate="">Version</span>:
|
||||
<span tal:content="versionInfo">1.1 (current, released)</span>
|
||||
|
|
|
@ -13,6 +13,6 @@ body {
|
|||
|
||||
#content {
|
||||
/* width: 100%; */
|
||||
width: 70%;
|
||||
width: 80%;
|
||||
color: Black;
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -3,7 +3,7 @@ msgstr ""
|
|||
|
||||
"Project-Id-Version: $Id$\n"
|
||||
"POT-Creation-Date: 2007-05-22 12:00 CET\n"
|
||||
"PO-Revision-Date: 2012-02-16 12:00 CET\n"
|
||||
"PO-Revision-Date: 2012-03-28 12:00 CET\n"
|
||||
"Last-Translator: Helmut Merz <helmutm@cy55.de>\n"
|
||||
"Language-Team: loops developers <helmutm@cy55.de>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -437,6 +437,12 @@ msgstr "Suchbegriff"
|
|||
msgid "Select if you want to create a new version"
|
||||
msgstr "Bitte markieren, wenn Sie eine neue Version anlegen möchten"
|
||||
|
||||
msgid "Suppress Versioning"
|
||||
msgstr "Keine Versionierung"
|
||||
|
||||
msgid "Check this field if you want to suppress versioning for this resource."
|
||||
msgstr "Bitte markieren, wenn diese Ressource nicht versioniert werden soll."
|
||||
|
||||
msgid "Search text"
|
||||
msgstr "Suchtext"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Versioning interfaces.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope.interface import Interface, Attribute
|
||||
|
@ -30,31 +28,34 @@ class IVersionable(Interface):
|
|||
""" An object that may exist in different versions.
|
||||
"""
|
||||
|
||||
versionNumbers = Attribute(u'A tuple of version numbers for the context '
|
||||
versionNumbers = Attribute('A tuple of version numbers for the context '
|
||||
'object, with a number for each level')
|
||||
|
||||
variantIds = Attribute(u'A tuple of variant IDs (e.g. for language '
|
||||
variantIds = Attribute('A tuple of variant IDs (e.g. for language '
|
||||
'varuants) for the context object')
|
||||
|
||||
versionId = Attribute(u'A string identifying this version, e.g. 1.1_de, '
|
||||
versionId = Attribute('A string identifying this version, e.g. 1.1_de, '
|
||||
'derived from versionNumbers and variantIds')
|
||||
|
||||
master = Attribute(u'The object (master version) that should be used for access to '
|
||||
master = Attribute('The object (master version) that should be used for access to '
|
||||
'version-independent attributes and central '
|
||||
'versioning metadata')
|
||||
|
||||
parent = Attribute(u'The version this one was created from')
|
||||
parent = Attribute('The version this one was created from')
|
||||
|
||||
comment = Attribute(u'Somme informative text provided when creating '
|
||||
comment = Attribute('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')
|
||||
versions = Attribute('A dictionary of all versions of this object')
|
||||
|
||||
currentVersion = Attribute(u'The default version to be used for editing')
|
||||
currentVersion = Attribute('The default version to be used for editing')
|
||||
|
||||
releasedVersion = Attribute(u'The default version to be used for viewing')
|
||||
releasedVersion = Attribute('The default version to be used for viewing')
|
||||
|
||||
notVersioned = Attribute('A boolean that is True if this object should '
|
||||
'not be versioned')
|
||||
|
||||
def createVersion(level=1):
|
||||
""" Create a copy of the context object as a new version and return it.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2007 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2012 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
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Utilities for managing version informations.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from BTrees.OOBTree import OOBTree
|
||||
|
@ -129,6 +127,13 @@ class VersionableResource(object):
|
|||
m = self.versionableMaster
|
||||
return self.versionableMaster.getVersioningAttribute('releasedVersion', None)
|
||||
|
||||
def getNotVersioned(self):
|
||||
m = self.versionableMaster
|
||||
return self.versionableMaster.getVersioningAttribute('notVersioned', False)
|
||||
def setNotVersioned(self, value):
|
||||
self.versionableMaster.setVersioningAttribute('notVersioned', bool(value))
|
||||
notVersioned = property(getNotVersioned, setNotVersioned)
|
||||
|
||||
def createVersionObject(self, versionNumbers, variantIds, comment=u''):
|
||||
versionableMaster = self.versionableMaster
|
||||
versionableMaster.initVersions()
|
||||
|
|
Loading…
Add table
Reference in a new issue