Add view for consuming new batch ID; misc. tweaks for grids etc.
This commit is contained in:
parent
6ae129ea24
commit
8186366b69
5 changed files with 76 additions and 38 deletions
|
@ -26,6 +26,7 @@ Core Grid Classes
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import datetime
|
||||
import urllib
|
||||
|
||||
import six
|
||||
|
@ -34,7 +35,7 @@ from sqlalchemy import orm
|
|||
|
||||
from rattail.db import api
|
||||
from rattail.db.types import GPCType
|
||||
from rattail.util import pretty_boolean, pretty_quantity, prettify
|
||||
from rattail.util import prettify, pretty_boolean, pretty_quantity, pretty_hours
|
||||
|
||||
import webhelpers2_grid
|
||||
from pyramid.renderers import render
|
||||
|
@ -149,6 +150,8 @@ class Grid(object):
|
|||
self.set_renderer(key, self.render_percent)
|
||||
elif type_ == 'quantity':
|
||||
self.set_renderer(key, self.render_quantity)
|
||||
elif type_ == 'duration':
|
||||
self.set_renderer(key, self.render_duration)
|
||||
else:
|
||||
raise ValueError("Unsupported type for column '{}': {}".format(key, type_))
|
||||
|
||||
|
@ -211,6 +214,12 @@ class Grid(object):
|
|||
value = self.obtain_value(obj, column_name)
|
||||
return pretty_quantity(value)
|
||||
|
||||
def render_duration(self, obj, column_name):
|
||||
value = self.obtain_value(obj, column_name)
|
||||
if value is None:
|
||||
return ""
|
||||
return pretty_hours(datetime.timedelta(seconds=value))
|
||||
|
||||
def set_url(self, url):
|
||||
self.url = url
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue