<commit_before>from datetime import datetime

from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt, csrf_protect

from ultimate.leagues.models import *

from ultimate.forms import RegistrationAttendanceForm
from ultimate.middleware.http import Http403

from paypal.standard.forms import PayPalPaymentsForm


def index(request, year, season):
	if request.user.is_superuser:
		leagues = League.objects.filter(year=year, season=season).order_by('league_start_date')
	elif request.user.is_staff:
		leagues = League.objects.filter(year=year, season=season, state__in=['active', 'planning']).order_by('league_start_date')
	else:
		leagues = League.objects.filter(year=year, season=season, state__in=['active']).order_by('league_start_date')

	return render_to_response('leagues/index.html',
		{'leagues': leagues, 'year': year, 'season': season},
		context_instance=RequestContext(request))


def summary(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)
	return render_to_response('leagues/summary.html',
		{'league': league},
		context_instance=RequestContext(request))


def details(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)
	return render_to_response('leagues/details.html',
		{'league': league},
		context_instance=RequestContext(request))


def players(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)
	user_registration = Registrations.objects.get(user=request.user, league=league)

	complete_registrations = league.get_complete_registrations()
	incomplete_registrations = league.get_incomplete_registrations()
	waitlist_registrations = league.get_waitlist_registrations()
	refunded_registrations = league.get_refunded_registrations()

	return render_to_response('leagues/players.html',
		{
			'league': league,
			'user_registration': user_registration,
			'complete_registrations': complete_registrations,
			'incomplete_registrations': incomplete_registrations,
			'waitlist_registrations': waitlist_registrations,
			'refunded_registrations': refunded_registrations
		},
		context_instance=RequestContext(request))


def teams(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)<commit_msg>fix for unauthenticated user on players page<commit_after>from datetime import datetime

from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt, csrf_protect

from ultimate.leagues.models import *

from ultimate.forms import RegistrationAttendanceForm
from ultimate.middleware.http import Http403

from paypal.standard.forms import PayPalPaymentsForm


def index(request, year, season):
	if request.user.is_superuser:
		leagues = League.objects.filter(year=year, season=season).order_by('league_start_date')
	elif request.user.is_staff:
		leagues = League.objects.filter(year=year, season=season, state__in=['active', 'planning']).order_by('league_start_date')
	else:
		leagues = League.objects.filter(year=year, season=season, state__in=['active']).order_by('league_start_date')

	return render_to_response('leagues/index.html',
		{'leagues': leagues, 'year': year, 'season': season},
		context_instance=RequestContext(request))


def summary(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)
	return render_to_response('leagues/summary.html',
		{'league': league},
		context_instance=RequestContext(request))


def details(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)
	return render_to_response('leagues/details.html',
		{'league': league},
		context_instance=RequestContext(request))


def players(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)

	if request.user.is_authenticated():
		user_registration = Registrations.objects.get(user=request.user, league=league)
	else:
		user_registration = None

	complete_registrations = league.get_complete_registrations()
	incomplete_registrations = league.get_incomplete_registrations()
	waitlist_registrations = league.get_waitlist_registrations()
	refunded_registrations = league.get_refunded_registrations()

	return render_to_response('leagues/players.html',
		{
			'league': league,
			'user_registration': user_registration,
			'complete_registrations': complete_registrations,
			'incomplete_registrations': incomplete_registrations,
			'waitlist_registrations': waitlist_registrations,
			'refunded_registrations': refunded_registrations
		},
		context_instance=RequestContext(request))


def teams(request, year, season, division):
	league = get_object_or_404(League, year=year, season=season, night=division)
{'fraction_non_alphanumeric': 0.1005514705882353, 'fraction_numerical': 0.006617647058823529, 'mean_word_length': 7.963756177924218, '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': '1277674', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1616, 'n_words': 324}