Beispiel #1
0
def register(request):
    if request.method=='POST':
        form=RegistrationForm(request.POST)
        if form.is_valid():
            #Generate a username and create user
            username=generate_username(form.cleaned_data['first_name'], form.cleaned_data['last_name'])
            new_user=User.objects.create_user(username, form.cleaned_data['email'], form.cleaned_data['password1'])
            new_user.first_name=form.cleaned_data['first_name']
            new_user.last_name=form.cleaned_data['last_name']
            new_user.save()
            return redirect('/')
    else:
        form=RegistrationForm()
    return render(request,'auth/registration_form.html',{'form':form})
Beispiel #2
0
def register(request):
    if request.user.is_authenticated():
        return redirect('/dashboard/')
    if request.method=='POST':
        form=RegistrationForm(request.POST)
        if form.is_valid():
            # Generate a username and create user
            new_user=User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1'])
            new_user.save()
            log_user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password1'])
            login(request, log_user)
            return redirect('/dashboard/')
    else:
        form=RegistrationForm()
    return render(request,'members/register.html',{'form':form})
Beispiel #3
0
def registration(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            member = Member.objects.create_user(
                username=form.cleaned_data.get("username"),
                password=form.cleaned_data.get("password"),
                email=form.cleaned_data.get("email"))
            member.location = form.cleaned_data.get("location")
            member.save()
            return HttpResponseRedirect('/members/')
        else:
            return render(request, 'members/signup.html', {'form':form})
    else:
        form = RegistrationForm()
        return render(request, 'members/signup.html', {'form': form})
Beispiel #4
0
def member_registration(request):
    if request.user.is_authenticated():
        return redirect('home')
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = form.save()
            user.backend='django.contrib.auth.backends.ModelBackend'			
            user.save()
            login(request, user)			
            return redirect('home')
        else:
            return render(request, 'register.html', {'form':form})
    else:
        form = RegistrationForm()
        return render(request, 'register.html', {'form':form})		
 def post(self,request):
     usercreation_form = UserCreationForm(request.POST)
     registration_form = RegistrationForm(request.POST)
     if registration_form.is_valid() and usercreation_form.is_valid():
 
         user = usercreation_form.save()
         member = registration_form.save(commit = False)
         member.reg_time = timezone.now()
         member.user = user
         member.save()
         
     
         context = {}
         context['member'] = member
         
         return render(request, 'members/complete.html', context)
 
     else:
         context = {}
         context['usercreation_form'] = usercreation_form
         context['registration_form'] = registration_form
         return render(request, 'members/registration.html', context)
Beispiel #6
0
def SurvivorRegistration(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/home')
    if request.method == "POST":
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(username=form.cleaned_data["username"],
                                            email=form.cleaned_data["email"],
                                            password=form.cleaned_data["password"])
            user.save()
            member = Member(
                user=user, ign=form.cleaned_data["ign"], title="Player")
            member.save()
            return HttpResponseRedirect('/home')
        else:
            return render_to_response("register.html", {"form": form},
                                      context_instance=RequestContext(request))
    else:
        # user is not submitting the form, show them a registration form
        form = RegistrationForm()
        context = {"form": form}
        return render_to_response('register.html', context,
                                  context_instance=RequestContext(request))