Ejemplo n.º 1
0
def home(request):
    events = get_event(request)
    blogs = Blog.objects.all()[:6]

    context = {'events': events, 'blogs': blogs}

    return render(request, 'index/index.html', context)
Ejemplo n.º 2
0
def show_teams(request, domain, num):
    event = get_event(domain, num)

    try:
        judge = get_object_or_404(Judge, email=request.session['session_id'])
    except KeyError:
        return HttpResponseRedirect('/users/login/?next=%s' % request.path)

    teams = Team.objects.filter(event=event, judge=judge)

    if event.category.domain == 'arth':
        return render_to_response('users/judge/arth_teams.html', {'list': menu, 'teams': teams, 'judge': judge}, context_instance=RequestContext(request))

    raise Http404
Ejemplo n.º 3
0
def show_entry(request, domain, num, index):
    event = get_event(domain, num)
    back = '/users/judge/' + event.get_link()
    msg = None
    success = None

    try:
        judge = get_object_or_404(Judge, email=request.session['session_id'])
    except KeyError:
        return HttpResponseRedirect('/users/login/?next=%s' % request.path)

    team = get_object_or_404(Team, pk=index)

    if team.judge != judge:
        raise Http404

    if event.category.domain == 'arth':
        data = team.get_data()
        form = ArthJudgeForm()

        if data:
            form = ArthJudgeForm(instance=data)

        if request.method == 'POST':
            form = ArthJudgeForm(request.POST)

            if form.is_valid():
                team.is_judged = True
                team.save()
                form = ArthJudgeForm(request.POST, instance=data)
                form.save()
                success = 1
                msg = 'Changes were saved successfully'
            else:
                success = 0
                msg = 'Please ensure all scores are integers from 0 to 10'

        return render_to_response('users/judge/arth_entry.html', {'list': menu, 'back': back, 'team': team, 'success': success, 'msg': msg, 'data': data, 'form': form}, context_instance=RequestContext(request))

    return HttpResponse()
Ejemplo n.º 4
0
def register(request, event_id = None):
  profile = None
  registration = None
  request.session['user_registered'] = None
  event = get_event(event_id)
  request.session['event_id'] = event.id

  if request.session.has_key('login_email'):
    profile, registration = get_user_profile_registration(event, request.session['login_email'])
    if profile and registration:
      request.session['user_registered'] = "True"
      if registration.completed_exit_survey == "True":
        request.session['thank_you'] = "thanks"
  else:
    request.session['login_email'] = None

  login_form = LoginForm()
  logout_form = LogoutForm()
  register_event_form = RegisterEventForm()
  user_profile_form = UserProfileForm()

  if request.method == "POST":
    login_form = LoginForm(request.POST)
    logout_form = LogoutForm(request.POST)
    register_event_form = RegisterEventForm(request.POST)
    user_profile_form = UserProfileForm(request.POST)

    if user_profile_form.is_valid():
      if not user_profile_exists(user_profile_form.cleaned_data['email']):
        usr = user_profile_form.save(commit=False)
        usr.ip_address = request.META['REMOTE_ADDR']
        usr.save()
        login_user(request, user_profile_form.cleaned_data['email'])
        register_user_for_event(request, event, usr)
        return HttpResponseRedirect(reverse('event', args=[event_id]))
      else:
        # the user already exists
        # TO DO
        user_profile_form = UserProfileForm()
        pass
    elif login_form.is_valid():
      if user_profile_exists(login_form.cleaned_data['email']):
        login_user(request, login_form.cleaned_data['email'])
        #if is_first_redirect(request):
        #  return HttpResponseRedirect(reverse('register', args=[event_id, settings.REGISTRATION_MESSAGE]))
        #else:
        return HttpResponseRedirect(reverse('event', args=[event_id]))
      else:
        # Do Nothing (page will reload with no one logged in)
        login_form = LoginForm()
        logout_form = LogoutForm()
        pass
    elif logout_form.is_valid():
      logout_user(request)
      login_form = LoginForm()
      user_profile_form = UserProfileForm()
      register_event_form = RegisterEventForm()
    
    if user_is_logged_in(request):
      if register_event_form.is_valid():
        register_user_for_event(request, event, profile)
        return HttpResponseRedirect(reverse('event', args=[event_id]))

  context_data = {
    'event': event,
    'login_form': login_form,
    'logout_form': logout_form,
    'register_event_form': register_event_form,
    'user_profile_form': user_profile_form,
  }

  return render_to_response('register.html', context_data, context_instance = RequestContext(request))