Last active
August 29, 2015 14:02
-
-
Save codersquid/e8ccb13618eab1093e76 to your computer and use it in GitHub Desktop.
help me with the symposion schedule grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section_slug | name | order | |
---|---|---|---|
talks-posters | Grand Ballroom | 0 | |
talks-posters | Room 203 | 1 | |
talks-posters | Room 204 | 2 | |
tutorials | Room 101 | 0 | |
tutorials | Room 102 | 1 | |
tutorials | Room 105 | 2 | |
tutorials | Room 106 | 3 | |
bofs | Grand Ballroom | 0 | |
bofs | Room 203 | 1 | |
bofs | Room 204 | 2 | |
bofs | Room 110 | 3 | |
bofs | Room 111 | 4 | |
bofs | Room 112 | 5 | |
sprints | Room 103 | 0 | |
sprints | Room 104 | 1 | |
sprints | Room 107 | 2 | |
sprints | Room 108 | 3 | |
sprints | Room 202 | 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import argparse | |
import csv | |
from datetime import datetime | |
import time | |
#from symposion.schedule.models import Day, Room, Schedule, Slot, SlotKind, SlotRoom | |
#from symposion.proposals.models import ProposalBase | |
#from symposion.schedule.timetable import TimeTable | |
""" | |
This will create schedule objects to build a schedule grid. | |
In order for this to work a Schedule and associated Days must already exist. | |
python schedutils.py --csv <csvfile> --section <slug> --modeltype <presentations|rooms|slotkinds> | |
presentations csv headers | |
date,time_start,time_end,kind,room,proposal_id,description | |
rooms csv headers | |
section_slug,name,order | |
slotkinds csv headers | |
section_slug,slot_kind,presentation_menu | |
This script is like running manage.py. The DJANGO_SETTINGS_MODULE environment | |
variable needs to be defined, or the default value of "scipy2014.settings" | |
must be in the python path. | |
This is sloppy. It was expendient. Backup everything before doing anything. | |
This doesn't do things in transactions so that you can do rollbacks on failures. | |
if it fails, you just have to nuke it from orbit and start over. | |
""" | |
def create_presentation_slots(schedule, args): | |
""" Creates a SlotRoom based on a csv file | |
Room, SlotKind, Day must exist | |
If a Slot does not exist it is created | |
""" | |
data = get_csv_data(args.csv) | |
for row in data: | |
date, start, end, kind_label, room_name, proposal_id = parse_presentation(row) | |
print row | |
room = Room.objects.get(schedule=schedule, name=room_name) | |
slotkind = SlotKind.objects.get(schedule=schedule, label=kind_label) | |
day = Day.objects.get(schedule=schedule, date=date) | |
slot, created = Slot.objects.get_or_create( | |
kind=slotkind, | |
day=day, | |
start=start, | |
end=end, | |
) | |
SlotRoom.objects.create(slot=slot, room=room) | |
def create_rooms(args): | |
data = get_csv_data(args.csv) | |
for row in data: | |
schedule = get_schedule(row['section_slug']) | |
Room.objects.create( | |
schedule = schedule, | |
name=row['name'], | |
order=row['order'], | |
) | |
def create_slot_kinds(args): | |
data = get_csv_data(args.csv) | |
for row in data: | |
schedule = get_schedule(row['section_slug']) | |
presentation = row['presentation_menu'] == 'TRUE' | |
SlotKind.objects.create( | |
schedule=schedule, | |
label=row['slot_kind'], | |
presentation=presentation | |
) | |
def parse_presentation(row): | |
""" parses row from presentation csv file | |
""" | |
# date,time_start,time_end,kind,room,proposal_id,description | |
date = datetime.strptime(row['date'], "%m/%d/%Y") | |
start = get_time(row['time_start']) | |
end = get_time(row['time_end']) | |
return date, start, end, row['kind'], row['room'], row.get('proposal_id', '') | |
def get_time(timestring): | |
time_obj = time.strptime(timestring, '%H:%M') | |
time_obj = datetime(100, 1, 1, time_obj.tm_hour, time_obj.tm_min, 00) | |
return time_obj.time() | |
def get_csv_data(csvfile): | |
reader = csv.DictReader(csvfile) | |
data = [dict((k.strip(), v.strip()) for k, v in x.items()) for x in reader] | |
return data | |
def get_schedule(section_slug): | |
""" get Schedule for section | |
""" | |
section = Section.objects.get(slug=section_slug) | |
return Schedule.objects.get(section=section) | |
def build_parser(): | |
parser = argparse.ArgumentParser(description=""" | |
""") | |
parser.add_argument('--modeltype', default='presentations') | |
parser.add_argument('--csv', type=file) | |
parser.add_argument('--section', default='talks-posters', help='section slug for the schedule') | |
return parser | |
if __name__ == '__main__': | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "scipy2014.settings") | |
from symposion.schedule.models import Day, Room, Schedule, Slot, SlotKind, SlotRoom | |
from symposion.conference.models import Section | |
parser = build_parser() | |
args = parser.parse_args() | |
if args.modeltype == 'presentations': | |
schedule = get_schedule(args.section) | |
create_presentation_slots(schedule, args) | |
elif args.modeltype == 'rooms': | |
create_rooms(args) | |
elif args.modeltype == 'slotkinds': | |
create_slot_kinds(args) | |
else: | |
print("invalid modeltype") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section_slug | slot_kind | presentation_menu | |
---|---|---|---|
talks-posters | Astronomy and Astrophysics Symposium | TRUE | |
talks-posters | Bioinformatics Symposium | TRUE | |
talks-posters | Break | FALSE | |
talks-posters | Breakfast | FALSE | |
talks-posters | Digital Social Sciences Symposium | TRUE | |
talks-posters | Engineering Symposium | TRUE | |
talks-posters | General | TRUE | |
talks-posters | Geophysics Symposium | TRUE | |
talks-posters | Geospatial Data in Science | TRUE | |
talks-posters | Imaging and Vision Symposium | TRUE | |
talks-posters | Job Fair | FALSE | |
talks-posters | Keynote | FALSE | |
talks-posters | Lightning Talks | FALSE | |
talks-posters | Lunch | FALSE | |
talks-posters | Posters | FALSE | |
talks-posters | Scientific Computing in Education | TRUE | |
talks-posters | Setup | FALSE | |
talks-posters | Welcome | FALSE | |
talks-posters | BOFs | FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date | time_start | time_end | kind | room | proposal_id | description | |
---|---|---|---|---|---|---|---|
7/8/2014 | 7:30 | 8:30 | Breakfast | Grand Ballroom | Sponsor Breakfast (Room 301) | ||
7/8/2014 | 7:30 | 8:30 | Breakfast | Room 203 | |||
7/8/2014 | 7:30 | 8:30 | Breakfast | Room 204 | |||
7/8/2014 | 8:30 | 9:00 | Break | Grand Ballroom | Morning Break (GB Hallway) | ||
7/8/2014 | 8:30 | 9:00 | Break | Room 203 | Morning Break (GB Hallway) | ||
7/8/2014 | 8:30 | 9:00 | Break | Room 204 | Morning Break (GB Hallway) | ||
7/8/2014 | 10:00 | 10:15 | Break | Grand Ballroom | Break (GB Hallway) | ||
7/8/2014 | 10:00 | 10:15 | Break | Room 203 | |||
7/8/2014 | 10:00 | 10:15 | Break | Room 204 | |||
7/8/2014 | 15:15 | 15:30 | Break | Grand Ballroom | Break (GB Hallway) | ||
7/8/2014 | 15:15 | 15:30 | Break | Room 203 | |||
7/8/2014 | 15:15 | 15:30 | Break | Room 204 | |||
7/8/2014 | 7:00 | 7:30 | Setup | Grand Ballroom | Set-up | ||
7/8/2014 | 7:00 | 7:30 | Setup | Room 203 | Set-up | ||
7/8/2014 | 7:00 | 7:30 | Setup | Room 204 | Set-up | ||
7/8/2014 | 9:00 | 9:15 | Welcome | Grand Ballroom | Welcome | ||
7/8/2014 | 9:00 | 9:15 | Welcome | Room 203 | Welcome | ||
7/8/2014 | 9:00 | 9:15 | Welcome | Room 204 | Welcome | ||
7/8/2014 | 9:15 | 10:00 | Keynote | Grand Ballroom | Keynote | ||
7/8/2014 | 9:15 | 10:00 | Keynote | Room 203 | Keynote | ||
7/8/2014 | 9:15 | 10:00 | Keynote | Room 204 | Keynote | ||
7/8/2014 | 12:15 | 1:30 | Lunch | Grand Ballroom | Lunch | ||
7/8/2014 | 12:15 | 1:30 | Lunch | Room 203 | |||
7/8/2014 | 12:15 | 1:30 | Lunch | Room 204 | |||
7/8/2014 | 15:00 | 15:15 | Setup | Grand Ballroom | Poster Set-Up (Ballroom) | ||
7/8/2014 | 15:00 | 15:15 | Setup | Room 203 | Poster Set-Up (Ballroom) | ||
7/8/2014 | 15:00 | 15:15 | Setup | Room 204 | Poster Set-Up (Ballroom) | ||
7/8/2014 | 16:30 | 19:00 | Lightning Talks | Grand Ballroom | Lightning Talks | ||
7/8/2014 | 16:30 | 19:00 | Lightning Talks | Room 203 | Lightning Talks | ||
7/8/2014 | 16:30 | 19:00 | Lightning Talks | Room 204 | Lightning Talks | ||
7/8/2014 | 19:00 | 21:00 | Job Fair | Grand Ballroom | |||
7/8/2014 | 19:00 | 21:00 | Job Fair | Room 203 | |||
7/8/2014 | 19:00 | 21:00 | Job Fair | Room 204 | |||
7/9/2014 | 7:00 | 8:00 | Setup | Grand Ballroom | Set-up | ||
7/9/2014 | 7:00 | 8:00 | Setup | Room 203 | Set-up | ||
7/9/2014 | 7:00 | 8:00 | Setup | Room 204 | Set-up | ||
7/9/2014 | 8:00 | 9:00 | Break | Grand Ballroom | Morning Break (GB Hallway) | ||
7/9/2014 | 8:00 | 9:00 | Break | Room 203 | Morning Break (GB Hallway) | ||
7/9/2014 | 8:00 | 9:00 | Break | Room 204 | Morning Break (GB Hallway) | ||
7/9/2014 | 9:00 | 9:15 | Welcome | Grand Ballroom | Welcome | ||
7/9/2014 | 9:00 | 9:15 | Welcome | Room 203 | Welcome | ||
7/9/2014 | 9:00 | 9:15 | Welcome | Room 204 | Welcome | ||
7/9/2014 | 9:15 | 10:00 | Keynote | Grand Ballroom | Keynote | ||
7/9/2014 | 9:15 | 10:00 | Keynote | Room 203 | Keynote | ||
7/9/2014 | 9:15 | 10:00 | Keynote | Room 204 | Keynote | ||
7/9/2014 | 10:00 | 10:15 | Break | Grand Ballroom | Break (GB Hallway) | ||
7/9/2014 | 10:00 | 10:15 | Break | Room 203 | |||
7/9/2014 | 10:00 | 10:15 | Break | Room 204 | |||
7/9/2014 | 12:15 | 13:30 | Lunch | Grand Ballroom | Lunch | ||
7/9/2014 | 12:15 | 13:30 | Lunch | Room 203 | Lunch | ||
7/9/2014 | 12:15 | 13:30 | Lunch | Room 204 | Lunch | ||
7/9/2014 | 14:30 | 15:30 | Posters | Grand Ballroom | |||
7/9/2014 | 14:30 | 15:30 | Posters | Room 203 | |||
7/9/2014 | 14:30 | 15:30 | Posters | Room 204 | |||
7/9/2014 | 14:30 | 15:30 | Break | Grand Ballroom | |||
7/9/2014 | 14:30 | 15:30 | Break | Room 203 | |||
7/9/2014 | 14:30 | 15:30 | Break | Room 204 | |||
7/9/2014 | 16:30 | 19:00 | Lightning Talks | Grand Ballroom | Lightning Talks | ||
7/9/2014 | 16:30 | 19:00 | Lightning Talks | Room 203 | Lightning Talks | ||
7/9/2014 | 16:30 | 19:00 | Lightning Talks | Room 204 | Lightning Talks | ||
7/10/2014 | 9:00 | 9:15 | Welcome | Grand Ballroom | Welcome | ||
7/10/2014 | 9:00 | 9:15 | Welcome | Room 203 | Welcome | ||
7/10/2014 | 9:00 | 9:15 | Welcome | Room 204 | Welcome | ||
7/10/2014 | 9:15 | 10:00 | Keynote | Grand Ballroom | Keynote | ||
7/10/2014 | 9:15 | 10:00 | Keynote | Room 203 | Keynote | ||
7/10/2014 | 9:15 | 10:00 | Keynote | Room 204 | Keynote | ||
7/10/2014 | 12:00 | 12:15 | Break | Grand Ballroom | |||
7/10/2014 | 12:00 | 12:15 | Break | Room 203 | |||
7/10/2014 | 12:00 | 12:15 | Break | Room 204 | |||
7/10/2014 | 12:15 | 13:30 | Lunch | Grand Ballroom | |||
7/10/2014 | 12:15 | 13:30 | Lunch | Room 203 | |||
7/10/2014 | 12:15 | 13:30 | Lunch | Room 204 | |||
7/10/2014 | 13:30 | 14:15 | BOFs | Grand Ballroom | |||
7/10/2014 | 13:30 | 14:15 | BOFs | Room 203 | |||
7/10/2014 | 13:30 | 14:15 | BOFs | Room 204 | |||
7/10/2014 | 15:00 | 15:30 | Break | Grand Ballroom | |||
7/10/2014 | 15:00 | 15:30 | Break | Room 203 | |||
7/10/2014 | 15:15 | 15:30 | Break | Room 203 | |||
7/10/2014 | 16:30 | 19:00 | Lightning Talks | Grand Ballroom | |||
7/10/2014 | 16:30 | 19:00 | Lightning Talks | Room 203 | |||
7/10/2014 | 16:30 | 19:00 | Lightning Talks | Room 204 | |||
7/8/2014 | 10:15 | 10:45 | Scientific Computing in Education | Grand Ballroom | 88 | ||
7/8/2014 | 10:15 | 10:45 | Geospatial Data in Science | Room 203 | 176 | ||
7/8/2014 | 10:15 | 10:45 | General | Room 204 | 128 | ||
7/8/2014 | 10:45 | 11:15 | Scientific Computing in Education | Grand Ballroom | 177 | ||
7/8/2014 | 10:45 | 11:15 | Geospatial Data in Science | Room 203 | 106 | ||
7/8/2014 | 10:45 | 11:15 | General | Room 204 | 130 | ||
7/8/2014 | 11:15 | 11:45 | Scientific Computing in Education | Grand Ballroom | 98 | ||
7/8/2014 | 11:15 | 11:45 | Geospatial Data in Science | Room 203 | 104 | ||
7/8/2014 | 11:15 | 11:45 | General | Room 204 | 14 | ||
7/8/2014 | 11:45 | 12:00 | Scientific Computing in Education | Grand Ballroom | 37 | ||
7/8/2014 | 11:45 | 12:00 | Geospatial Data in Science | Room 203 | 135 | ||
7/8/2014 | 11:45 | 12:00 | General | Room 204 | 33 | ||
7/8/2014 | 14:15 | 14:45 | Scientific Computing in Education | Grand Ballroom | 149 | ||
7/8/2014 | 14:15 | 14:45 | Geospatial Data in Science | Room 203 | 160 | ||
7/8/2014 | 14:15 | 14:45 | General | Room 204 | 110 | ||
7/8/2014 | 14:45 | 15:00 | Scientific Computing in Education | Grand Ballroom | 185 | ||
7/8/2014 | 14:45 | 15:00 | Geospatial Data in Science | Room 203 | 57 | ||
7/8/2014 | 14:45 | 15:00 | General | Room 204 | 116 | ||
7/8/2014 | 15:30 | 16:00 | Scientific Computing in Education | Grand Ballroom | 15 | ||
7/8/2014 | 15:30 | 16:00 | Geospatial Data in Science | Room 203 | 80 | ||
7/8/2014 | 15:30 | 16:00 | General | Room 204 | 7 | ||
7/8/2014 | 16:00 | 16:15 | Scientific Computing in Education | Grand Ballroom | 13 | ||
7/8/2014 | 16:00 | 16:15 | Geospatial Data in Science | Room 203 | 103 | ||
7/8/2014 | 16:00 | 16:30 | General | Room 204 | 153 | ||
7/9/2014 | 10:15 | 10:45 | Scientific Computing in Education | Grand Ballroom | 156 | ||
7/9/2014 | 10:15 | 10:45 | Geospatial Data in Science | Room 203 | 131 | ||
7/9/2014 | 10:15 | 10:45 | General | Room 204 | 141 | ||
7/9/2014 | 10:45 | 11:15 | Scientific Computing in Education | Grand Ballroom | 169 | ||
7/9/2014 | 10:45 | 11:15 | Geospatial Data in Science | Room 203 | 28 | ||
7/9/2014 | 10:45 | 11:15 | General | Room 204 | 67 | ||
7/9/2014 | 11:15 | 11:45 | Scientific Computing in Education | Grand Ballroom | 82 | ||
7/9/2014 | 11:15 | 11:45 | Geospatial Data in Science | Room 203 | 179 | ||
7/9/2014 | 11:15 | 11:45 | General | Room 204 | 38 | ||
7/9/2014 | 11:45 | 12:00 | Scientific Computing in Education | Grand Ballroom | 114 | ||
7/9/2014 | 11:45 | 12:00 | Geospatial Data in Science | Room 203 | 184 | ||
7/9/2014 | 11:45 | 12:00 | General | Room 204 | 108 | ||
7/10/2014 | 10:15 | 10:45 | Scientific Computing in Education | Grand Ballroom | |||
7/10/2014 | 10:15 | 10:45 | Geospatial Data in Science | Room 203 | |||
7/10/2014 | 10:15 | 10:45 | General | Room 204 | |||
7/10/2014 | 10:45 | 11:15 | Scientific Computing in Education | Grand Ballroom | |||
7/10/2014 | 10:45 | 11:15 | Geospatial Data in Science | Room 203 | |||
7/10/2014 | 10:45 | 11:15 | General | Room 204 | |||
7/10/2014 | 11:15 | 11:45 | Scientific Computing in Education | Grand Ballroom | |||
7/10/2014 | 11:15 | 11:45 | Geospatial Data in Science | Room 203 | |||
7/10/2014 | 11:15 | 11:45 | General | Room 204 | |||
7/10/2014 | 11:45 | 12:00 | Scientific Computing in Education | Grand Ballroom | |||
7/10/2014 | 11:45 | 12:00 | Geospatial Data in Science | Room 203 | |||
7/10/2014 | 11:45 | 12:00 | General | Room 204 | |||
7/9/2014 | 13:30 | 14:00 | Bioinformatics Symposium | Grand Ballroom | 175 | ||
7/9/2014 | 14:00 | 14:15 | Bioinformatics Symposium | Grand Ballroom | 24 | ||
7/9/2014 | 15:30 | 16:00 | Bioinformatics Symposium | Grand Ballroom | 94 | ||
7/9/2014 | 16:00 | 16:30 | Bioinformatics Symposium | Grand Ballroom | 36 | ||
7/9/2014 | 13:30 | 13:50 | Astronomy and Astrophysics Symposium | Room 203 | 101 | ||
7/9/2014 | 13:50 | 14:10 | Astronomy and Astrophysics Symposium | Room 203 | 26 | ||
7/9/2014 | 14:10 | 14:30 | Astronomy and Astrophysics Symposium | Room 203 | 66 | ||
7/9/2014 | 15:30 | 15:50 | Astronomy and Astrophysics Symposium | Room 203 | 39 | ||
7/9/2014 | 15:50 | 16:10 | Astronomy and Astrophysics Symposium | Room 203 | 81 | ||
7/9/2014 | 16:10 | 16:30 | Astronomy and Astrophysics Symposium | Room 203 | 161 | ||
7/9/2014 | 13:30 | 14:00 | Geophysics Symposium | Room 204 | 86 | ||
7/9/2014 | 14:00 | 14:30 | Geophysics Symposium | Room 204 | 122 | ||
7/9/2014 | 15:30 | 16:00 | Geophysics Symposium | Room 204 | 60 | ||
7/9/2014 | 16:00 | 16:30 | Geophysics Symposium | Room 204 | 27 | ||
7/10/2014 | 14:15 | 14:30 | Imaging and Vision Symposium | Room 204 | 85 | ||
7/10/2014 | 14:30 | 14:45 | Imaging and Vision Symposium | Room 204 | 183 | ||
7/10/2014 | 14:45 | 15:00 | Imaging and Vision Symposium | Room 204 | 84 | ||
7/10/2014 | 15:00 | 15:15 | Imaging and Vision Symposium | Room 204 | 50 | ||
7/10/2014 | 15:30 | 15:45 | Imaging and Vision Symposium | Room 204 | 166 | ||
7/10/2014 | 15:45 | 16:00 | Imaging and Vision Symposium | Room 204 | 45 | ||
7/10/2014 | 16:00 | 16:15 | Imaging and Vision Symposium | Room 204 | 46 | ||
7/10/2014 | 14:15 | 14:45 | Engineering Symposium | Grand Ballroom | 11 | ||
7/10/2014 | 14:45 | 15:00 | Engineering Symposium | Grand Ballroom | 42 | ||
7/10/2014 | 15:30 | 16:00 | Engineering Symposium | Grand Ballroom | 74 | ||
7/10/2014 | 16:00 | 16:30 | Engineering Symposium | Grand Ballroom | 157 | ||
7/10/2014 | 14:15 | 14:45 | Digital Social Sciences Symposium | Room 203 | 189 | ||
7/10/2014 | 14:45 | 15:00 | Digital Social Sciences Symposium | Room 203 | 182 | ||
7/10/2014 | 15:30 | 16:00 | Digital Social Sciences Symposium | Room 203 | 145 | ||
7/10/2014 | 16:00 | 16:30 | Digital Social Sciences Symposium | Room 203 | 190 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment