more flexible layout for states info and stateful actions; improved/more flexible translateion facilities

This commit is contained in:
Helmut Merz 2013-03-24 17:15:06 +01:00
parent b5ab23a90b
commit a67c19659a
3 changed files with 24 additions and 8 deletions

View file

@ -154,6 +154,11 @@ class BaseView(GenericView, I18NView):
def checkPermissions(self):
return canAccessObject(self.context)
def translate(self, text, msgFactory=_):
if msgFactory is None:
return text
return msgFactory(text)
@Lazy
def contextInfo(self):
return dict(view=self, context=getName(self.context))

View file

@ -274,18 +274,22 @@
</metal:versioning>
<metal:states define-macro="states"
<metal:states define-macro="states">
<tr><td colspan="5" i18n:translate="" class="headline">States</td></tr>
<metal:states define-macro="states_info"
tal:define="states view/states"
tal:condition="states">
<tr><td colspan="5" i18n:translate="" class="headline">States</td></tr>
<tr tal:repeat="st states">
<tal:state define="stObj st/getStateObject;
stDef st/statesDefinition;
stTrans st/getAvailableTransitionsForUser">
<td colspan="2" i18n:translate=""
tal:content="stDef">loops.simple_publishing</td>
<td i18n:translate=""
tal:content="stObj/title">draft</td>
<td colspan="2">
<b i18n:translate=""
tal:content="python:view.translate(stDef, st.msgFactory)">
loops.simple_publishing</b>:&nbsp;</td>
<td>
<span i18n:translate=""
tal:content="stObj/title">draft</span>&nbsp;</td>
<td>
<select name="state.loops.simple_publishing"
tal:condition="stTrans"
@ -301,6 +305,7 @@
</tal:state>
</tr>
</metal:states>
</metal:states>
<div metal:define-macro="buttons" class="buttons">

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
# Copyright (c) 2013 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
@ -47,6 +47,7 @@ class StateAction(Action):
url = None
definition = None
msgFactory = _
@Lazy
def stateful(self):
@ -56,6 +57,7 @@ class StateAction(Action):
@Lazy
def description(self):
lang = self.view.languageInfo.language
_ = self.msgFactory
definition = translate(_(self.definition), target_language=lang)
title = translate(_(self.stateObject.title), target_language=lang)
return _(u'State information for $definition: $title',
@ -71,12 +73,16 @@ class StateAction(Action):
return 'cybertools.icons/' + icon
for std in statefulActions:
def registerStatefulAction(std, msgFactory=_):
actions.register('state.' + std, 'object', StateAction,
definition = std,
cssClass='icon-action',
msgFactory=msgFactory,
)
for std in statefulActions:
registerStatefulAction(std)
#class StateQuery(ConceptView):
class StateQuery(BaseView):