Пример #1
0
def register(request):
	extra_context = {}
	if get_settings().deny_registration_from < datetime.now():
		extra_context['deny_registration_from'] = get_settings().deny_registration_from
		extra_context['admins'] = User.objects.filter(is_superuser=True)
		extra_context['trainers'] = Group.objects.get(name="Trainer").user_set.all()
	else:
		if request.method == 'POST':
			form = MyRegistrationForm(request.POST, domain=RequestSite(request).domain, use_https=request.is_secure())
			if form.is_valid():
				form.save()
				return HttpResponseRedirect(reverse('registration_complete'))
		else:
			form = MyRegistrationForm()
		extra_context['form'] = form
	return render_to_response('registration/registration_form.html', extra_context, context_instance=RequestContext(request))
Пример #2
0
def register_user(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        uform = UserDetailForm(request.POST)
        print "here"
        if form.is_valid():
            print "Form1 is valid"
            if uform.is_valid():
                print "Form2 is valid"
                user = form.save()
                userprofile = uform.save(commit=False)
                userprofile.user = user
                userprofile.save()
                return HttpResponseRedirect('/accounts/register_success')
    args = {}
    args.update(csrf(request))

    args['form'] = MyRegistrationForm()
    args['uform'] = UserDetailForm()

    return render(request, 'register.html', args)
Пример #3
0
def make_account_view(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            user = form.save()
            return redirect("home")

    else:
        form = MyRegistrationForm()
    return render(request, 'accounts/make-account.html', {'form': form})
Пример #4
0
def signup_view(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            user = form.save()
            login(request, user)
            return redirect('dashboard:health')
    else:
        form = MyRegistrationForm()
    return render(request, 'accounts/signup.html', {'form': form})
Пример #5
0
def editProfile_view(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST, instance=request.user)
        if form.is_valid:
            form.save()
            return redirect('dashboard:profilePage')

    else:
        form = MyRegistrationForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #6
0
def register(request):
    print request
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST, request.FILES)
        if form.is_valid():
            form.save(commit=True)

            return HttpResponseRedirect('/accounts/register/complete')
    else:
        form = MyRegistrationForm()
    token = {}
    token.update(csrf(request))
    token['form'] = form

    return render(request, 'registration/registration_form.html', token)
Пример #7
0
def register(request):
    extra_context = {}
    if (not settings.REGISTRATION_POSSIBLE
        ) or get_settings().deny_registration_from < datetime.now():
        extra_context['deny_registration_from'] = get_settings(
        ).deny_registration_from
        extra_context['admins'] = User.objects.filter(is_superuser=True)
        extra_context['trainers'] = Group.objects.get(
            name="Trainer").user_set.all()
    else:
        if request.method == 'POST':
            form = MyRegistrationForm(request.POST,
                                      domain=RequestSite(request).domain,
                                      use_https=request.is_secure())
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('registration_complete'))
        else:
            form = MyRegistrationForm()
        extra_context['form'] = form
    return render(request, 'registration/registration_form.html',
                  extra_context)