Ejemplo n.º 1
0
def general_listing(request, isAlumniFilter, isPledgeFilter, name):
    '''
    Retrieves all of the information necessary for each of the brother listings.
    Retrieves information based on the isAlumniFilter and isPledgeFilter
    '''
    brothers_count = PageHelper.get_request_count(request, standard_brothers_per_page, max_brothers_per_page)
    page_number = PageHelper.get_page_number(request)
    brothers_range_min = (page_number - 1) * brothers_count
    brothers_range_max = (page_number) * brothers_count
    brothers = Brother.objects.filter(isAlumni=isAlumniFilter, isPledge=isPledgeFilter).order_by(
        'lastName', 'firstName', 'middleName')
    number_of_brothers = len(brothers)
    total_pages = int(math.ceil(number_of_brothers / float(brothers_count)))
    brothers = brothers[brothers_range_min:brothers_range_max]
    brothers = convert_brothers_to_brotherentities(brothers)
    brother_list_list = utility.convert_array_to_YxZ(brothers, brothers_per_row) if len(brothers) > 0 else None
    page_numbers_list = PageHelper.calculate_page_range(total_pages, page_number, max_pages_listed_on_screen)
    next_page = page_number + 1 if number_of_brothers > brothers_range_max else 0
    prev_page = page_number - 1
    context_dict = {
                    'brotherType': name, 
                    'brother_list_list' : brother_list_list, 
                    'page_number' : page_number, 
                    'prev_page': prev_page, 
                    'next_page' : next_page, 
                    'page_numbers' : page_numbers_list
                    }
    if brothers_count != standard_brothers_per_page:
        context_dict['brothers_count'] = brothers_count
    c = Context(context_dict)
    t = loader.get_template('brothers_list.html')
    return HttpResponse(t.render(c))
Ejemplo n.º 2
0
def general_listing(request, eventType, category):
    t = loader.get_template('article_list.html')
    category_query = Q()
    if category != None:
        category_query = Q(category__name=category)
    article_list = Article.objects.filter(category_query).order_by('date').reverse()
    article_count = PageHelper.get_request_count(request, default_count_per_page, max_count_per_page)
    page_number = PageHelper.get_page_number(request)
    articles_range_min = (page_number - 1) * article_count
    articles_range_max = (page_number) * article_count    
    number_of_articles = len(article_list)
    total_pages = int(math.ceil(number_of_articles / float(article_count)))
    article_list = article_list[articles_range_min:articles_range_max]
    page_numbers_list = PageHelper.calculate_page_range(total_pages, page_number, max_pages_listed_on_screen)    
    next_page = page_number + 1 if number_of_articles > articles_range_max else 0
    prev_page = page_number - 1
    context_dict = {
                    'eventType': eventType,
                    'article_list' : article_list,
                    'article_count': article_count, 
                    'page_number' : page_number, 
                    'prev_page': prev_page, 
                    'next_page' : next_page, 
                    'page_numbers' : page_numbers_list
                    }
    c = Context(context_dict)
    return HttpResponse(t.render(c))