Exemplo n.º 1
0
def city_slug_handler(request, city_slug=None):
    if city_slug == None:
        city_slug = request.COOKIES.get('city_slug', 'new-york')
        return HttpResponseRedirect("/%s/" % city_slug)

    vars = {}
    try:
        city = City.objects.get(slug=city_slug)
    except City.DoesNotExist:
        raise Http404
    vars['city'] = city

    events = event_service.get_music_events(city, 0, MUSIC_EVENTS_SIZE)
    vars["events"] = events
    vars['cities'] = City.objects.filter(
        Q(country=const.LFM_COUNTRY_ID_USA)
        | Q(id=const.LFM_LONDON_CID)).order_by('name')

    vids = [o['venue_id'] for o in events.values('venue_id')]
    vars['venues'] = Venue.objects.filter(city=city,
                                          id__in=vids).order_by('name')
    vars['MUSIC_EVENTS_SIZE'] = MUSIC_EVENTS_SIZE

    resp = base.render(request, "music_events.html", vars)
    resp.set_cookie('city_slug', city_slug, max_age=315569260)

    return resp
Exemplo n.º 2
0
def find_events(request):
    vars = {}
    vid = request.GET.get('vid', None)
    cid = request.GET['cid']
    artist = request.GET.get('txt', None)
    if artist == 'Artist Search': artist = None
    if vid == '0': vid = None

    start = request.GET.get('start', None)
    end = int(request.GET.get('end', MUSIC_EVENTS_SIZE))
    if start == None: start = end - MUSIC_EVENTS_SIZE

    city = City.objects.get(id=cid)
    vars['city'] = city
    events = event_service.get_music_events(city, start, end, vid, artist)
    vars['events'] = events

    return render_to_response("ajax/find_events.html", vars)
Exemplo n.º 3
0
def find_events(request):
    vars = {}
    vid = request.GET.get("vid", None)
    cid = request.GET["cid"]
    artist = request.GET.get("txt", None)
    if artist == "Artist Search":
        artist = None
    if vid == "0":
        vid = None

    start = request.GET.get("start", None)
    end = int(request.GET.get("end", MUSIC_EVENTS_SIZE))
    if start == None:
        start = end - MUSIC_EVENTS_SIZE

    city = City.objects.get(id=cid)
    vars["city"] = city
    events = event_service.get_music_events(city, start, end, vid, artist)
    vars["events"] = events

    return render_to_response("ajax/find_events.html", vars)
Exemplo n.º 4
0
def city_slug_handler(request, city_slug=None):
    if city_slug == None:
        city_slug = request.COOKIES.get('city_slug', 'new-york')
        return HttpResponseRedirect("/%s/" % city_slug)
    
    vars = {}
    try:
        city = City.objects.get(slug=city_slug)
    except City.DoesNotExist: raise Http404
    vars['city'] = city
    
    events = event_service.get_music_events(city, 0, MUSIC_EVENTS_SIZE)
    vars["events"] =  events
    vars['cities'] = City.objects.filter(Q(country=const.LFM_COUNTRY_ID_USA) | Q(id=const.LFM_LONDON_CID)).order_by('name')
    
    vids = [o['venue_id'] for o in events.values('venue_id')]
    vars['venues'] = Venue.objects.filter(city=city, id__in=vids).order_by('name')
    vars['MUSIC_EVENTS_SIZE'] = MUSIC_EVENTS_SIZE
    
    resp =  base.render(request, "music_events.html", vars)
    resp.set_cookie('city_slug', city_slug, max_age=315569260)
    
    return resp