more flexible layout for states info and stateful actions; improved/more flexible translateion facilities
This commit is contained in:
parent
b5ab23a90b
commit
a67c19659a
3 changed files with 24 additions and 8 deletions
|
@ -154,6 +154,11 @@ class BaseView(GenericView, I18NView):
|
||||||
def checkPermissions(self):
|
def checkPermissions(self):
|
||||||
return canAccessObject(self.context)
|
return canAccessObject(self.context)
|
||||||
|
|
||||||
|
def translate(self, text, msgFactory=_):
|
||||||
|
if msgFactory is None:
|
||||||
|
return text
|
||||||
|
return msgFactory(text)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def contextInfo(self):
|
def contextInfo(self):
|
||||||
return dict(view=self, context=getName(self.context))
|
return dict(view=self, context=getName(self.context))
|
||||||
|
|
|
@ -274,18 +274,22 @@
|
||||||
</metal:versioning>
|
</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:define="states view/states"
|
||||||
tal:condition="states">
|
tal:condition="states">
|
||||||
<tr><td colspan="5" i18n:translate="" class="headline">States</td></tr>
|
|
||||||
<tr tal:repeat="st states">
|
<tr tal:repeat="st states">
|
||||||
<tal:state define="stObj st/getStateObject;
|
<tal:state define="stObj st/getStateObject;
|
||||||
stDef st/statesDefinition;
|
stDef st/statesDefinition;
|
||||||
stTrans st/getAvailableTransitionsForUser">
|
stTrans st/getAvailableTransitionsForUser">
|
||||||
<td colspan="2" i18n:translate=""
|
<td colspan="2">
|
||||||
tal:content="stDef">loops.simple_publishing</td>
|
<b i18n:translate=""
|
||||||
<td i18n:translate=""
|
tal:content="python:view.translate(stDef, st.msgFactory)">
|
||||||
tal:content="stObj/title">draft</td>
|
loops.simple_publishing</b>: </td>
|
||||||
|
<td>
|
||||||
|
<span i18n:translate=""
|
||||||
|
tal:content="stObj/title">draft</span> </td>
|
||||||
<td>
|
<td>
|
||||||
<select name="state.loops.simple_publishing"
|
<select name="state.loops.simple_publishing"
|
||||||
tal:condition="stTrans"
|
tal:condition="stTrans"
|
||||||
|
@ -300,6 +304,7 @@
|
||||||
<td />
|
<td />
|
||||||
</tal:state>
|
</tal:state>
|
||||||
</tr>
|
</tr>
|
||||||
|
</metal:states>
|
||||||
</metal:states>
|
</metal:states>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -47,6 +47,7 @@ class StateAction(Action):
|
||||||
|
|
||||||
url = None
|
url = None
|
||||||
definition = None
|
definition = None
|
||||||
|
msgFactory = _
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def stateful(self):
|
def stateful(self):
|
||||||
|
@ -56,6 +57,7 @@ class StateAction(Action):
|
||||||
@Lazy
|
@Lazy
|
||||||
def description(self):
|
def description(self):
|
||||||
lang = self.view.languageInfo.language
|
lang = self.view.languageInfo.language
|
||||||
|
_ = self.msgFactory
|
||||||
definition = translate(_(self.definition), target_language=lang)
|
definition = translate(_(self.definition), target_language=lang)
|
||||||
title = translate(_(self.stateObject.title), target_language=lang)
|
title = translate(_(self.stateObject.title), target_language=lang)
|
||||||
return _(u'State information for $definition: $title',
|
return _(u'State information for $definition: $title',
|
||||||
|
@ -71,12 +73,16 @@ class StateAction(Action):
|
||||||
return 'cybertools.icons/' + icon
|
return 'cybertools.icons/' + icon
|
||||||
|
|
||||||
|
|
||||||
for std in statefulActions:
|
def registerStatefulAction(std, msgFactory=_):
|
||||||
actions.register('state.' + std, 'object', StateAction,
|
actions.register('state.' + std, 'object', StateAction,
|
||||||
definition = std,
|
definition = std,
|
||||||
cssClass='icon-action',
|
cssClass='icon-action',
|
||||||
|
msgFactory=msgFactory,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for std in statefulActions:
|
||||||
|
registerStatefulAction(std)
|
||||||
|
|
||||||
|
|
||||||
#class StateQuery(ConceptView):
|
#class StateQuery(ConceptView):
|
||||||
class StateQuery(BaseView):
|
class StateQuery(BaseView):
|
||||||
|
|
Loading…
Add table
Reference in a new issue