def about(): """ About page. """ content, meta = get_markdown_file('about', g.lang_code) team = get_data_file('team.json') sponsors = get_data_file('sponsors.yml') content, meta = get_markdown_file('about', g.lang_code) return render_template('pages/about.html', content=content, meta=meta, team=team, sponsors=sponsors)
def about(): """ About page. """ content, meta = get_markdown_file('about', g.lang_code) team = get_data_file('team.json') sponsors = get_data_file('sponsors.yml') content, meta = get_markdown_file('about', g.lang_code) return render_template('pages/about.html', content=content, meta=meta, team=team, sponsors=sponsors)
def index(): """ Landing page. """ sponsors = get_data_file('sponsors.yml') return render_template('pages/index.html', sponsors=sponsors)
def index(): """ Schedule index page. """ schedule = get_data_file('schedule.json') return render_template('pages/schedule/index.html', schedule=schedule)
def guide(): """ Guide to things around the venue area page. """ guide = get_data_file('guide.json') return render_template('pages/guide.html', guide=guide)
def index(): """ Landing page. """ sponsors = get_data_file('sponsors.yml') return render_template('pages/index.html', sponsors=sponsors)
def talk_ics(slug): cal = Calendar() cal.add('prodid', '-//PyCon Canada 2016//2016.pycon.ca') cal.add('version', '2.0') if slug == 'schedule': schedule = get_data_file('schedule.json') # TODO: This should be refactored. for day in schedule.get('days'): for slot in day.get('entries'): if slot.get('talks'): for room, talk in slot.get('talks').iteritems(): if talk: cal.add_component(event_ics(talk)) else: cal.add_component(event_ics(slug)) headers = { 'Content-Disposition': 'attachment;filename={0}.ics'.format(slug) } return Response(response=cal.to_ical(), status=200, mimetype='text/calendar', headers=headers)
def guide(): """ Guide to things around the venue area page. """ guide = get_data_file('guide.json') return render_template('pages/guide.html', guide=guide)
def sponsors(): """ Sponsors page. """ data = get_data_file('sponsors.yml') content, meta = get_markdown_file('sponsors', g.lang_code) return render_template('pages/sponsors.html', content=content, meta=meta, sponsors=data)
def talk_json(slug): if slug == 'schedule': content = get_data_file('schedule.json') else: description, content = get_markdown_file('talks/{}'.format(slug), 'en') content['description'] = description return jsonify(content)
def test_sponsors_yml_file(self): with self.app.app_context(): sponsors = get_data_file('sponsors.yml') for level in sponsors: self.assertTrue(level['level']['en']) for sponsor in level['entries']: self.assertTrue(sponsor['logo'])
def test_data_files(self): data_files = [] data_files += glob.glob(os.path.join(self.app.config['APP_PATH'], 'data', '*.json')) data_files += glob.glob(os.path.join(self.app.config['APP_PATH'], 'data', '*.yml')) for data_file in data_files: with self.app.app_context(): self.assertTrue(get_data_file(os.path.basename(data_file)))
def test_sponsors_yml_file(self): with self.app.app_context(): sponsors = get_data_file('sponsors.yml') for level in sponsors: self.assertTrue(level['level']['en']) for sponsor in level['entries']: self.assertTrue(sponsor['logo']) self.assertEqual(sponsor['en'].keys(), ['url', 'twitter', 'name', 'description'])
def sponsors(): """ Sponsors page. """ data = get_data_file('sponsors.yml') content, meta = get_markdown_file('sponsors', g.lang_code) return render_template('pages/sponsors.html', content=content, meta=meta, sponsors=data)
def talk_json(slug): if slug == 'schedule': content = get_data_file('schedule.json') else: description, content = get_markdown_file('talks/{}'.format(slug), 'en') # The Markdown Meta extension gives us everything in lists. # So this is a simple converter. for k, v in content.items(): content[k] = v[0] content['description'] = description return jsonify(content)
def talk_ics(slug): cal = Calendar() cal.add('prodid', '-//PyCon Canada 2016//2016.pycon.ca') cal.add('version', '2.0') if slug == 'schedule': schedule = get_data_file('schedule.json') # TODO: This should be refactored because it's really ugly. for day in schedule.get('days'): for slot in day.get('entries'): if slot.get('link'): cal.add_component(event_ics(slot.get('link'))) elif slot.get('talks'): for room, talk in slot.get('talks').iteritems(): if talk: cal.add_component(event_ics(talk)) else: start_time_str = '{0} {1}'.format(day['date'], slot['start_time']) start_time = datetime.strptime(start_time_str, '%Y-%m-%d %H:%M:%S') end_time_str = '{0} {1}'.format(day['date'], slot['end_time']) end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S') event = Event() event.add('summary', slot['title']) event.add('dtstart', tz.localize(start_time)) event.add('dtend', tz.localize(end_time)) event.add('dtstamp', tz.localize(start_time)) cal.add_component(event) else: cal.add_component(event_ics(slug)) headers = { 'Content-Disposition': 'attachment;filename={0}.ics'.format(slug) } return Response(response=cal.to_ical(), status=200, mimetype='text/calendar', headers=headers)
def schedule_json(): schedule = get_data_file('schedule.json') return jsonify(schedule)
def schedule(): schedule = get_data_file('schedule.json') return jsonify(schedule)