Skip to content

Commit

Permalink
refactor timestamp choices
Browse files Browse the repository at this point in the history
  • Loading branch information
sidgupta committed May 6, 2016
1 parent 80b0818 commit 20c00b5
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions caravel/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

config = app.config

TIMESTAMP_CHOICES = [
('smart_date', 'Adaptative formating'),
("%m/%d/%Y", '"%m/%d/%Y" | 01/14/2019'),
("%Y-%m-%d", '"%Y-%m-%d" | 2019-01-14'),
("%Y-%m-%d %H:%M:%S",
'"%Y-%m-%d %H:%M:%S" | 2019-01-14 01:32:10'),
("%H:%M:%S", '"%H:%M:%S" | 01:32:10'),
]

class BetterBooleanField(BooleanField):

Expand Down Expand Up @@ -433,26 +441,12 @@ def __init__(self, viz):
'table_timestamp_format': FreeFormSelectField(
'Table Timestamp Format',
default='smart_date',
choices=[
('smart_date', 'Adaptative formating'),
("%m/%d/%Y", '"%m/%d/%Y" | 01/14/2019'),
("%Y-%m-%d", '"%Y-%m-%d" | 2019-01-14'),
("%Y-%m-%d %H:%M:%S",
'"%Y-%m-%d %H:%M:%S" | 2019-01-14 01:32:10'),
("%H:%M:%S", '"%H:%M:%S" | 01:32:10'),
],
choices=TIMESTAMP_CHOICES,
description="Timestamp Format"),
'x_axis_format': FreeFormSelectField(
'X axis format',
default='smart_date',
choices=[
('smart_date', 'Adaptative formating'),
("%m/%d/%Y", '"%m/%d/%Y" | 01/14/2019'),
("%Y-%m-%d", '"%Y-%m-%d" | 2019-01-14'),
("%Y-%m-%d %H:%M:%S",
'"%Y-%m-%d %H:%M:%S" | 2019-01-14 01:32:10'),
("%H:%M:%S", '"%H:%M:%S" | 01:32:10'),
],
choices=TIMESTAMP_CHOICES,
description="D3 format syntax for y axis "
"https://github.com/mbostock/\n"
"d3/wiki/Formatting"),
Expand Down

0 comments on commit 20c00b5

Please sign in to comment.