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')
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})
def loginFail(request): return commonResponse(request, 'loginFail.html')
def loginSuccess(request): return commonResponse(request, 'loginSuccess.html')
def manageSetups(request, createdSetup = False): return commonResponse(request, 'manageSetups.html')
def home(request): return commonResponse(request, 'home.html')