def render(self, obj): datetime = Accessor(self.field).resolve(obj) # print(datetime) datetime = timezone.localtime(datetime) # print(datetime) text = datetime.strftime(self.format) return escape(text)
def render(self, obj): if self.model_function: self.field = self.model_function text = Accessor(self.field).resolve(obj) if self.html: return text return escape(text)
def render(self, value): data = Accessor(self.field).resolve(value) data_new = value.sowing_date + timedelta( days=value.days) if data else '' data_new = data_new.strftime( "%d/%m/%Y") if data_new >= date.today() else '' return escape(data_new)
def render(self, obj): checked = bool(Accessor( self.field).resolve(obj)) if self.field else False if checked: return mark_safe('<input checked type="checkbox">') else: return mark_safe('<input type="checkbox">')
def test_resolve_manager_instance(self): p1 = Publication(title='The Python Journal') p1.save() a1 = Article(headline='Django lets you build Web apps easily') a1.save() a1.publications.add(p1) self.assertEqual(Accessor('article_set.count').resolve(p1), 1)
def render(self, obj): ret = '' if Accessor(self.field).resolve(obj): ret = super(CustomNoneColumn, self).render(obj) else: ret = mark_safe(self.none_str) return ret
def render(self, obj): path = Accessor(self.field).resolve(obj) if isinstance(self.image_title, Accessor): title = self.image_title.resolve(self.obj) else: title = self.image_title template = Template('{%% load static %%}<img src="{%% static "%s" %%}"' ' title="%s">' % (path, title)) return template.render(Context())
def render(self, obj): html = super(RemoveConfirmColumn, self).render(obj) extra_val = '' val = Accessor(self.extra_field).resolve(obj) if val: extra_val = val return mark_safe(html.format(self.message).format(extra_val))
def render(self, obj): path = Accessor(self.field).resolve(obj) print self if isinstance(self.image_title, Accessor): title = self.image_title.resolve(self.obj) else: title = self.image_title template = Template( '{%% load static %%}<img style="width:30px;height:30px;"src="{%% static "../../%s" %%}"' ' title="%s">' % (path, title)) return template.render(Context())
def render(self, obj): image = Accessor(self.field).resolve(obj) template = Template(""" {% load static %} {% if image %} <img class="img-responsive" src="{{ image.url }}"> {% else %} <img class="img-responsive" src="{% static 's5appadherant/images/no_image.png' %}"> {% endif %} """) return template.render(Context({'image': image}))
class DatasetListTable(Table): id = Column(field='id', header='ID') name = Column(field='name', header='Dataset') status = DatasetStatusColumn(field='processing_finished', header='Status', links=[ Link(text='View', viewname='dataset-detail', args=(Accessor('pk'), )) ]) errors = ProcessingErrorColumn(header='', searchable=False, sortable=False) class Meta: model = Dataset ajax = True sort = [(0, 'desc')]
class SpectraTable(Table): inventory_id = Column(field='standard.inventory_id', header='Inventory ID') molecule = Column(field='standard.molecule.name', header='Molecule') precursor_mz = Column(field='precursor_mz', header='Precursor m/z') adduct = AdductColumn(field='adduct.delta_formula', header='Adduct') view = LinkColumn(header='', sortable=False, searchable=False, links=[ Link(text='View', viewname='fragmentSpectrum-detail', kwargs={'pk': Accessor('pk')}) ]) class Meta: model = FragmentationSpectrum ajax = True ajax_source = reverse_lazy('spectra_table') sort = [(0, 'asc')]
def render(self, obj): text = Accessor(self.field).resolve(obj) return "<div style='background-color:" + text + "'> </div>"
def render(self, obj): datetime = Accessor(self.field).resolve(obj) text = datetime.strftime(self.format) return escape(text)
def render(self, obj): value = Accessor(self.field).resolve(obj) return '{:0.5f}'.format(value)
def render(self, obj): text = Accessor(self.field).resolve(obj) return escape(text)
def render(self, obj): return Accessor(self.field).resolve(obj)
def render(self, obj): ret = mark_safe('') if Accessor(self.field).resolve(obj): ret = super(NoneableDatetimeColumn, self).render(obj) return ret
def render(self, obj): checked = bool(Accessor( self.field).resolve(obj)) if self.field else False return self.boolean_render(checked)
def render(self, value): data = Accessor(self.field).resolve(value) date = data.strftime("%d/%m/%Y") if data else '' return escape(date)
def text(self): if self.field: basetext = Accessor(self.field).resolve(self.obj) else: basetext = self.basetext return escape(basetext)
def render(self, obj): valor = Accessor(self.field).resolve(obj) return str(valor) + " páginas"
def render(self, obj): valor = Accessor(self.field).resolve(obj) return "Si" if valor == True else "No"