Exemplo n.º 1
0
def venues(request, *args, **kwargs):
    current_venue_type = int(request.GET.get("venue_type", 0))
    if not current_venue_type \
            and 'extra_params' in kwargs \
                and 'venue_type' in kwargs['extra_params']:
        try:
            venue_type = VenueType.active_types.get(name=kwargs['extra_params']['venue_type'])
        except VenueType.DoesNotExist:
            pass
        else:
            current_venue_type = venue_type.id

    featured_events = featured_events_for_region(request)

    venue_types = VenueType.active_types.all()

    location_from_user_choice = location_service.LocationFromUserChoice(request)
    venue_accounts = VenueAccount.public_venues.filter_by_location(location_from_user_choice.location_type,
                                                                   location_from_user_choice.location_id)

    if current_venue_type:
        venue_accounts = venue_accounts.filter(types__id=int(current_venue_type))

    venue_accounts = venue_accounts.order_by('venue__name')

    return render_to_response('venues/index.html', {
        'featured_events': featured_events,
        'venue_accounts': venue_accounts,
        'venue_types': venue_types,
        'current_venue_type': current_venue_type
    }, context_instance=RequestContext(request))
Exemplo n.º 2
0
def venues(request, *args, **kwargs):
    current_venue_type = int(request.GET.get("venue_type", 0))
    if not current_venue_type \
            and 'extra_params' in kwargs \
                and 'venue_type' in kwargs['extra_params']:
        try:
            venue_type = VenueType.active_types.get(
                name=kwargs['extra_params']['venue_type'])
        except VenueType.DoesNotExist:
            pass
        else:
            current_venue_type = venue_type.id

    featured_events = featured_events_for_region(request)

    venue_types = VenueType.active_types.all()

    location_from_user_choice = location_service.LocationFromUserChoice(
        request)
    venue_accounts = VenueAccount.public_venues.filter_by_location(
        location_from_user_choice.location_type,
        location_from_user_choice.location_id)

    if current_venue_type:
        venue_accounts = venue_accounts.filter(
            types__id=int(current_venue_type))

    venue_accounts = venue_accounts.order_by('venue__name')

    return render_to_response('venues/index.html', {
        'featured_events': featured_events,
        'venue_accounts': venue_accounts,
        'venue_types': venue_types,
        'current_venue_type': current_venue_type
    },
                              context_instance=RequestContext(request))
Exemplo n.º 3
0
def browse(request, *args, **kwargs):
    search_params = ["search", "tag", "period", "start_date", "end_date", "start_time", "end_time", "function"]
    start_date, end_date = utils.get_dates_from_request(request)
    start_time, end_time = utils.get_times_from_request(request)

    featured_events = featured_service.featured_events_for_region(request)

    params = request.GET.copy()
    if 'extra_params' in kwargs:
        params.update(kwargs['extra_params'])

    if 'function' in params and params['function'] in FunctionFilter.SPLIT_FUNCTIONS:
        events = SingleEvent.future_events.all()
    else:
        events = SingleEvent.homepage_events.all()

    
    location_from_user_choice = location_service.LocationFromUserChoice(request)
    if not "location" in params:
        params["location"] = "%s|%s" % (
            location_from_user_choice.location_type,
            location_from_user_choice.location_id,
        )

    tag_page = kwargs['extra_params']['tag'] if 'extra_params' in kwargs and 'tag' in kwargs['extra_params'] else ''
    eventsFilter = EventFilter(params, queryset=events, account=request.account, tag_page=tag_page)

    if 'search' in params:
        tags = TaggedItem.objects.filter(object_id__in=map(lambda event: event.event.id, eventsFilter.qs())) \
            .values('tag_id', 'tag__name') \
            .annotate(count=Count('id'))
    else:
        tags = TaggedItem.objects.filter(object_id__in=eventsFilter.qs().values_list("event_id", flat=True)) \
            .values('tag_id', 'tag__name') \
            .annotate(count=Count('id'))

    if 'sort' in params and params['sort'] == 'abc':
        tags = tags.order_by('tag__name')
    else:
        tags = tags.order_by('-count')

    try:
        page_info = Page.objects.get(alias='home')
    except Page.DoesNotExist:
        page_info = {}

    return render_to_response('events/browse_events.html', {
                                'page_type': 'index',
                                'location_name': location_from_user_choice.location_name,
                                'featured_events': featured_events,
                                'events': events,
                                'eventsFilter': eventsFilter,
                                'tags': tags,
                                'start_date': start_date,
                                'end_date': end_date,
                                'start_time': start_time,
                                'end_time': end_time,
                                'period': params.get('period', ''),
                                'tag_page': kwargs['extra_params']['tag'] if 'extra_params' in kwargs
                                and 'tag' in kwargs['extra_params'] else '',
                                'page_info': page_info
                            }, context_instance=RequestContext(request))
Exemplo n.º 4
0
def browse(request, *args, **kwargs):
    search_params = [
        "search", "tag", "period", "start_date", "end_date", "start_time",
        "end_time", "function"
    ]
    start_date, end_date = utils.get_dates_from_request(request)
    start_time, end_time = utils.get_times_from_request(request)

    featured_events = featured_service.featured_events_for_region(request)

    params = request.GET.copy()
    if 'extra_params' in kwargs:
        params.update(kwargs['extra_params'])

    if 'function' in params and params[
            'function'] in FunctionFilter.SPLIT_FUNCTIONS:
        events = SingleEvent.future_events.all()
    else:
        events = SingleEvent.homepage_events.all()

    location_from_user_choice = location_service.LocationFromUserChoice(
        request)
    if not "location" in params:
        params["location"] = "%s|%s" % (
            location_from_user_choice.location_type,
            location_from_user_choice.location_id,
        )

    tag_page = kwargs['extra_params'][
        'tag'] if 'extra_params' in kwargs and 'tag' in kwargs[
            'extra_params'] else ''
    eventsFilter = EventFilter(params,
                               queryset=events,
                               account=request.account,
                               tag_page=tag_page)

    if 'search' in params:
        tags = TaggedItem.objects.filter(object_id__in=map(lambda event: event.event.id, eventsFilter.qs())) \
            .values('tag_id', 'tag__name') \
            .annotate(count=Count('id'))
    else:
        tags = TaggedItem.objects.filter(object_id__in=eventsFilter.qs().values_list("event_id", flat=True)) \
            .values('tag_id', 'tag__name') \
            .annotate(count=Count('id'))

    if 'sort' in params and params['sort'] == 'abc':
        tags = tags.order_by('tag__name')
    else:
        tags = tags.order_by('-count')

    try:
        page_info = Page.objects.get(alias='home')
    except Page.DoesNotExist:
        page_info = {}

    return render_to_response('events/browse_events.html', {
        'page_type':
        'index',
        'location_name':
        location_from_user_choice.location_name,
        'featured_events':
        featured_events,
        'events':
        events,
        'eventsFilter':
        eventsFilter,
        'tags':
        tags,
        'start_date':
        start_date,
        'end_date':
        end_date,
        'start_time':
        start_time,
        'end_time':
        end_time,
        'period':
        params.get('period', ''),
        'tag_page':
        kwargs['extra_params']['tag'] if 'extra_params' in kwargs
        and 'tag' in kwargs['extra_params'] else '',
        'page_info':
        page_info
    },
                              context_instance=RequestContext(request))