<commit_before>from django.shortcuts import render, redirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseServerError
from django.contrib.auth import authenticate, login, logout
from django.contrib.sites.models import Site
from django.db.models import Q
from django.views.decorators.csrf import csrf_protect
from django.shortcuts import get_object_or_404
from django.utils.encoding import smart_str
from django.conf import settings
from django.utils import timezone

from web.models import Event, User, SignUp, LearningResource, ResourceCategory
from web.forms import EventForm, RegisterForm, LoginForm, SignUpForm
from web.extra import send_signup_confirmation, send_new_event
from datetime import timedelta

import sys
import datetime
import csv
import urllib

def index(request):
  approved = Q(approved=True)
  endDateInFuture = Q(end_date__isnull=False) & Q(end_date__gt=datetime.datetime.now() + timedelta(days=-1))
  noEndDateStartDateInFuture = Q(end_date__isnull=True) & Q(start_date__gt=datetime.datetime.now() + timedelta(days=-1))
  events = Event.objects.filter(approved & (endDateInFuture | noEndDateStartDateInFuture))
  old_events = Event.objects.filter(~Q(approved & (endDateInFuture | noEndDateStartDateInFuture)))
  form = SignUpForm()

  resources = [
    ResourceCategory('Pelien avulla', 'game', [
      LearningResource(
        url = 'http://koodaustunti.fi',
        age = '4 +',
        ageClass = 4,
        languages = 'FI',
        header = 'Tunnin johdatus koodaukseen',
        description = 'Kuka tahansa voi oppia koodauksen perusasiat. Koodaustunti antaa tunnin mittaisen johdatuksen koodaamiseen.',
        free = True),<commit_msg>there was a bug in the filtering logic<commit_after>from django.shortcuts import render, redirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseServerError
from django.contrib.auth import authenticate, login, logout
from django.contrib.sites.models import Site
from django.db.models import Q
from django.views.decorators.csrf import csrf_protect
from django.shortcuts import get_object_or_404
from django.utils.encoding import smart_str
from django.conf import settings
from django.utils import timezone

from web.models import Event, User, SignUp, LearningResource, ResourceCategory
from web.forms import EventForm, RegisterForm, LoginForm, SignUpForm
from web.extra import send_signup_confirmation, send_new_event
from datetime import timedelta

import sys
import datetime
import csv
import urllib

def index(request):
  approved = Q(approved=True)
  endDateInFuture = Q(end_date__isnull=False) & Q(end_date__gt=datetime.datetime.now() + timedelta(days=-1))
  noEndDateStartDateInFuture = Q(end_date__isnull=True) & Q(start_date__gt=datetime.datetime.now() + timedelta(days=-1))
  events = Event.objects.filter(approved & (endDateInFuture | noEndDateStartDateInFuture))
  old_events = Event.objects.filter(approved & ~Q(endDateInFuture | noEndDateStartDateInFuture))
  form = SignUpForm()

  resources = [
    ResourceCategory('Pelien avulla', 'game', [
      LearningResource(
        url = 'http://koodaustunti.fi',
        age = '4 +',
        ageClass = 4,
        languages = 'FI',
        header = 'Tunnin johdatus koodaukseen',
        description = 'Kuka tahansa voi oppia koodauksen perusasiat. Koodaustunti antaa tunnin mittaisen johdatuksen koodaamiseen.',
        free = True),
{'fraction_non_alphanumeric': 0.08228379513014274, 'fraction_numerical': 0.003918275958578225, 'mean_word_length': 5.162068965517242, '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': '4064911', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1066, 'n_words': 282}