def selected_td(self, col_num, i, item): from string import Template from webhelpers2.html.builder import HTML icon_class = "glyphicon glyphicon-thumbs-down" if item['selected'] == True: icon_class = "glyphicon glyphicon-thumbs-up" div = Template("""\ <button class="btn btn-mini select" data-value="${identifier}"><i class="${icon_class}"></i></button> """) return HTML.td(HTML.literal(div.substitute({'identifier': item['identifier'], 'icon_class': icon_class} )))
def selected_td(self, col_num, i, item): from string import Template from webhelpers2.html.builder import HTML icon_class = "glyphicon glyphicon-thumbs-down" if item.get('selected') == True: icon_class = "glyphicon glyphicon-thumbs-up" div = Template("""\ <a class="select" data-value="${recordid}" href="#"><i class="${icon_class}"></i></a> """) return HTML.td(HTML.literal(div.substitute({'recordid': item['identifier'], 'icon_class': icon_class} )))
def render_timestamp_td(self, timestamp): import datetime if timestamp is None: return HTML.td('') if type(timestamp) is not datetime.datetime: from dateutil import parser as datetime_parser timestamp = datetime_parser.parse(str(timestamp)) span_class = 'due-date badge' span = HTML.tag( "span", c=HTML.literal(timestamp.strftime('%Y-%m-%d %H:%M:%S')), class_=span_class, ) return HTML.td(span)
def render_format_td(self, format, source): span_class = 'label' if format is None: format = 'unknown' if 'wps' in format.lower(): span_class += ' label-warning' elif 'wms' in format.lower(): span_class += ' label-info' elif 'netcdf' in format.lower(): span_class += ' label-success' else: span_class += ' label-default' anchor = string.Template("""\ <a class="${span_class}" href="${source}" data-format="${format}">${format}</a> """) return HTML.td(HTML.literal(anchor.substitute( {'source': source, 'span_class': span_class, 'format': format} )))
def _column_format(column_number, i, record): import datetime timestamp = get_value(record, attribute) if timestamp is None: return HTML.td('') if type(timestamp) is not datetime.datetime: from dateutil import parser as datetime_parser timestamp = datetime_parser.parse(str(timestamp)) span_class = 'due-date badge' span = HTML.tag( "span", c=HTML.literal(timestamp.strftime('%Y-%m-%d %H:%M:%S')), class_=span_class, ) return HTML.td(span)
def render_format_td(self, format, source): span_class = 'label' if format is None: format = 'unknown' if 'wps' in format.lower(): span_class += ' label-warning' elif 'wms' in format.lower(): span_class += ' label-info' elif 'netcdf' in format.lower(): span_class += ' label-success' else: span_class += ' label-default' anchor = string.Template("""\ <a class="${span_class}" href="${source}" data-format="${format}">${format}</a> """) return HTML.td( HTML.literal( anchor.substitute({ 'source': source, 'span_class': span_class, 'format': format })))
def render_td(self, renderer, **data): mytemplate = self.lookup.get_template(renderer) return HTML.td(HTML.literal(mytemplate.render(**data)))
def render_td(self, renderer, **data): mytemplate = mylookup.get_template(renderer + ".mako") return HTML.td(HTML.literal(mytemplate.render(**data)))