示例#1
0
def row_template(index, path, f, url_prefix):
    output = '\t\t<tr>\n'
    if index % 2 == 1:
        output = '\t\t<tr class="altrow">\n'
    if f == path.parent:
        output += '\t\t\t<td><a class="backlink" title="%s" href="%s%s">%s</a></td>\n' % (
            f.name, url_prefix, f.url, _('Parent folder'))
        output += '\t\t\t<td class="number"></td>\n'
        output += '\t\t\t<td></td>\n'
        output += '\t\t\t<td></td>\n'
        output += '\t\t\t<td></td>\n'
    else:
        output += '\t\t\t<td>\n'
        if f.is_folder():
            output += '\t\t\t\t<span class="folder">[%s]</span> ' % _('Folder')
        elif f.ext:
            output += '\t\t\t\t<span class="file ext-%s">[%s]</span> ' % (
                f.ext.lower(), _('File'))
        else:
            output += '\t\t\t\t<span class="file">[%s]</span> ' % _('File')

        if f.is_broken_link():
            output += '%s <span class="broken_link">[%s]</span>' % (
                f.name, _('Broken link'))
        else:
            output += '<a title="%s" href="%s%s">%s</a>' % (f.name, url_prefix,
                                                            f.url, f.name)
            if f.is_link():
                output += ' <span class="link">[%s]</span>' % _('Link')
        output += '\n\t\t\t</td>\n'
        output += '\t\t\t<td class="number">%s</td>\n' % filesizeformat(f.size)
        output += '\t\t\t<td>%s</td>\n' % value_to_string(f.created)
        output += '\t\t\t<td>%s</td>\n' % value_to_string(f.modified)
        output += '\t\t\t<td>%s</td>\n' % actions_template(f, url_prefix)
    return output
示例#2
0
 def column_template(self, instance, index):
     css = ''
     value = field_to_value(self.field_list[index], instance)
     if isinstance(value, (int, float)) and not isinstance(value, bool):
         css = u' class="number"'
     value = value_to_string(value)
     if index == 0 and hasattr(instance, 'get_absolute_url'):
         value = u'<a href="%s">%s</a>' % (instance.get_absolute_url(), value)
     return u'\t\t<td%s>%s</td>\n' % (css, value)
示例#3
0
def field_template(name, field, form_or_model, attrs={}, suffix=""):
    label = ""
    value = ""
    output = ""
    td_attrs = {}

    if isinstance(field, models.Field):
        label = u'%s' % field.verbose_name
        value = field_to_string(field, form_or_model)

    elif isinstance(field, forms.Field):
        bf = BoundField(form_or_model, field, name)
        label = u'%s' % bf.label_tag()
        value = u'%s' % bf
        if bf.help_text:
            value += '<br/>\n<span class="help_text">%s</span>' % (
                u'%s' % bf.help_text)
        if bf._errors():
            value += '<br/>\n<ul class="errorlist">\n'
            for error in bf._errors():
                value += '\t<li>%s</li>\n' % error
            value += '</ul>\n'
        css_classes = bf.css_classes()
        if css_classes:
            td_attrs['class'] = css_classes

    else:
        name = _(pretty_name(name).lower())
        label = u'%s' % name.capitalize()
        if callable(field):
            value = value_to_string(field())
        else:
            value = value_to_string(field)

    td_attrs.update(attrs)

    if label and value:
        output += ("\t\t<th>%s</th>\n" % (label[0].capitalize() + label[1:]))
        output += "\t\t<td%s>\n" % flatatt(td_attrs)
        output += "\t\t\t%s%s\n" % (value, suffix)
        output += "\t\t</td>\n"

    return output
示例#4
0
 def column_template(self, instance, index):
     css = ''
     value = field_to_value(self.field_list[index], instance)
     if isinstance(value, (int, float)) and not isinstance(value, bool):
         css = u' class="number"'
     value = value_to_string(value)
     if index == 0 and hasattr(instance, 'get_absolute_url'):
         value = u'<a href="%s">%s</a>' % (instance.get_absolute_url(),
                                           value)
     return u'\t\t<td%s>%s</td>\n' % (css, value)
