pvl/verkko/hosts.py
changeset 6 0f243c59d5d1
parent 5 91970ce3fc6b
child 8 f64c44640b15
equal deleted inserted replaced
5:91970ce3fc6b 6:0f243c59d5d1
   106         return html.table(
   106         return html.table(
   107             html.caption(title) if title else None,
   107             html.caption(title) if title else None,
   108             html.thead(
   108             html.thead(
   109                 html.tr(
   109                 html.tr(
   110                     html.th(
   110                     html.th(
   111                         html.a(href='?sort={name}'.format(name=sort))(title) if sort else (title)
   111                         html.a(href=self.url(sort=sort))(title) if sort else (title)
   112                     ) for title, sort in COLS
   112                     ) for title, sort in COLS
   113                 )
   113                 )
   114             ),
   114             ),
   115             html.tbody(
   115             html.tbody(
   116                 html.tr(class_=('alternate' if i % 2 else None), id=host.id)(
   116                 html.tr(class_=('alternate' if i % 2 else None), id=host.id)(
   117                     html.td(class_='id')(
   117                     html.td(class_='id')(
   118                         html.a(href='/hosts/{host.id}'.format(host=host))(
   118                         html.a(href=self.url(ItemHandler, id=host.id))(
   119                             '#' #host['rowid'])
   119                             '#' #host['rowid'])
   120                         )
   120                         )
   121                     ),
   121                     ),
   122                     html.td(class_='ip')(
   122                     html.td(class_='ip')(
   123                         html.a(href='/hosts/ip/{host.ip}'.format(host=host))(host.ip)
   123                         html.a(href=self.url(ListHandler, attr='ip', value=host.ip))(
       
   124                             host.ip
       
   125                         )
   124                     ),
   126                     ),
   125                     html.td(class_='mac')(
   127                     html.td(class_='mac')(
   126                         html.a(href='/hosts/mac/{host.mac}'.format(host=host))(
   128                         html.a(href=self.url(ListHandler, attr='mac', value=host.mac))(
   127                             host.render_mac()
   129                             host.render_mac()
   128                         )
   130                         )
   129                     ),
   131                     ),
   130                     html.td(host.render_name()),
   132                     html.td(host.render_name()),
   131                     html.td(host.when()),
   133                     html.td(host.when()),
   148             ),
   150             ),
   149 
   151 
   150             html.h2('Related'),
   152             html.h2('Related'),
   151             self.render_hosts(hosts),
   153             self.render_hosts(hosts),
   152 
   154 
   153             html.a(href='/hosts')(html('«'), 'Back'),
   155             html.a(href=self.url(IndexHandler))(html('«'), 'Back'),
   154         )
   156         )
   155 
   157 
   156 class IndexHandler (BaseHandler) :
   158 class IndexHandler (BaseHandler) :
   157     def process (self) :
   159     def process (self) :
   158         self.hosts = self.query()
   160         self.hosts = self.query()