[gen] Boolean field can now be rendered as 2 radio buttons.

This commit is contained in:
Gaetan Delannay 2014-08-08 12:36:19 +02:00
parent f8d5cb546d
commit 6770d23a50
4 changed files with 66 additions and 32 deletions

View file

@ -273,7 +273,7 @@ class FieldDescriptor:
return msgId, default, niceDefault
def walkString(self):
'''How to generate an Appy String?'''
'''Generates String-specific i18n labels.'''
if self.appyType.isSelect and \
(type(self.appyType.validator) in (list, tuple)):
# Generate i18n messages for every possible value if the list
@ -283,8 +283,15 @@ class FieldDescriptor:
self.fieldName, value)
self.i18n(label, value)
def walkBoolean(self):
'''Generates Boolean-specific i18n labels.'''
if self.appyType.render == 'radios':
for v in ('true', 'false'):
label = '%s_%s_%s' % (self.classDescr.name, self.fieldName, v)
self.i18n(label, self.appyType.yesNo[v])
def walkAction(self):
'''Generates the i18n-related label.'''
'''Generates Action-specific i18n labels.'''
if self.appyType.confirm:
label = '%s_%s_confirm' % (self.classDescr.name, self.fieldName)
self.i18n(label, po.CONFIRM, nice=False)
@ -351,6 +358,8 @@ class FieldDescriptor:
group.generateLabels(self.generator.labels, self.classDescr, set())
# Manage things which are specific to String types
if self.appyType.type == 'String': self.walkString()
# Manage things which are specific to Boolean types
if self.appyType.type == 'Boolean': self.walkBoolean()
# Manage things which are specific to Actions
elif self.appyType.type == 'Action': self.walkAction()
# Manage things which are specific to Ref types

View file

@ -207,6 +207,7 @@ class ZopeInstaller:
translations = [t.o.id for t in appyTool.translations]
# We browse the languages supported by this application and check
# whether we need to create the corresponding Translation objects.
done = []
for language in self.languages:
if language in translations: continue
# We will create, in the tool, the translation object for this
@ -218,7 +219,8 @@ class ZopeInstaller:
title = langEn
appyTool.create('translations', noSecurity=True,
id=language, title=title)
appyTool.log('Translation object created for "%s".' % language)
done.append(language)
if done: appyTool.log('Translations created for %s.' % ', '.join(done))
# Synchronizes, if required, every Translation object with the
# corresponding "po" file on disk.
@ -226,14 +228,16 @@ class ZopeInstaller:
appFolder = self.config.diskFolder
appName = self.config.PROJECTNAME
i18nFolder = os.path.join(appFolder, 'tr')
done = []
for translation in appyTool.translations:
# Get the "po" file
poName = '%s-%s.po' % (appName, translation.id)
poFile = PoParser(os.path.join(i18nFolder, poName)).parse()
for message in poFile.messages:
setattr(translation, message.id, message.getMessage())
appyTool.log('Translation "%s" updated from "%s".' % \
(translation.id, poName))
done.append(translation.id)
appyTool.log('Translation(s) %s updated (%s messages).' % \
(', '.join(done), len(poFile.messages)))
# Execute custom installation code if any.
if hasattr(appyTool, 'onInstall'): appyTool.onInstall()
@ -316,7 +320,6 @@ class ZopeInstaller:
install_product(self.app, Products.__path__[1], 'ZCTextIndex', [], {})
def install(self):
self.logger.info('is being installed...')
self.installDependencies()
self.patchZope()
self.installRoles()

View file

@ -160,13 +160,9 @@ class Table:
def addCssClasses(self, css_class):
'''Adds a single or a group of p_css_class.'''
classes = self.css_class
if classes == None:
classes = ''
if not classes:
self.css_class = css_class
if not self.css_class: self.css_class = css_class
else:
self.css_class += ' ' + css_classes
self.css_class += ' ' + css_class
# Ensures that every class appears once
self.css_class = ' '.join(set(self.css_class.split()))