def register(request): context = {} template = 'contest/register.html' if contest_phase() != 'after': form = RegistrationForm() if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): uname = form['username'].value() pwd = form['password'].value() p = Profile() p.username = uname p.set_password(pwd) p.save() context['successful_registration'] = uname return redirect('home') else: form = RegistrationForm() return render(request, template, {'form': form}) else: messages.warning(request, "No Competition Online Come Back After Some Time") return render(request, "404.html")
def contest_time(request): context = {} now = timezone.now() contest = models.ContestControl.objects.first() if now < contest.start: time = contest.start elif contest.start <= now <= contest.end: time = contest.end else: time = None context['contest_time'] = time context['contest_on'] = is_contest_on() context['contest_phase'] = contest_phase() return context
def register(request): context = {} template = 'contest/register.html' if contest_phase() != 'after': context['form'] = RegistrationForm() if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): uname = form['username'].value() pwd = form['password'].value() p = Profile() p.username = uname p.set_password(pwd) p.save() context['successful_registration'] = uname else: context['form'] = form return render(request, template, context)