<commit_before>import math

from django.http import HttpResponse
from django.template import Context, loader

from info.models import Brother, Officer
from info import utility

max_brothers_per_page = 24
standard_brothers_per_page = 9
brothers_per_row = 3
max_pages_listed_on_screen = 5

# Create your views here.
def index(request):
    t = loader.get_template('brothers_list.html')
    brothers = Brother.objects.all()
    if len(brothers) > 0:
        brother_list_list = utility.convert_array_to_YxZ(brothers, brothers_per_row)
    else:
        brother_list_list = None
    c = Context({'brotherType': 'All Brothers', 'brother_list_list' : brother_list_list})
    return HttpResponse(t.render(c))


def officers(request):
    officers = Officer.objects.filter().order_by('ordering')
    officers_matrix = utility.convert_array_to_YxZ(officers, 2)
    c = Context({'officer_list_list': officers_matrix})
    t = loader.get_template('officers_list.html')
    return HttpResponse(t.render(c))

def actives(request):
    return general_listing(request, False, False, 'Active Members')

def pledges(request):
    return general_listing(request, False, True, 'Pledges')

def alumni(request):
    return general_listing(request, True, False, 'Alumni')

def general_listing(request, isAlumniFilter, isPledgeFilter, name):
    brothers_count = get_brother_count(request)
    page_number = 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]
    brother_list_list = utility.convert_array_to_YxZ(brothers, brothers_per_row) if len(brothers) > 0 else None
    page_numbers_list = calculate_page_range(total_pages, page_number)
    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}<commit_msg>Defined why '2' is used<commit_after>import math

from django.http import HttpResponse
from django.template import Context, loader

from info.models import Brother, Officer
from info import utility

max_brothers_per_page = 24
standard_brothers_per_page = 9
brothers_per_row = 3
max_pages_listed_on_screen = 5
officers_per_row = 2

# Create your views here.
def index(request):
    t = loader.get_template('brothers_list.html')
    brothers = Brother.objects.all()
    if len(brothers) > 0:
        brother_list_list = utility.convert_array_to_YxZ(brothers, brothers_per_row)
    else:
        brother_list_list = None
    c = Context({'brotherType': 'All Brothers', 'brother_list_list' : brother_list_list})
    return HttpResponse(t.render(c))


def officers(request):
    officers = Officer.objects.filter().order_by('ordering')
    officers_matrix = utility.convert_array_to_YxZ(officers, officers_per_row)
    c = Context({'officer_list_list': officers_matrix})
    t = loader.get_template('officers_list.html')
    return HttpResponse(t.render(c))

def actives(request):
    return general_listing(request, False, False, 'Active Members')

def pledges(request):
    return general_listing(request, False, True, 'Pledges')

def alumni(request):
    return general_listing(request, True, False, 'Alumni')

def general_listing(request, isAlumniFilter, isPledgeFilter, name):
    brothers_count = get_brother_count(request)
    page_number = 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]
    brother_list_list = utility.convert_array_to_YxZ(brothers, brothers_per_row) if len(brothers) > 0 else None
    page_numbers_list = calculate_page_range(total_pages, page_number)
    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}
{'fraction_non_alphanumeric': 0.09607263513513513, 'fraction_numerical': 0.005278716216216216, 'mean_word_length': 5.6344537815126055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2521777', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1519, 'n_words': 313}