Commit a6bdb3d1 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Implemlentation example.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11956 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ac9e1b6c
...@@ -30,6 +30,7 @@ from DateTime import DateTime ...@@ -30,6 +30,7 @@ from DateTime import DateTime
from operator import add from operator import add
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl import ClassSecurityInfo, getSecurityManager
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.WebDAVSupport import TextContent from Products.ERP5Type.WebDAVSupport import TextContent
...@@ -491,16 +492,27 @@ class Document(XMLObject): ...@@ -491,16 +492,27 @@ class Document(XMLObject):
Returns a list of documents with same reference, same portal_type Returns a list of documents with same reference, same portal_type
but different version and given language or any language if not given. but different version and given language or any language if not given.
""" """
# Use portal_catalog catalog = getToolByName(self, 'portal_catalog', None)
pass return catalog(portal_type=self.getPortalType(),
reference=self.getReference(),
version=version,
language=language,
group_by=('revision',),
order_by=(('revision', 'descending', 'SIGNED'),)
)
security.declareProtected(Permissions.View, 'isVersionUnique') security.declareProtected(Permissions.View, 'isVersionUnique')
def isVersionUnique(self): def isVersionUnique(self):
""" """
Returns true if no other document has the same version and language Returns true if no other document of the same
portal_type and reference has the same version and language
""" """
# Use portal_catalog catalog = getToolByName(self, 'portal_catalog', None)
pass return catalog.countResults(portal_type=self.getPortalType(),
reference=self.getReference(),
version=self.getVersion(),
language=self.getLanguage(),
) <= 1
security.declareProtected(Permissions.View, 'getLatestRevisionValue') security.declareProtected(Permissions.View, 'getLatestRevisionValue')
def getLatestRevisionValue(self): def getLatestRevisionValue(self):
...@@ -537,8 +549,13 @@ class Document(XMLObject): ...@@ -537,8 +549,13 @@ class Document(XMLObject):
Returns a list of languages which this document is available in Returns a list of languages which this document is available in
for the current user. for the current user.
""" """
# Use portal_catalog catalog = getToolByName(self, 'portal_catalog', None)
pass return map(lambda o:o.getLanguage(),
catalog(portal_type=self.getPortalType(),
reference=self.getReference(),
version=version,
group_by=('language',),
))
security.declareProtected(Permissions.View, 'getOriginalLanguage') security.declareProtected(Permissions.View, 'getOriginalLanguage')
def getOriginalLanguage(self): def getOriginalLanguage(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment