def show_view(show): s = Show.query.get(show) if s is None: return 'no show found' # TODO: proper error page if request.args.get('inline'): template = '/shows/show-inline.html' else: template = '/shows/show.html' link_users = [] users = [] for ushow in s.users: link_users.append(make_user_link(ushow.user)) users.append(ushow.user) return render_template(template, show={'name': s.name, 'description': s.description, 'series': s.series, 'users': natural_join(link_users), 'tags': s.tags, 'begin': s.begin, 'end': s.end, 'logo': s.get_logo(), 'user': users, 'show': s.show, 'duration': (s.end - s.begin).total_seconds(), 'link': url_for('.show_view', show=s.show), 'fulfilled': s.is_fulfilled()})
def show_view(show): s = Show.query.get(show) if s is None: return "no show found" if request.args.get("inline"): template = "/shows/show-inline.html" else: template = "/shows/show.html" link_users = [] users = [] for ushow in s.users: link_users.append(make_user_link(ushow.user)) users.append(ushow.user) return render_template( template, show={ "name": s.name, "description": s.description, "series": s.series, "users": natural_join(link_users), "tags": s.tags, "begin": s.begin, "logo": s.get_logo(), "user": users, "show": s.show, "duration": (s.end - s.begin).total_seconds(), "link": url_for(".show_view", show=s.show), }, )
def now_playing(): try: ret = {} #gather showinfos show = Show.get_active_show() if show: user = show.get_active_user() if show.end: end = to_timestamp(to_user_timezone(show.end)) else: end = None ret['show'] = {'id': show.show, 'name': show.name, 'begin': to_timestamp(to_user_timezone(show.begin)), 'now': to_timestamp(to_user_timezone(now())), 'end': end, 'logo': show.get_logo(), 'type': Show.FLAGS.name(show.flags), 'user': {'countryball': iso_country_to_countryball(user.country)} } if show.series: ret['series'] = {'name': show.series.name} link_users = [] for ushow in show.users: link_users.append(make_user_link(ushow.user)) ret['users'] = {'links': natural_join(link_users)} #gather trackinfos track = Track.current_track() if track: ret['track'] = {'title': track.title.name, 'artist': track.title.artist.name, } #gather nextshow infos if show and show.end: filter_begin = show.end else: filter_begin = now() if request.args.get('full') == 'true': nextshow = Show.query.filter(Show.begin >= filter_begin).order_by(Show.begin.asc()).first(); if nextshow: ret['nextshow'] = {'name': nextshow.name, 'begin': to_timestamp(to_user_timezone(nextshow.begin)), 'logo': nextshow.get_logo()} if nextshow.series: ret['nextshow']['series'] = nextshow.series.name #get listenerinfo for disco listeners = Listener.get_current_listeners() ret['listener'] = {} for listener in listeners: ret['listener'][listener.listener] = {'listener': listener.listener, 'county': listener.country, 'countryball': iso_country_to_countryball(listener.country)} return jsonify({'success': True, 'data': ret}) except Exception as e: raise e return jsonify({'success': False, 'data': unicode(e)})
def now_playing(): try: ret = {} #gather showinfos show = Show.get_active_show() if show: user = show.get_active_user() if show.end: end = int(to_user_timezone(show.end).strftime("%s")) * 1000 else: end = None ret['show'] = { 'id': show.show, 'name': show.name, 'begin': int(to_user_timezone(show.begin).strftime("%s")) * 1000, 'now': int(to_user_timezone(now()).strftime("%s")) * 1000, 'end': end, 'logo': show.get_logo(), 'type': Show.FLAGS.name(show.flags), 'user': { 'countryball': iso_country_to_countryball(user.country) } } if show.series: ret['series'] = {'name': show.series.name} link_users = [] for ushow in show.users: link_users.append(make_user_link(ushow.user)) ret['users'] = {'links': natural_join(link_users)} #gather nextshow infos if show and show.end: filter_begin = show.end else: filter_begin = now() if request.args.get('full') == 'true': nextshow = Show.query.filter(Show.begin >= filter_begin).order_by( Show.begin.asc()).first() if nextshow: ret['nextshow'] = { 'name': nextshow.name, 'begin': int(to_user_timezone(nextshow.begin).strftime("%s")) * 1000, 'logo': nextshow.get_logo() } if nextshow.series: ret['nextshow']['series'] = nextshow.series.name return jsonify({'success': True, 'data': ret}) except Exception as e: raise e return jsonify({'success': False, 'data': unicode(e)})
def now_playing(): try: ret = {} #gather showinfos show = Show.get_active_show() if show: user = show.get_active_user() if show.end: end = int(to_user_timezone(show.end).strftime("%s")) * 1000 else: end = None ret['show'] = {'id': show.show, 'name': show.name, 'begin': int(to_user_timezone(show.begin).strftime("%s")) * 1000, 'now': int(to_user_timezone(now()).strftime("%s")) * 1000, 'end': end, 'logo': show.get_logo(), 'type': Show.FLAGS.name(show.flags), 'user': {'countryball': iso_country_to_countryball(user.country)} } if show.series: ret['series'] = {'name': show.series.name} link_users = [] for ushow in show.users: link_users.append(make_user_link(ushow.user)) ret['users'] = {'links': natural_join(link_users)} #gather nextshow infos if show and show.end: filter_begin = show.end else: filter_begin = now() if request.args.get('full') == 'true': nextshow = Show.query.filter(Show.begin >= filter_begin).order_by(Show.begin.asc()).first(); if nextshow: ret['nextshow'] = {'name': nextshow.name, 'begin': int(to_user_timezone(nextshow.begin).strftime("%s")) * 1000, 'logo': nextshow.get_logo()} if nextshow.series: ret['nextshow']['series'] = nextshow.series.name return jsonify({'success': True, 'data': ret}) except Exception as e: raise e return jsonify({'success': False, 'data': unicode(e)})