<commit_before>from django.core.urlresolvers import reverse
from django.shortcuts import render, get_object_or_404
from django.utils import timezone

from wprevents.base.decorators import ajax_required
from wprevents.events.models import Event, Space, FunctionalArea
from wprevents.events.forms import SearchForm

from month_manager import MonthManager


def one(request, id, slug):
  event = get_object_or_404(Event.objects.select_related('space').prefetch_related('areas'), id=id)

  return render(request, 'event.html', {
    'event': event,
    'event_absolute_url': request.build_absolute_uri(reverse('event_one', args=(event.pk, event.slug,)))
  })


def render_index(request, template):
  list_events = Event.objects.upcoming_events().order_by('start')
  list_events = list_events.select_related('space').prefetch_related('areas')

  now = timezone.now()
  calendar_events = Event.objects.of_given_month(now.year, now.month)
  calendar_events = calendar_events.select_related('space').prefetch_related('areas')
  month_manager = MonthManager(year=now.year, month=now.month, events=calendar_events)

  return render(request, template, {
    'list_events': list_events,
    'spaces': Space.objects.all(),
    'areas': FunctionalArea.objects.all(),
    'month_manager': month_manager
  })

def list(request):
  return render_index(request, 'list.html')

def calendar(request):
  return render_index(request, 'calendar.html')


@ajax_required
def filter_list(request):
  form = SearchForm(request.GET)
  events = []

  if form.is_valid():
    search_params = {
      'space_name': form.cleaned_data['space'],
      'area_name': form.cleaned_data['area'],
      'search_string': form.cleaned_data['keyword'],
      'start_date': form.cleaned_data.get('start'),
      'end_date': form.cleaned_data.get('end')
    }

    events = Event.objects.search(**search_params).order_by('start')

  return render(request, 'list_content.html', {
    'list_events': events
  })


@ajax_required
def filter_calendar(request):
  form = SearchForm(request.GET)
  events = []
  now = timezone.now()

  if form.is_valid():
    search_params = {
      'space_name': form.cleaned_data['space'],<commit_msg>Remove unused variable<commit_after>from django.core.urlresolvers import reverse
from django.shortcuts import render, get_object_or_404
from django.utils import timezone

from wprevents.base.decorators import ajax_required
from wprevents.events.models import Event, Space, FunctionalArea
from wprevents.events.forms import SearchForm

from month_manager import MonthManager


def one(request, id, slug):
  event = get_object_or_404(Event.objects.select_related('space').prefetch_related('areas'), id=id)

  return render(request, 'event.html', {
    'event': event,
    'event_absolute_url': request.build_absolute_uri(reverse('event_one', args=(event.pk, event.slug,)))
  })


def render_index(request, template):
  list_events = Event.objects.upcoming_events().order_by('start')
  list_events = list_events.select_related('space').prefetch_related('areas')

  now = timezone.now()
  calendar_events = Event.objects.of_given_month(now.year, now.month)
  calendar_events = calendar_events.select_related('space').prefetch_related('areas')
  month_manager = MonthManager(year=now.year, month=now.month, events=calendar_events)

  return render(request, template, {
    'list_events': list_events,
    'spaces': Space.objects.all(),
    'areas': FunctionalArea.objects.all(),
    'month_manager': month_manager
  })

def list(request):
  return render_index(request, 'list.html')

def calendar(request):
  return render_index(request, 'calendar.html')


@ajax_required
def filter_list(request):
  form = SearchForm(request.GET)
  events = []

  if form.is_valid():
    search_params = {
      'space_name': form.cleaned_data['space'],
      'area_name': form.cleaned_data['area'],
      'search_string': form.cleaned_data['keyword'],
      'start_date': form.cleaned_data.get('start'),
      'end_date': form.cleaned_data.get('end')
    }

    events = Event.objects.search(**search_params).order_by('start')

  return render(request, 'list_content.html', {
    'list_events': events
  })


@ajax_required
def filter_calendar(request):
  form = SearchForm(request.GET)
  now = timezone.now()

  if form.is_valid():
    search_params = {
      'space_name': form.cleaned_data['space'],
{'fraction_non_alphanumeric': 0.13252460517280842, 'fraction_numerical': 0.002746623941405356, 'mean_word_length': 5.315028901734104, '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': '6242973', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1377, 'n_words': 250}