Beispiel #1
0
def create_test_account():
    ta = UserAccount(username="******",
                     password="******",
                     email="*****@*****.**",
                     first_name="penguin",
                     last_name="rider",
                     bio="Hi im a penguinrider",
                     profile_picture=DEFAULT_IMAGE_UUID)
    ta.set_password('password123')
    ta.save()
    return ta
Beispiel #2
0
 def setUp(self):
     create_test_product(create_test_account().id)
     ta_2 = UserAccount(username="******",
                        password="******",
                        email="*****@*****.**",
                        first_name="penguin",
                        last_name="rider",
                        bio="Hi im a penguinrider",
                        profile_picture=DEFAULT_IMAGE_UUID)
     ta_2.set_password('password123')
     ta_2.save()
Beispiel #3
0
def UserRegistration(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/photos/')
    elif 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()
            user_account = UserAccount(user=user,
                                       username=form.cleaned_data['username'],
                                       email=form.cleaned_data['email'],
                                       password=form.cleaned_data['password'])
            user_account.save()
            return HttpResponseRedirect('/photos/' , {'form' : form})
        else:
            return render(request , 'register.html' , {'form': form})
    else:
        '''user is'nt submitting the form, show them a blank registration form'''
        form = RegistrationForm()
        return render(request,'register.html', {'form' : form})
Beispiel #4
0
def registration_view(request):
    redirect_to = "/"
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        email = request.POST.get("email")
        username = request.POST.get("username")
        password = request.POST.get("password")
        first_name = request.POST.get("first_name")
        last_name = request.POST.get("last_name")
        email = request.POST.get("email")
        if password == request.POST.get("repeat_password") and form.is_valid():
            acc = UserAccount()
            user = User.objects.create_user(username=username,
                                            password=password,
                                            first_name=first_name,
                                            last_name=last_name,
                                            email=email)
            acc.user = user
            acc.phone_number = request.POST.get("phone_number")
            acc.save()
            return HttpResponseRedirect(redirect_to)
    form = RegistrationForm()
    context = {'form': form}
    return render(request, "registration.html", context)