2020-09-24 14:39:09 -04:00
|
|
|
from babel.dates import format_datetime, get_timezone
|
2020-09-25 11:33:20 -04:00
|
|
|
from flask_table import Table, Col, DatetimeCol, BoolCol, NestedTableCol
|
2020-09-23 12:43:58 -04:00
|
|
|
|
|
|
|
|
2020-09-24 14:39:09 -04:00
|
|
|
class BetterDatetimeCol(Col):
|
|
|
|
"""Format the content as a datetime, unless it is None, in which case,
|
|
|
|
output empty.
|
|
|
|
|
|
|
|
"""
|
|
|
|
def __init__(self, name, datetime_format='short', tzinfo='', locale='', **kwargs):
|
|
|
|
super(BetterDatetimeCol, self).__init__(name, **kwargs)
|
|
|
|
self.datetime_format = datetime_format
|
|
|
|
self.tzinfo = tzinfo
|
|
|
|
self.locale = locale
|
|
|
|
|
|
|
|
def td_format(self, content):
|
|
|
|
if content:
|
|
|
|
return format_datetime(content, self.datetime_format, self.tzinfo, self.locale)
|
|
|
|
else:
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
2020-12-16 10:12:01 -05:00
|
|
|
class NotificationTable(Table):
|
2020-09-25 11:33:20 -04:00
|
|
|
type = Col('type')
|
|
|
|
date = BetterDatetimeCol('Date', "medium", tzinfo=get_timezone('US/Eastern'), locale='en')
|
|
|
|
successful = BoolCol('Success?')
|
|
|
|
error_message = Col('error')
|
|
|
|
|
2021-01-04 12:15:56 -05:00
|
|
|
class NestedDataColumn(Table):
|
|
|
|
type = Col('Type')
|
|
|
|
data = Col('Data')
|
2020-09-25 11:33:20 -04:00
|
|
|
|
2020-09-23 12:43:58 -04:00
|
|
|
class SampleTable(Table):
|
|
|
|
def sort_url(self, col_id, reverse=False):
|
|
|
|
pass
|
2020-12-09 21:38:05 -05:00
|
|
|
classes = ["table","align-items-center","table-flush"]
|
2020-09-23 12:43:58 -04:00
|
|
|
barcode = Col('Barcode')
|
2020-09-24 14:39:09 -04:00
|
|
|
date = BetterDatetimeCol('Date', "medium", tzinfo=get_timezone('US/Eastern'), locale='en')
|
2021-01-04 12:15:56 -05:00
|
|
|
# station = Col('Station') # TODO: Pad with leading 0s to 4 digits
|
|
|
|
ids = NestedTableCol('IDs', NestedDataColumn)
|
|
|
|
taken_at = NestedTableCol('Taken at', NestedDataColumn) # TODO: Pad with leading 0s to 4 digits
|
|
|
|
contacts = NestedTableCol('contacts', NestedDataColumn)
|
2020-12-16 10:12:01 -05:00
|
|
|
notifications = NestedTableCol('notifications', NotificationTable)
|
2020-09-25 11:33:20 -04:00
|
|
|
|
2020-09-23 16:01:31 -04:00
|
|
|
class IvyFileTable(Table):
|
|
|
|
def sort_url(self, col_id, reverse=False):
|
|
|
|
pass
|
2021-01-11 10:43:36 -05:00
|
|
|
classes = ["table","align-items-center","table-flush"]
|
2020-09-23 16:01:31 -04:00
|
|
|
file_name = Col('File Name')
|
2020-09-24 14:39:09 -04:00
|
|
|
date_added = BetterDatetimeCol('Date', "medium", tzinfo=get_timezone('US/Eastern'), locale='en')
|
2020-09-23 16:01:31 -04:00
|
|
|
sample_count = Col('Total Records')
|
2020-09-23 17:00:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
class InvitationTable(Table):
|
2021-01-11 10:43:36 -05:00
|
|
|
classes = ["table","align-items-center","table-flush"]
|
2020-09-23 17:00:51 -04:00
|
|
|
def sort_url(self, col_id, reverse=False):
|
|
|
|
pass
|
2020-09-24 14:39:09 -04:00
|
|
|
date_sent = BetterDatetimeCol('Date Sent', "medium", tzinfo=get_timezone('US/Eastern'), locale='en')
|
2020-09-23 17:00:51 -04:00
|
|
|
location = Col('Location')
|
|
|
|
date = Col('Date')
|
2020-12-30 09:06:46 -05:00
|
|
|
total_recipients = Col('# Recipients')
|