def tfoot(self): tr_content = (''.join( self.tfoot_td(i, col_key, col) for i, (col_key, col) in enumerate(self._cols.items()) if col.show)) content = element('tr', content=tr_content, escape_content=False) return element('tfoot', content=content, escape_content=False)
def tfoot_td(self, i, key, col): if key == "id": return element("td", content="#") if i == 1: url = url_for(".create_model") tag = f"<a href='{url}'>Add new</a>" return element("td", content=tag, escape_content=False) return element("td", content="")
def __html__(self): tbody = self.tbody() if tbody or self.allow_empty: content = '\n{thead}\n{tbody}\n{tfoot}\n'.format( thead=self.thead(), tbody=tbody, tfoot=self.tfoot(), ) return element('table', attrs=self.get_html_attrs(), content=content, escape_content=False) else: return element('p', content=self.no_items)
def td_contents(self, item, attr_list): name = self.from_attr_list(item, 'name') refdate = self.from_attr_list(item, 'refdate') # url = '/reprocess?filter={}&refdate={}'.format(name, refdate) url = 'https://us-central1-kyd-storage-001.cloudfunctions.net/kyd-generic-download-publish?filter={}&refdate={}'.format( name, refdate) return element('a', {'href': url}, content='Link')
def td_contents(self, item, attr_list): text = self.td_format(self.text(item, attr_list)) attrs = dict(type='checkbox', value=text, name='input_checkbox') return html.element('input', attrs=attrs, content=' ', escape_content=False)
def td_contents(self, item, attr_list): img = self.from_attr_list(item, [self.img_attr]) return html.element('img', { 'src': img, 'alt': 'hi', 'height': 80, 'width': 80 })
def td_contents(self, item, attr_list): attrs = dict(href=self.url(item)) attrs.update(self.anchor_attrs) text = self.td_format(self.text(item, attr_list)) element_ret = html.element('a', attrs=attrs, content=text, escape_content=False) return element_ret
def tbody(self): out = [self.tr(item) for item in self.items] if self.use_item_notes: notes = [self.get_notes_tr(item) for item in self.items] out = list(itertools.chain(*zip(out, notes))) if not out: return '' content = '\n{}\n'.format('\n'.join(out)) return element('tbody', content=content, escape_content=False)
def td_contents(self, item, attr_list): ''' Wird unsere Link in einer HTML-a tag übersetzen ''' text = self.from_attr_list(item, attr_list) link = self.from_attr_list(item, [self.url_attr]) return element('a', { 'href': link, 'onclick': "loading();" }, content=text)
def td(self, item, attr): content = self.td_contents(item, self.get_attr_list(attr)) if item.isActive == 'Active': return html.element('td', content=content, escape_content=False, attrs={'class': 'serviceActive'}) elif item.isActive == 'Inactive': return html.element('td', content=content, escape_content=False, attrs={'class': 'serviceInactive'}) elif item.isActive == 'Activating': return html.element('td', content=content, escape_content=False, attrs={'class': 'serviceActivating'}) else: return html.element('td', content=content, escape_content=False, attrs={'class': 'serviceNone'})
def td(self, item, attr): content = self.td_contents(item, self.get_attr_list(attr)) if attr == "total": if item.total > 0: over_par = {"bgcolor": "#0047b3", "style": 'text-align:center; font-size: 16pt; font-family: calibri; border-radius: 6px'} return element( 'td', content="+"+str(content), escape_content=False, attrs=over_par) elif item.total < 0: under_par = {"bgcolor":"#FF0000","style":'text-align:center; font-size: 16pt; font-family: calibri; border-radius: 6px'} return element( 'td', content=content, escape_content=False, attrs=under_par) elif item.total == 0: on_par = {"bgcolor":"#d3d3d3","style":'text-align:center; font-size: 16pt; font-family: calibri; border-radius: 6px'} return element( 'td', content=content, escape_content=False, attrs=on_par) elif attr == "round": if item.round > 0: over_par = {"bgcolor": "#0000FF", "style": 'text-align:center; font-size: 16pt; font-family: calibri'} return element( 'td', content="+"+str(content), escape_content=False, attrs=over_par) elif item.round < 0: under_par = {"bgcolor":"#FF0000","style":'text-align:center; font-size: 16pt; font-family: calibri'} return element( 'td', content=content, escape_content=False, attrs=under_par) elif item.round == 0: on_par = {"bgcolor":"#d3d3d3","style":'text-align:center; font-size: 16pt; font-family: calibri'} return element( 'td', content=content, escape_content=False, attrs=on_par) else: return element( 'td', content=content, escape_content=False, attrs=self.td_html_attrs)
def td_contents(self, item, attr_list): #item is Task elements=[] #add fire mark if date.today() >= item.ddate: #delayed if date.today() > cycletypes.next(item.cycletype,item.cycle,item.ddate): #delayed more then twice elements.append(element('span ',attrs={'class':'glyphicon glyphicon-fire gly-spin color-red'})) else: #delayed a bit elements.append(element('span ',attrs={'class':'glyphicon glyphicon-bell color-yellow'})) if item.logging==0: #No logging required, making just a link send via ajax attrs = {'data-id':item.id,'type':"button",'class':"btn btn-primary btn-xs {}".format(self.endpoint)} text = 'Done' elements.append(element('button',attrs=attrs, content=text, escape_content=False)) else: #we should show modal window and collect data attrs = {'data-logid':item.id,'type':"button",'class':"btn btn-success btn-xs {}".format(self.logendpoint)} text = 'Log...' elements.append(element('button',attrs=attrs, content=text, escape_content=False)) return ''.join(elements)
def td(self, item, attr, id_attr=True): """add option to import tag attrs from item itself - item tag attrs override td_html_attrs""" content = self.td_contents(item, self.get_attr_list(attr)) if len(item.html_attrs) and self.use_item_attrs: td_html_attrs = item.html_attrs else: td_html_attrs = self.td_html_attrs if id_attr: self.add_html_id_attr(item, td_html_attrs, attr) return element('td', content=content, escape_content=False, attrs=td_html_attrs)
def th(self, col_key, col): content = self.th_contents(col_key, col) attrs = col.th_html_attrs if self.rotate_header: content = Markup('<div><span>') + content + Markup('</span></div>') if 'class' in attrs: attrs['class'] += ' rotate' else: attrs['class'] = 'rotate' return element( 'th', content=content, escape_content=False, attrs=attrs, )
def td_contents(self, item, attr_list): text = 'View Petition' url = self.from_attr_list(item, [self.url_attr]) return element('a', {'href': url}, content=text)
def td_format(self, content): #url = re.escape(content) url = content url = url.replace("I:\\", "\\\\Utsarr.net\\utfile\\USERS\\") print(url) return element('a', attrs=dict(href=url), content=url)
def td_contents(self, item, attr_list): text = self.from_attr_list(item, attr_list) url = self.from_attr_list(item, [self.url_attr]) id = self.from_attr_list(item, [self.id_attr]) return element('a', {'href': url, 'id': id}, content=text)
def td_contents(self, item, attr_list): attrs = {'data-id':item.id,'type':"button",'class':"btn btn-info btn-xs {}".format(Markup.escape(self.endpoint))} attrs.update(self.anchor_attrs) text = self.td_format(self.text(item, attr_list)) return element('button',attrs=attrs, content=text, escape_content=False)
def td_contents(self, item, attr_list): attrs = {'data-target':self.endpoint, 'data-myid':item.id,'type':"button",'class':"btn btn-info btn-xs",'data-toggle':"modal"} attrs.update(self.anchor_attrs) text = self.td_format(self.text(item, attr_list)) return element('button',attrs=attrs, content=text, escape_content=False)
def td_format(self, content): return element('a', attrs=dict(href=content, target="_blank"), content="Seite öffnen")
def td_contents(self, item, attr_list): text = self.from_attr_list(item, attr_list) url = self.from_attr_list(item, [self.url_attr]) return html.element('a', {'href': url}, content=text)