[gen] Added base Appy i18n files containing standard Appy labels.

This commit is contained in:
Gaetan Delannay 2013-10-20 18:12:39 +02:00
parent 1faba191b2
commit 14f4848348
16 changed files with 5643 additions and 370 deletions

View file

@ -23,7 +23,7 @@ class Page:
subElements = ('save', 'cancel', 'previous', 'next', 'edit')
def __init__(self, name, phase='main', show=True, showSave=True,
showCancel=True, showPrevious=True, showNext=True,
showEdit=True):
showEdit=True, label=None):
self.name = name
self.phase = phase
self.show = show
@ -39,6 +39,9 @@ class Page:
self.showNext = showNext
# When viewing the page, must I show the "edit" button?
self.showEdit = showEdit
# Instead of computing a translated label, one may give p_label, a
# fixed label which will not be translated.
self.label = label
@staticmethod
def get(pageData):
@ -85,4 +88,10 @@ class Page:
setattr(res, 'show%s' % elem.capitalize(), \
self.isShowable(obj, layoutType, elem=elem))
return res
def getLabel(self, zobj):
'''Returns the i18n label for this page, or a fixed label if self.label
is not empty.'''
if self.label: return self.label
return zobj.translate('%s_page_%s' % (zobj.meta_type, self.name))
# ------------------------------------------------------------------------------

View file

@ -36,8 +36,7 @@ class Phase:
<div if="not (singlePhase and singlePage)"
class=":aPage==page and 'portletCurrent portletPage' or \
'portletPage'">
<a href=":zobj.getUrl(page=aPage)">::_('%s_page_%s' % \
(zobj.meta_type, aPage))</a>
<a href=":zobj.getUrl(page=aPage)">::aPageInfo.page.getLabel(zobj)</a>
<x var="locked=zobj.isLocked(user, aPage);
editable=mayEdit and aPageInfo.showOnEdit and \
aPageInfo.showEdit">

View file

@ -25,18 +25,18 @@ r, w, d = ('read', 'write', 'delete')
# ------------------------------------------------------------------------------
class Role:
'''Represents a role, be it local or global.'''
zopeRoles = ('Manager', 'Owner', 'Anonymous', 'Authenticated')
zopeLocalRoles = ('Owner',)
zopeUngrantableRoles = ('Anonymous', 'Authenticated')
appyRoles = ('Manager', 'Owner', 'Anonymous', 'Authenticated')
appyLocalRoles = ('Owner',)
appyUngrantableRoles = ('Anonymous', 'Authenticated')
def __init__(self, name, local=False, grantable=True):
self.name = name
self.local = local # True if it can be used as local role only.
# It is a standard Zope role or an application-specific one?
self.zope = name in self.zopeRoles
if self.zope and (name in self.zopeLocalRoles):
self.appy = name in self.appyRoles
if self.appy and (name in self.appyLocalRoles):
self.local = True
self.grantable = grantable
if self.zope and (name in self.zopeUngrantableRoles):
if self.appy and (name in self.appyUngrantableRoles):
self.grantable = False
# An ungrantable role is one that is, like the Anonymous or
# Authenticated roles, automatically attributed to a user.