def attend(request, lan_id): lan = get_object_or_404(LAN, pk=lan_id) if lan.end_date < datetime.now(): messages.error( request, _(u'This LAN has finished and can no longer be attended.')) return redirect(lan) if not request.user.profile.has_address(): messages.error( request, _(u'You need to fill in your address and postal code in order to sign up for a LAN.' )) else: if request.user in lan.attendees: messages.error( request, _(u'You are already in the attendee list for {lan}.').format( lan=lan)) else: attendee = Attendee(lan=lan, user=request.user) attendee.save() messages.success( request, _(u'Successfully added you to attendee list for {lan}.'). format(lan=lan)) return redirect(lan)
def direct_register(request, lan_id): lan = get_object_or_404(LAN, id=lan_id) if lan.is_ended(): messages.error(request, _(u'The LAN is ended, arrivals can\'t be changed.')) return redirect('/') if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): cleaned = form.cleaned_data # Create user user = User( username=cleaned['desired_username'], first_name=cleaned['first_name'], last_name=cleaned['last_name'], email=cleaned['email'], ) user.set_password(cleaned['password']) user.is_active = True user.save() # Create userprofile up = UserProfile( user=user, nick=cleaned['desired_username'], date_of_birth=cleaned['date_of_birth'], zip_code=cleaned['zip_code'], address=cleaned['address'], phone=cleaned['phone'], ) up.save() attendee = Attendee(lan=lan, user=user) attendee.save() messages.success(request, _(u'Registration successful.')) return redirect('/auth/direct_register') else: form = RegisterForm(request.POST, auto_id=True, error_class=InlineSpanErrorList) else: form = RegisterForm() breadcrumbs = ( (lan, lan.get_absolute_url()), (_(u'Manual Registration'), ''), ) context = { 'breadcrumbs': breadcrumbs, 'lan': lan, 'form': form, } return render(request, 'auth/direct_register.html', context)
def direct_register(request): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): cleaned = form.cleaned_data lan = LAN.objects.filter(end_date__gte=datetime.now())[0] if not lan: messages.error(request, u'No upcoming LAN was found.') return HttpResponseRedirect('/auth/direct_register') # Create user user = User( username=cleaned['desired_username'], first_name=cleaned['first_name'], last_name=cleaned['last_name'], email=cleaned['email'], ) user.set_password(cleaned['password']) user.is_active = True user.save() # Create userprofile up = UserProfile( user=user, nick=cleaned['desired_username'], date_of_birth=cleaned['date_of_birth'], zip_code=cleaned['zip_code'], address=cleaned['address'], phone=cleaned['phone'], ) up.save() attendee = Attendee(lan=lan, user=user) attendee.save() messages.success(request, _(u'Registration successful.')) return HttpResponseRedirect('/auth/direct_register') else: form = RegisterForm(request.POST, auto_id=True, error_class=InlineSpanErrorList) else: form = RegisterForm() lan = LAN.objects.filter(end_date__gte=datetime.now())[0] return render(request, 'auth/direct_register.html', {'form': form, 'lan': lan})
def direct_register(request): lan = LAN.objects.filter(end_date__gte=datetime.now()).first() if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): cleaned = form.cleaned_data if lan is None: messages.error(request, _(u'No upcoming LAN was found.')) return HttpResponseRedirect('/auth/direct_register') # Create user user = User( username=cleaned['desired_username'], first_name=cleaned['first_name'], last_name=cleaned['last_name'], email=cleaned['email'], ) user.set_password(cleaned['password']) user.is_active = True user.save() # Create userprofile up = UserProfile( user=user, nick=cleaned['desired_username'], date_of_birth=cleaned['date_of_birth'], zip_code=cleaned['zip_code'], address=cleaned['address'], phone=cleaned['phone'], ) up.save() attendee = Attendee(lan=lan, user=user) attendee.save() messages.success(request, _(u'Registration successful.')) return HttpResponseRedirect('/auth/direct_register') else: form = RegisterForm(request.POST, auto_id=True, error_class=InlineSpanErrorList) else: form = RegisterForm() return render(request, 'auth/direct_register.html', {'form': form, 'lan': lan})
def attend(request, lan_id): lan = get_object_or_404(LAN, pk=lan_id) if lan.end_date < datetime.now(): messages.error(request, _(u"This LAN has finished and can no longer be attended")) return redirect(lan) if not request.user.profile.has_address(): messages.error(request, _(u"You need to fill in your address and zip code in order to sign up for a LAN.")) else: if request.user in lan.attendees: messages.error(request, _(u"You are already in the attendee list for ") + unicode(lan)) else: attendee = Attendee(lan=lan, user=request.user) attendee.save() messages.success(request, _(u"Successfully added you to attendee list for ") + unicode(lan)) return redirect(lan)