<commit_before>from django.db.models import Q
from django.shortcuts import render_to_response
from django.template import RequestContext
from datetime import datetime, date, timedelta

from animals.models import Animal
from animals.forms import AnimalSearchForm


def index(request, template_name='animals/index.html'):
    context = {}
    alist = Animal.objects.all()
    startdate = datetime.today() - timedelta(days=14)
    enddate = datetime.today()

    if request.method == 'POST':
        form = AnimalSearchForm(request.POST)
        request.session['post_data'] = request.POST.copy() 
    else:
        post_data = request.session['post_data']
        if post_data:
            form = AnimalSearchForm(post_data)
        else:
            form = AnimalSearchForm()

    if form.is_valid():
        intake_condition = form.cleaned_data['intake_condition']
        if intake_condition:
            alist = alist.filter(intake_condition=intake_condition)
        intake_date_start = form.cleaned_data['intake_date_start']
        intake_date_end = form.cleaned_data['intake_date_end']
        if intake_date_start and intake_date_end:
            alist = alist.filter(intake_date__gte=intake_date_start,<commit_msg>bugfix<commit_after>from django.db.models import Q
from django.shortcuts import render_to_response
from django.template import RequestContext
from datetime import datetime, date, timedelta

from animals.models import Animal
from animals.forms import AnimalSearchForm


def index(request, template_name='animals/index.html'):
    context = {}
    alist = Animal.objects.all()
    startdate = datetime.today() - timedelta(days=14)
    enddate = datetime.today()

    if request.method == 'POST':
        form = AnimalSearchForm(request.POST)
        request.session['post_data'] = request.POST.copy() 
    else:
        post_data = request.session.get('post_data', None)
        if post_data:
            form = AnimalSearchForm(post_data)
        else:
            form = AnimalSearchForm()

    if form.is_valid():
        intake_condition = form.cleaned_data['intake_condition']
        if intake_condition:
            alist = alist.filter(intake_condition=intake_condition)
        intake_date_start = form.cleaned_data['intake_date_start']
        intake_date_end = form.cleaned_data['intake_date_end']
        if intake_date_start and intake_date_end:
            alist = alist.filter(intake_date__gte=intake_date_start,
{'fraction_non_alphanumeric': 0.08990600735594606, 'fraction_numerical': 0.0016346546791990192, 'mean_word_length': 3.426763110307414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1150824', 'n_tokens_mistral': 736, 'n_tokens_neox': 707, 'n_words': 144}