From 28fbdcdf9f5c56c09896b81cafceb453d7a39cc3 Mon Sep 17 00:00:00 2001 From: jrdbnntt Date: Tue, 7 Feb 2017 23:05:43 -0500 Subject: [PATCH] view_local_schedule script --- hackfsu_com/settings.py | 2 -- requirements.txt | 1 + scripts/view_local_schedule.py | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 scripts/view_local_schedule.py diff --git a/hackfsu_com/settings.py b/hackfsu_com/settings.py index b7901e7..97f05cb 100644 --- a/hackfsu_com/settings.py +++ b/hackfsu_com/settings.py @@ -142,8 +142,6 @@ os.path.join(BASE_DIR, 'webapp/build/static'), ] - - IGNORABLE_404_URLS = [ re.compile(r'\.(php|cgi|pug|scss)$'), re.compile(r'^/node_modules/'), diff --git a/requirements.txt b/requirements.txt index 8b5cc62..8b5e609 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ mandrill django-extensions terminaltables python-dateutil +pytz \ No newline at end of file diff --git a/scripts/view_local_schedule.py b/scripts/view_local_schedule.py new file mode 100644 index 0000000..fdc9a25 --- /dev/null +++ b/scripts/view_local_schedule.py @@ -0,0 +1,34 @@ +""" + Prints the schedule in the local time zone +""" + +from api.models import ScheduleItem, Hackathon +from datetime import datetime +from terminaltables import AsciiTable +import pytz + + +EASTERN = pytz.timezone('US/Eastern') + + +def format_time(dt: datetime): + dt = dt.astimezone(tz=EASTERN) + return dt.strftime('%a %I:%M %p') + + +def run(): + h = Hackathon.objects.current() + items = ScheduleItem.objects.filter(hackathon=h).order_by('start', 'end') + + title = '{} Schedule in {}'.format(h.name, EASTERN.zone) + data = [('Start', 'End', 'Event Name')] + + for item in items: + data.append(( + format_time(item.start), + format_time(item.end) if item.end is not None else 'n/a', + item.name + )) + + table = AsciiTable(table_data=data, title=title) + print(table.table)