Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
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))
Ejemplo n.º 3
0
def detail_committee_view(request, slug):
    context = {}

    committee = get_object_or_404(Committee, slug=slug)
    context["committee"] = committee

    categories = EventCategory.objects.all()
    event_posts = EventPost.objects.filter(author=committee.author)
    myFilter = EventFilter(request.GET, queryset=event_posts)
    events = myFilter.qs

    # Pagination
    page = request.GET.get("page", 1)
    event_posts_paginator = Paginator(event_posts, POST_PER_PAGE)

    try:
        event_posts = event_posts_paginator.page(page)
    except PageNotAnInteger:
        event_posts = event_posts_paginator.page(POST_PER_PAGE)
    except EmptyPage:
        event_posts = event_posts_paginator.page(
            event_posts_paginator.num_pages)

    context['event_posts'] = event_posts
    context['categories'] = categories

    return render(request, "committee/detail_committee.html", context)
Ejemplo n.º 4
0
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))
Ejemplo n.º 5
0
def filter_events(request):

    events = Event.objects.all()
    event_filter = EventFilter(request.GET, queryset=events)
    events = event_filter.qs

    params = {
        'filter': event_filter,
        'events': events,
    }
    return render(request, 'events/filter.html', params)
Ejemplo n.º 6
0
def index(request):
	s = request.session.get('eventusers_id', None)
	data = {}
	list_item = Event.objects.all()
	data['list_item'] = list_item
	user = EventUsers.objects.filter(id=s)
	data['user']=user
	#filter
	event_filter = EventFilter(request.GET, queryset=list_item)
	data['filter']=event_filter
	return render(request,'front/index.html', data)
Ejemplo n.º 7
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))
Ejemplo n.º 8
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))