示例#5
0
def field_template(name, field, form_or_model, attrs={}, suffix=""):
    label = ""
    value = ""
    output = ""
    td_attrs = {}

    if isinstance(field, models.Field):
        label = u'%s' % field.verbose_name
        value = field_to_string(field, form_or_model)

    elif isinstance(field, forms.Field):
        bf = BoundField(form_or_model, field, name)
        label = u'%s' % bf.label_tag()
        value = u'%s' % bf
        if bf.help_text:
            value += '<br/>\n<span class="help_text">%s</span>' % (u'%s' % bf.help_text)
        if bf._errors():
            value += '<br/>\n<ul class="errorlist">\n'
            for error in bf._errors():
                value += '\t<li>%s</li>\n' % error
            value += '</ul>\n'
        css_classes = bf.css_classes()
        if css_classes:
            td_attrs['class'] = css_classes

    else:
        name = _(pretty_name(name).lower())
        label = u'%s' % name.capitalize()
        if callable(field):
            value = value_to_string(field())
        else:
            value = value_to_string(field)
    
    td_attrs.update(attrs)

    if label and value:
        output += ("\t\t<th>%s</th>\n" % (label[0].capitalize() + label[1:]))
        output += "\t\t<td%s>\n" % flatatt(td_attrs)
        output += "\t\t\t%s%s\n" % (value, suffix)
        output += "\t\t</td>\n"

    return output
示例#6
0
def row_template(index, path, f, url_prefix):
    output = "\t\t<tr>\n"
    if index % 2 == 1:
        output = '\t\t<tr class="altrow">\n'
    if f == path.parent:
        output += '\t\t\t<td><a class="backlink" title="%s" href="%s%s">%s</a></td>\n' % (
            f.name,
            url_prefix,
            f.url,
            _("Parent folder"),
        )
        output += '\t\t\t<td class="number"></td>\n'
        output += "\t\t\t<td></td>\n"
        output += "\t\t\t<td></td>\n"
        output += "\t\t\t<td></td>\n"
    else:
        output += "\t\t\t<td>\n"
        if f.is_folder():
            output += '\t\t\t\t<span class="folder">[%s]</span> ' % _("Folder")
        elif f.ext:
            output += '\t\t\t\t<span class="file ext-%s">[%s]</span> ' % (f.ext.lower(), _("File"))
        else:
            output += '\t\t\t\t<span class="file">[%s]</span> ' % _("File")

        if f.is_broken_link():
            output += '%s <span class="broken_link">[%s]</span>' % (f.name, _("Broken link"))
        else:
            output += '<a title="%s" href="%s%s">%s</a>' % (f.name, url_prefix, f.url, f.name)
            if f.is_link():
                output += ' <span class="link">[%s]</span>' % _("Link")
        output += "\n\t\t\t</td>\n"
        output += '\t\t\t<td class="number">%s</td>\n' % filesizeformat(f.size)
        output += "\t\t\t<td>%s</td>\n" % value_to_string(f.created)
        output += "\t\t\t<td>%s</td>\n" % value_to_string(f.modified)
        output += "\t\t\t<td>%s</td>\n" % actions_template(f, url_prefix)
    return output
示例#7
0
 def __unicode__(self):
     return _(u'Rev # %(created)s') % {'created': value_to_string(self.created)}
示例#8
0
文件: models.py 项目: bryanriosb/PERP
 def __unicode__(self):
     return _(u'Rev # %(created)s') % {
         'created': value_to_string(self.created)
     }
示例#9
0
文件: models.py 项目: bryanriosb/PERP
 def __unicode__(self):
     return "#%s of %s" % (self.id, value_to_string(self.created))
示例#10
0
def default_empty(obj):
    """Returns the default empty value representation if obj is invalid.
    """
    if not obj:
        return value_to_string(obj)
    return obj
示例#11
0
def default_empty(obj):
    """Returns the default empty value representation if obj is invalid.
    """
    if not obj:
        return value_to_string(obj)
    return obj
示例#12
0
 def __unicode__(self):
     return "#%s of %s" % (self.id, value_to_string(self.created))