[gen] pod field: one of the listed templates in field.template can simply be a pointer to another template from the list. For example, template=('Item.odt', 'Item.odt.variant'). The second file is an empty file and gen will use the first one for the second template. It allows to have similar files for templates that, in the UI, are different, ie, can have different names and appear under different conditions. Note that in the default context of every template, variable 'template' contains the name of the template file. It allows the template to know if he is 'called' under the name 'Item.odt' or 'Item.odt.variant'.
This commit is contained in:
parent
71bc58a8b0
commit
194b455816
4 changed files with 76 additions and 14 deletions
|
@ -156,7 +156,7 @@ class UserWrapper(AbstractWrapper):
|
|||
if self.firstName and self.name:
|
||||
self.title = '%s %s' % (self.name, self.firstName)
|
||||
else:
|
||||
self.title = self.login
|
||||
self.title = self.title or self.login
|
||||
|
||||
def ensureAdminIsManager(self):
|
||||
'''User 'admin' must always have role 'Manager'.'''
|
||||
|
|
|
@ -776,14 +776,19 @@ class AbstractWrapper(object):
|
|||
def getField(self, name): return self.o.getAppyType(name)
|
||||
|
||||
def getValue(self, name, formatted=False, language=None):
|
||||
'''Gets the formatted value of field p_name. If this formatting implies
|
||||
translating some element, translate them in p_langue, or in the user
|
||||
language if not specified.'''
|
||||
'''Gets the possibly p_formatted value of field p_name. If this
|
||||
formatting implies translating something, it will be done in
|
||||
p_language, or in the user language if not specified. If the "shown"
|
||||
value is required instead of the "formatted" value (see methods
|
||||
getFormattedValue and getShownValue from class appy.fields.Field),
|
||||
use p_formatted="shown" instead of p_formatted=True.'''
|
||||
field = self.o.getAppyType(name)
|
||||
obj = self.o
|
||||
val = field.getValue(obj)
|
||||
if not formatted: return val
|
||||
return field.getFormattedValue(obj, val, language=language)
|
||||
method = (formatted == 'shown') and 'getShownValue' or \
|
||||
'getFormattedValue'
|
||||
return getattr(field, method)(obj, val, language=language)
|
||||
|
||||
def getLabel(self, name, type='field'):
|
||||
'''Gets the translated label of field named p_name. If p_type is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue