[gen] pod field: bugfix with attr 'formats' without method 'showTemplate'; [shared] bugfix: renamed module ldap to ldap_connector.
This commit is contained in:
parent
5ac8e71a6f
commit
c2676c9cf8
7 changed files with 25 additions and 26 deletions
|
@ -38,6 +38,15 @@ def osPathJoin(*pathElems):
|
|||
strings.'''
|
||||
return os.path.join(*pathElems).rstrip(os.sep)
|
||||
|
||||
def getShownSize(size):
|
||||
'''Express p_size (a file size in bytes) in a human-readable way.'''
|
||||
# Display the size in bytes if smaller than 1024 bytes
|
||||
if size < 1024: return '%d byte(s)' % size
|
||||
size = size / 1024.0 # This is the size, in Kb
|
||||
if size < 1024: return '%s Kb' % sutils.formatNumber(size, precision=1)
|
||||
size = size / 1024.0 # This is the size, in Mb
|
||||
return '%s Mb' % sutils.formatNumber(size, precision=1)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
class FileInfo:
|
||||
'''A FileInfo instance holds metadata about a file on the filesystem.
|
||||
|
@ -113,14 +122,7 @@ class FileInfo:
|
|||
'''Normalizes file p_name.'''
|
||||
return name[max(name.rfind('/'), name.rfind('\\'), name.rfind(':'))+1:]
|
||||
|
||||
def getShownSize(self):
|
||||
'''Displays this file's size in the user interface.'''
|
||||
if self.size < 1024:
|
||||
# Display the size in bytes
|
||||
return '%d byte(s)' % self.size
|
||||
else:
|
||||
# Display the size in Kb
|
||||
return '%d Kb' % (self.size / 1024)
|
||||
def getShownSize(self): return getShownSize(self.size)
|
||||
|
||||
def replicateFile(self, src, dest):
|
||||
'''p_src and p_dest are open file handlers. This method copies content
|
||||
|
|
|
@ -236,8 +236,7 @@ class Pod(Field):
|
|||
# What are the output formats when generating documents from this pod ?
|
||||
self.formats = formats
|
||||
if not formats: # Compute default ones
|
||||
ext = self.getExtension(self.template[0])
|
||||
self.formats = Pod.allFormats[ext]
|
||||
self.formats = self.getAllFormats(self.template[0])
|
||||
# Parameter "getChecked" can specify the name of a Ref field belonging
|
||||
# to the same gen class. If it is the case, the context of the pod
|
||||
# template will contain an additional object, name "_checked", and
|
||||
|
@ -294,7 +293,7 @@ class Pod(Field):
|
|||
def getAllFormats(self, template):
|
||||
'''Gets all the output formats that are available for a given
|
||||
p_template.'''
|
||||
return self.allFormats[self.getExtension(template)]
|
||||
return Pod.allFormats[self.getExtension(template)]
|
||||
|
||||
def setTemplateFolder(self, folder):
|
||||
'''This methods adds a prefix to every template name in
|
||||
|
@ -363,11 +362,10 @@ class Pod(Field):
|
|||
'''Returns, among self.template, the template(s) that can be shown.'''
|
||||
res = []
|
||||
if not self.showTemplate:
|
||||
# Show them all in any format.
|
||||
# Show them all in the formats spoecified in self.formats.
|
||||
for template in self.template:
|
||||
res.append(Object(template=template,
|
||||
formats=self.getAllFormats(template),
|
||||
freezeFormats=self.getFreezeFormats(obj, template)))
|
||||
res.append(Object(template=template, formats=self.formats,
|
||||
freezeFormats=self.getFreezeFormats(obj, template)))
|
||||
else:
|
||||
isManager = obj.user.has_role('Manager')
|
||||
for template in self.template:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue