Exemplo n.º 1
0
    def post(self, request):
        postData = request.POST
        Firstname = postData.get('Firstname')
        Lastname = postData.get('Lastname')
        phone = postData.get('phone')
        email = postData.get('email')
        password = postData.get('password')
        # validation
        value = {
            'Firstname': Firstname,
            'Lastname': Lastname,
            'phone': phone,
            'email': email
        }
        error_message = None

        customer = Customer(Firstname=Firstname,
                            Lastname=Lastname,
                            phone=phone,
                            email=email,
                            password=password)
        error_message = self.validateCustomer(customer)

        if not error_message:
            print(Firstname, Lastname, phone, email, password)
            customer.password = make_password(customer.password)
            customer.register()
            return redirect('index')
        else:
            data = {
                'error': error_message,
                'values': value
            }
            return render(request, 'signup.html', data)
Exemplo n.º 2
0
    def post(self, request):
        post_data = request.POST
        fname = post_data.get('fname')
        lname = post_data.get('lname')
        phone = post_data.get('phone')
        emailid = post_data.get('emailid')
        password = post_data.get('password')

        # validations
        value = {
            'fname': fname,
            'lname': lname,
            'phone': phone,
            'emailid': emailid
        }

        error_message = None

        customer = Customer(fname=fname,
                            lname=lname,
                            phone=phone,
                            emailid=emailid,
                            password=password)
        error_message = self.validateCustomer(customer)

        # saving
        if not error_message:

            print(fname, lname, phone, emailid, password)
            customer.password = make_password(customer.password)
            customer.register()
            return redirect('homepage')
        else:
            data = {'error': error_message, 'values': value}
            return render(request, 'signup.html', data)
Exemplo n.º 3
0
    def post(self, request):
        full_name = request.POST.get("name")
        phone = request.POST.get("c_number")
        email = request.POST.get("email")
        password = request.POST.get("password")

        customer = Customer(full_name=full_name,
                            phone=phone,
                            email=email,
                            password=password)

        values = {
            'name': full_name,
            'phone': phone,
            'email': email,
            'password': password
        }

        error = self.validateCustomer(customer)

        if not error:
            customer.password = make_password(customer.password)
            customer.register_customer()
            return redirect('homepage')
        else:
            data = {'error': error, 'values': values}
            return render(request, 'signuppage.html', data)
Exemplo n.º 4
0
    def post(self, request):
        email = request.POST.get("email")
        password = request.POST.get("password")
        customer = Customer.loginValidate(email)
        if customer:
            if check_password(password, customer.password):
                customer_data = serializers.serialize('json', [
                    customer,
                ])
                request.session['customer'] = customer_data
                if self.return_url:
                    return_url_temp = self.return_url
                    Loginform.return_url = ""
                    return HttpResponseRedirect(return_url_temp)
                else:
                    return redirect(
                        reverse("homepageloggedin",
                                kwargs={'name': customer.full_name}))

            else:
                data = {'error': "Invalid email or password", 'email': email}
            return render(request, 'loginpage.html', data)
        else:
            data = {'error': "Invalid email or password", 'email': email}
            return render(request, 'loginpage.html', data)
Exemplo n.º 5
0
    def post(self, request):
        # Login verification
        email = request.POST.get('email')
        password = request.POST.get('password')
        name = request.POST.get('first_name')
        customer = Customer.get_customer_by_email(email)
        print(request.POST)

        error_message = None
        if customer:
            request.session['customer'] = customer.id
            request.session['email'] = customer.email
            flag = check_password(password, customer.password)
            if flag:
                request.session['cart'] = {}
                if Login.return_url:
                    return HttpResponseRedirect(Login.return_url)
                else:
                    Login.return_url = None
                    return redirect('homepage')
            else:
                error_message = 'Email or Password Invalid..!'
        else:
            error_message = 'Email or Password Invalid..!'
        return render(request, 'login.html', {'error': error_message})
Exemplo n.º 6
0
    def post(self, request):
        post = request.POST
        first_name = post.get('firstname')
        last_name = post.get('lastname')
        phone = post.get('phone')
        email = post.get('email')
        password = post.get('password')

        value = {
            'first_name': first_name,
            'last_name': last_name,
            'phone': phone,
            'email': email
        }
        error_message = None
        customer = Customer(first_name=first_name,
                            last_name=last_name,
                            phone=phone,
                            email=email,
                            password=password)

        error_message = self.signup_validate(customer)

        # Saving
        if not error_message:
            print(first_name, last_name, phone, email, password)
            customer.password = make_password(customer.password)
            customer.register()
            return redirect('homepage')

        else:
            data = {
                'error': error_message,
                'values': value
            }
        return render(request, 'signup.html', data)
Exemplo n.º 7
0
    def post(self, request):
        emailid = request.POST.get('emailid')
        password = request.POST.get('password')
        customer = Customer.get_customer_by_email(emailid)
        error_message = None
        if customer:
            flag = check_password(password, customer.password)
            if flag:
                request.session['customer'] = customer.id

                if Login.return_url:
                    return HttpResponseRedirect(Login.return_url)
                else:
                    Login.return_url = None
                    return redirect('homepage')
            else:
                error_message = 'Email or Password Invalid!!'
            return render(request, 'login.html', {'error': error_message})
Exemplo n.º 8
0
    def post(self, request):
        address = request.POST.get('address')
        phone = request.POST.get('phone')
        customer = request.session.get('customer')
        cart = request.session.get('cart')
        products = Product.get_product_by_id(list(cart.keys()))

        for product in products:
            print(cart.get(str(product.id)))
            order = Order(customer=Customer(id=customer),
                          product=product,
                          price=product.price,
                          address=address,
                          phone=phone,
                          quantity=cart.get(str(product.id)))
            order.placeorder()

        request.session['cart'] = {}
        return redirect('cart')