Exemple #1
0
def signup(request):
    if request.method == 'POST':
        username = request.POST['username']
        password = password1 = request.POST['password1']
        password2 = request.POST['password2']

        if password1 == password2:
            if User.objects.filter(username=username).exists() == False:
                o_ref = User.objects.create_user(username=username,
                                                 password=password1)
                o_ref.save()
                u_ref = UserAccount(username=username, password=password1)
                u_ref.save()
                print('User Created')
                user = auth.authenticate(username=username, password=password)
                auth.login(request, user)
                print(user)
                return redirect('../../user/')

            else:
                print("User Already Exists")
                return render(request, "signup.html")

        else:
            print("Passwords don't Match")
            return render(request, "signup.html")

    else:
        return render(request, "signup.html")
Exemple #2
0
def reqister(request):
    username = request.POST.get("username")
    password = request.POST.get("password")
    email = request.POST.get("email")
    company = request.POST.get("company")
    location = request.POST.get("location")
    startdate = request.POST.get("startdate")
    enddate = request.POST.get("enddate")
    comments = request.POST.get("comments")
    datetimenow = timezone.now()

    user = User(username=username, email=email)
    user.set_password(password)
    user.save()
    userdetails = UserAccount(user=user, user_type='CU', company=company)
    userdetails.save()
    login(request, user)

    inquiry = Inquiry(location=location,
                      start_date=startdate,
                      end_date=enddate,
                      sent_on=datetimenow,
                      comments=comments,
                      customer=user,
                      status="AQ")
    inquiry.save()

    cart = request.session.get('cart', [])
    equipment = Equipment.objects.filter(id__in=cart)
    for unit in equipment:
        inquiryequipment = InquiryEquipment(equipment=unit, inquiry=inquiry)
        inquiryequipment.save()

    request.session['cart'] = []
    return HttpResponse('1')
Exemple #3
0
def userpage(request, user):
    if request.method == 'POST':
        uploaded_file = request.FILES["document"]
        fs = UserAccount(file_user=uploaded_file)
        fs.save(uploaded_file)
        return render(request, 'user.html')