Пример #1
0
def validate(request, validation_hash):
    try:
        registration = Registration.objects.get(
            validation_hash=validation_hash)
    except Registration.DoesNotExist:
        return render_to_response(
            'registration/validate_error.html', {
                'message':
                'The validation key you provided, has not been valid. Did you validate before?'
            })

    try:
        # save to LDAP
        registration.transfer_to_ldap()
        # send mail
        util.send_mail(registration.email,
                       'OFELIA Registration - Registration complete',
                       'registration_complete.txt',
                       link=settings.SERVER_BASE +
                       reverse('registration.views.login.login'),
                       login=registration.safe_name)
    except Registration.LdapException, e:
        return render_to_response(
            'registration/validate_error.html',
            {'message': 'Error during LDAP processing (%s)' % e.message})
Пример #2
0
def register(request):
	if request.method == 'POST':
		form = RegistrationForm(request.POST)
		form.recaptcha_remote_ip = request.META['REMOTE_ADDR']
		
		if form.is_valid():
			form.save()
			util.send_mail(
				form.instance.email,
				'OFELIA Registration - Please validate your email address',
				'registration_validation.txt',
				link=settings.SERVER_BASE + reverse('registration.views.registration.validate', args=(form.instance.validation_hash,)))
			return HttpResponseRedirect(reverse('registration.views.registration.register_success'))
	else:
		form = RegistrationForm()
	return render_to_response('registration/register.html', { 'form' : form })
Пример #3
0
def validate(request, validation_hash):
	try:
		registration = Registration.objects.get(validation_hash=validation_hash)
	except Registration.DoesNotExist:
		return render_to_response('registration/validate_error.html', { 'message' : 'The validation key you provided, has not been valid. Did you validate before?'})
		
	try:
		# save to LDAP
		registration.transfer_to_ldap()
		# send mail
		util.send_mail(
			registration.email,
			'OFELIA Registration - Registration complete',
			'registration_complete.txt',
			link=settings.SERVER_BASE + reverse('registration.views.login.login'),
			login=registration.safe_name)
	except Registration.LdapException, e:
		return render_to_response('registration/validate_error.html', { 'message' : 'Error during LDAP processing (%s)' % e.message})
Пример #4
0
def forgotten(request):
	if request.method == 'POST':
		form = PasswordResetForm(request.POST)

		if form.is_valid():
			email = form.cleaned_data['email']
			password_stub = util.generate_random_password()
			try:
				login = form.reset_password(password_stub)
			except util.LdapException, e:
				return render_to_response('password_reset/forgotten.html', { 'message' : 'Error during LDAP processing (%s)' % e.message, 'form' : form })
			
			util.send_mail(
				email,
				'OFELIA Registration - Password has been reset',
				'password_reset_reset.txt',
				password=password_stub, login=login)
			return HttpResponseRedirect(reverse('registration.views.password_reset.reset'))
Пример #5
0
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        form.recaptcha_remote_ip = request.META['REMOTE_ADDR']

        if form.is_valid():
            form.save()
            util.send_mail(
                form.instance.email,
                'OFELIA Registration - Please validate your email address',
                'registration_validation.txt',
                link=settings.SERVER_BASE +
                reverse('registration.views.registration.validate',
                        args=(form.instance.validation_hash, )))
            return HttpResponseRedirect(
                reverse('registration.views.registration.register_success'))
    else:
        form = RegistrationForm()
    return render_to_response('registration/register.html', {'form': form})