Example #1
0
def authLogin(request):
	if request.method == 'POST':
		username = request.POST['username']
		password = request.POST['password']
		user = authenticate(username=username, password=password)
		if user is not None:
			if user.is_active:
				login(request, user)
				return HttpResponseRedirect(reverse(loginSuccess))
			else: #no longer active
				return HttpResponseRedirect(reverse(home))
		else: #failed login
			return HttpResponseRedirect(reverse(home))
	else:
		return commonResponse(request, 'login.html')
Example #2
0
def createSetup(request):
	if request.method == 'POST':
		data = request.POST
		user = request.user
		team = getUserProfile(user).team
		competition = models.Competition.objects.get(pk=int(data['competition']))
		teamDataSetup = models.TeamDataSetup(creator = team, competition = competition)
		teamDataSetup.save()
		createdSetups = []
		dataSetupNumbers = data['dataSetups'].split(',')
		groups = {}
		for number in dataSetupNumbers:
			typeOfData = data['{}-type'.format(number)]
			createdSetups.append( (dataSetups[typeOfData])['create'](data, number, groups, teamDataSetup) )

		for dataSetup in createdSetups:
			dataSetup.save()

		return HttpResponseRedirect(reverse(manageSetups))
	else:
		competitions = models.Competition.objects.order_by('dateCreated')
		return commonResponse(request, 'createSetup.html', {"dataTypes": dataTypes, 'competitions': competitions})
Example #3
0
def loginFail(request):
	return commonResponse(request, 'loginFail.html')
Example #4
0
def loginSuccess(request):
	return commonResponse(request, 'loginSuccess.html')
Example #5
0
def manageSetups(request, createdSetup = False):
	return commonResponse(request, 'manageSetups.html')
Example #6
0
def home(request):
	return commonResponse(request, 'home.html')