def search_pad(request): 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) params = request.GET.copy() if set(search_params) & set(params.keys()): events = SingleEvent.future_events.all() else: events = SingleEvent.homepage_events.all() events_all_count = events.count() 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, ) eventsFilter = EventFilter(params, queryset=events, account=request.account) if "search" in params: top10_tags = TaggedItem.objects.filter(object_id__in=map(lambda event: event.event.id, eventsFilter.qs())) \ .values('tag_id', 'tag__name') \ .annotate(count=Count('id')) \ .order_by('-count')[:10] else: top10_tags = TaggedItem.objects.filter(object_id__in=eventsFilter.qs().values_list("event_id", flat=True)) \ .values('tag_id', 'tag__name') \ .annotate(count=Count('id')) \ .order_by('-count')[:10] return render_to_response('events/search_pad.html', { 'events': events, 'location_name': location_from_user_choice.location_name, 'eventsFilter': eventsFilter, 'top10_tags': top10_tags, 'events_all_count': events_all_count, 'start_date': start_date, 'end_date': end_date, 'start_time': start_time, 'end_time': end_time }, context_instance=RequestContext(request))
def browse(request): start_date, end_date = utils.get_dates_from_request(request) start_time, end_time = utils.get_times_from_request(request) region = location_service.LocationForFeaturedEvent(request).canadian_region featured_event_query = Q(featuredevent__all_of_canada=True) if region: featured_event_query = featured_event_query | Q(featuredevent__regions__id=region.id) featured_events = Event.featured_events\ .filter(featured_event_query)\ .order_by('?')\ .annotate(Count("id")) events = SingleEvent.future_events.all() params = request.GET.copy() 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, ) eventsFilter = EventFilter(params, queryset=events) #.filter(object_id__in=map(lambda event: event.event.id, eventsFilter.qs())) \ 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')) \ .order_by('-count') 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')) \ .order_by('-count') return render_to_response('events/browse_events.html', { '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 }, context_instance=RequestContext(request))
def search_pad(request): 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) params = request.GET.copy() if set(search_params) & set(params.keys()): events = SingleEvent.future_events.all() else: events = SingleEvent.homepage_events.all() events_all_count = events.count() 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, ) eventsFilter = EventFilter(params, queryset=events, account=request.account) if "search" in params: top10_tags = TaggedItem.objects.filter(object_id__in=map(lambda event: event.event.id, eventsFilter.qs())) \ .values('tag_id', 'tag__name') \ .annotate(count=Count('id')) \ .order_by('-count')[:10] else: top10_tags = TaggedItem.objects.filter(object_id__in=eventsFilter.qs().values_list("event_id", flat=True)) \ .values('tag_id', 'tag__name') \ .annotate(count=Count('id')) \ .order_by('-count')[:10] return render_to_response('events/search_pad.html', { 'events': events, 'location_name': location_from_user_choice.location_name, 'eventsFilter': eventsFilter, 'top10_tags': top10_tags, 'events_all_count': events_all_count, 'start_date': start_date, 'end_date': end_date, 'start_time': start_time, 'end_time': end_time }, context_instance=RequestContext(request))
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))
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))