Beispiel #1
0
def sign_up_form():
    if request.method == 'POST':
        email = request.form['Email']
        fName = request.form['FirstName']
        lName = request.form['LastName']
        DOB = request.form['DateOfBirth']
        psw = request.form['Password']
        now = datetime.now()

        checkCustomer = dbManager.fetch(
            'SELECT * FROM customers WHERE Email=%s ', (email, ))
        print(checkCustomer)
        if checkCustomer == []:
            maxID = dbManager.fetch(
                'SELECT max(ShoppingCartID) AS max FROM shopping_carts ')
            if maxID[0].max:
                ShoppingCartID = maxID[0].max + 1
            else:
                ShoppingCartID = 1
            dbManager.commit(
                'INSERT INTO customers VALUES (%s, %s,%s, %s, %s, %s, %s, %s, %s, %s)',
                (email, psw, fName, lName, DOB, '', '', 0, '', ''))
            db = dbManager.commit(
                'INSERT INTO shopping_carts VALUES (%s, %s, %s)',
                (ShoppingCartID, now, email))
            print(db)
            return redirect(url_for('sign_in.index'))
        else:
            return redirect('/sign_up?emailexist=true')
Beispiel #2
0
def yogurtOrder():
    if request.method == 'GET':
        maxID = dbManager.fetch('SELECT max(ProductID) AS max FROM products ')
        if maxID[0].max:
            productID = maxID[0].max + 1
        else:
            productID = 1
        ProductName = "יוגורט " + request.args['amount'] + " קילו"
        Amount = request.args['quantity']
        ShoppingCartID = session.get('ShoppingCartID')
        yogurt_tastes = request.args.getlist('yogurt_tastes')
        toppings_chosen = request.args.getlist('toppings_chosen')
        if len(yogurt_tastes) >= 1:
            rowProduct = dbManager.commit(
                'INSERT INTO products VALUES (%s,%s,%s,%s)',
                (productID, ProductName, Amount, ShoppingCartID))
            print(rowProduct)
            for i in range(len(yogurt_tastes)):
                rowBox = dbManager.commit(
                    'INSERT INTO box_flavours VALUES (%s,%s)',
                    (productID, yogurt_tastes[i]))
                print(rowBox)
        if len(toppings_chosen) >= 1:
            for i in range(len(toppings_chosen)):
                rowBoxTopping = dbManager.commit(
                    'INSERT INTO yogurtbox_toppings VALUES (%s,%s)',
                    (productID, toppings_chosen[i]))
                print(rowBoxTopping)
    return render_template('order.html', tab_name='yogurt')
Beispiel #3
0
 def createUser(self, username, passwd, passwd1, email):
     if passwd == passwd1:
         query = "INSERT INTO users (fullname, password, email) VALUES ('%s','%s', '%s')" % (
             username, passwd, email)
         dbManager.commit(query)
         return True
     return False
Beispiel #4
0
 def update_credit(self, credit_number, exp, cvv, email):
     """Updates and changes a credit data by the users' email"""
     sql = '''
             UPDATE credit SET credit_card_number = %s, expiration_date = %s, cvv = %s
             WHERE email_address = %s
           '''
     dbManager.commit(sql, (credit_number, exp, cvv, email))
     return
Beispiel #5
0
 def add_review(self):
     """ Add new review to data base"""
     sql = '''
             INSERT INTO review (review_number, date, `rank`, content, email_address, id)
             VALUES (%s, %s, %s, %s, %s, %s)
           '''
     dbManager.commit(sql, (self.review_number, self.date, self.rank,
                            self.content, self.email_address, self.id))
     return
Beispiel #6
0
 def add_product(self):
     """ Method that insert a new product to DB """
     sql = '''
         INSERT INTO product (id, name, price, description, img, category_code)
         VALUES (%s, %s, %s, %s, %s, %s)
         '''
     dbManager.commit(sql, (self.id, self.name, self.price,
                            self.description, self.img, self.category_code))
     return
Beispiel #7
0
 def update_category(self, category_code, category_name, img):
     """ Method that update an existing category by the category' code"""
     sql = '''  
                 UPDATE category SET category_code = %s, category_name = %s, img =%s
                 WHERE category_code = %s
           '''
     dbManager.commit(sql,
                      (category_code, category_name, img, category_code))
     return
Beispiel #8
0
 def add_category(self):
     """ Method that insert a new Category to DB """
     sql = '''
                 INSERT INTO category (category_code, category_name, img)
                 VALUES (%s, %s, %s)
           '''
     dbManager.commit(sql,
                      (self.category_code, self.category_name, self.img))
     return
Beispiel #9
0
def newuser():
    username = request.form['user']
    passwd = request.form['pass']
    passwd1 = request.form['pass1']
    email = request.form['email']
    if passwd == passwd1:
        dbManager.commit("INSERT INTO USERS (fullname, password, email) VALUES ('%s','%s', '%s')" % (username, passwd, email))
        return render_template('/login.html')
    return render_template('/login.html' )
Beispiel #10
0
 def add_credit(self):
     """If the user doesnt have a credit in the database
     this method will insert the credit data by the users' email"""
     sql = '''
             INSERT INTO credit (credit_card_number, expiration_date, cvv, email_address)
             VALUES (%s, %s, %s, %s)
           '''
     dbManager.commit(
         sql, (self.credit_number, self.exp, self.cvv, self.email_address))
     return
Beispiel #11
0
def index():
    if request.method == 'GET':
        return render_template('contact.html', contact=False)
    else:
        Name = request.form['contact_name']
        Email = request.form['contact_email']
        Text = request.form['contact_text']
        dbManager.commit('INSERT INTO contact VALUES (%s, %s, %s)',
                         (Name, Email, Text))
        return render_template('contact.html', contact=True)
Beispiel #12
0
 def update_product(self, name, price, prev_price, description, img,
                    category_code, given_id):
     """ Method that update an existing product by the products' current ID """
     sql = '''  
                 UPDATE product SET name = %s, price =%s, prev_price = %s,
                 description = %s, img = %s, category_code = %s
                 WHERE id = %s
           '''
     dbManager.commit(sql, (name, price, prev_price, description, img,
                            category_code, given_id))
     return
Beispiel #13
0
def index():
    if request.method == 'POST':
        if request.form.get('email'):
            dbManager.commit('UPDATE customer SET email=%s WHERE user_name=%s',
                             (request.form['email'], session['name']))
        if request.form.get('phone_number'):
            dbManager.commit(
                'UPDATE customer SET phone_number=%s WHERE user_name=%s',
                (request.form['phone_number'], session['name']))
        if request.form.get('street'):
            dbManager.commit(
                'UPDATE customer SET street=%s WHERE user_name=%s',
                (request.form['street'], session['name']))
        if request.form.get('st_number'):
            dbManager.commit(
                'UPDATE customer SET st_number=%s WHERE user_name=%s',
                (request.form['st_number'], session['name']))
        if request.form.get('city'):
            dbManager.commit('UPDATE customer SET city=%s WHERE user_name=%s',
                             (request.form['city'], session['name']))
    if session['logged-in']:
        if dbManager.fetch('SELECT * FROM private WHERE u_name=%s',
                           (session['name'], )):
            Private = True
            User_details = dbManager.fetch(
                'SELECT * FROM customer LEFT JOIN private ON user_name=u_name WHERE user_name=%s',
                (session['name'], ))
            Recommended_items = dbManager.fetch(
                'SELECT * FROM item JOIN item_department ON item_id=it_id WHERE department=%s ORDER BY price DESC, inventory_amount DESC LIMIT 3',
                ('private', ))
        else:
            Private = False
            User_details = dbManager.fetch(
                'SELECT * FROM customer LEFT JOIN business ON user_name=u_name WHERE user_name=%s',
                (session['name'], ))
            Recommended_items = dbManager.fetch(
                'SELECT * FROM item JOIN item_department ON item_id=it_id WHERE department=%s ORDER BY price DESC, inventory_amount DESC LIMIT 3',
                ('business', ))
        Purchased_items = dbManager.fetch(
            'SELECT * FROM customer_purchased JOIN item ON it_id=item_id WHERE u_name=%s',
            (session['name'], ))
        Customer_manager = dbManager.fetch(
            'SELECT * FROM customer JOIN employee ON customer_management_id=employee_id WHERE user_name=%s',
            (session['name'], ))
        return render_template('user.html',
                               user_details=User_details[0],
                               private=Private,
                               purchased_items=Purchased_items,
                               customer_manager=Customer_manager[0],
                               recommended_items=Recommended_items)
    else:
        return render_template('user.html')
Beispiel #14
0
 def update_customer(self, user, password, first_name, last_name, country,
                     city, street, number, phone_number, role, given_email):
     """ This Method Updates the data of a user, by the users' email address. """
     sql = '''  
                 UPDATE customer SET user = %s, password =%s, first_name = %s,
                 last_name = %s, country = %s, city = %s, street = %s, number = %s, phone_number = %s,
                 role = %s
                 WHERE email_address = %s
           '''
     dbManager.commit(sql,
                      (user, password, first_name, last_name, country, city,
                       street, number, phone_number, role, given_email))
     return
Beispiel #15
0
 def add_customer(self):
     """ Add new customer to data base"""
     # sql_z = ''' INSERT INTO zips (country, city, street, number, zip) VALUES (%s, %s, %s, %s, %s)'''
     sql_c = '''
             INSERT INTO customer (email_address, user, password, first_name, last_name, country, city, street,
                                   number, phone_number, role)
             VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
             '''
     # dbManager.commit(sql_z, (self.country, self.city, self.street, self.number, self.zip))
     dbManager.commit(
         sql_c, (self.email_address, self.user, self.password,
                 self.first_name, self.last_name, self.country, self.city,
                 self.street, self.number, self.phone_number, self.role))
     return
Beispiel #16
0
 def update_models_values(orders, user_name):
     counter_misses = 0
     for order in orders:
         query = "select %s as size_amount from models where makat= %s ;" % (
             order.size, order.makat)
         ans = db.fetch(query)
         if ans[0].size_amount - order.quantity >= 0:
             query = "update models set %s=(%s- %s) where makat = %s ;" % (
                 order.size, order.size, order.quantity, order.makat)
             db.commit(query)
             user.delete_cart(user_name, order.size, order.makat)
         else:
             counter_misses = counter_misses + 1
     return counter_misses
Beispiel #17
0
def index():
    if request.method == 'POST':
        maxID = dbManager.fetch('SELECT max(ContactID) AS max FROM contacts ')
        if maxID[0].max:
            contactID = maxID[0].max + 1
        else:
            contactID = 1
        Uname = request.form['full-name']
        Uphone = request.form['phone-number']
        message = request.form['message']
        dbManager.commit('insert into contacts values (%s, %s, %s,%s)',
                         (contactID, Uname, Uphone, message))
        return render_template('contact.html')
    elif request.method == 'GET':
        return render_template('contact.html')
Beispiel #18
0
 def update_address(self, country, city, street, number, email):
     """Method that updates the address of the user. by adding new row in 'zips' table
      and than changes the address in 'customer' table where its fit to the zips table."""
     # sql_1 = '''
     #             INSERT INTO zips (country, city, street, number)
     #             VALUES (%s, %s, %s, %s)
     #         '''
     sql_2 = '''
                 UPDATE customer SET country=%s, city=%s, street=%s, number=%s
                 WHERE email_address=%s
             '''
     # dbManager.commit(sql_1, (country, city, street, number))
     dbManager.commit(sql_2, (country, city, street, number, email))
     flash('Your address has successfully updated!')
     return
Beispiel #19
0
def insert_result():
    Personal_code = session['Personal_code']
    session['worker_id'] = request.form['worker_id']
    final_id = request.form['worker_id'] + "777BGU"
    session['final_id'] = final_id
    worker_id = session['worker_id']
    age = request.form['age']
    topic1 = session['topic1']
    topic2 = session['topic2']
    gender = request.form['Gender']
    Education_level = request.form['Education level']
    computer_use = request.form['computer use']
    mobile_use = request.form['mobile use']
    political_view = request.form['political view']
    device = request.form['device']
    place_size = request.form['place_size']
    level_of_privacy = request.form['level_of_privacy']
    level_of_confined_space = request.form['level_of_confined_space']
    level_of_noise = request.form['level_of_noise']
    level_of_light = request.form['level_of_light']
    level_of_croweded_env = request.form['level_of_croweded_env']

    query = dbManager.commit(
        'insert into facebook_users values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',
        (Personal_code, device, topic1, topic2, age, gender, Education_level,
         computer_use, mobile_use, political_view, place_size,
         level_of_privacy, level_of_confined_space, level_of_noise,
         level_of_light, level_of_croweded_env, worker_id))

    return redirect(url_for('finish_thanks.index'))
Beispiel #20
0
    def add_form(self):
        """ Add new feedback form to data base"""
        sql = '''
                INSERT INTO form (application_number, application_date, subject, content, status, email_address)
                VALUES (%s, %s, %s, %s, %s, %s)
              '''
        dbManager.commit(
            sql, (self.application_number, self.application_date, self.subject,
                  self.content, self.status, self.email_address))
        return


# class Manager:
#     def __init__(self):
#         pass
#
#     def get_tables_names(self):
#         table1 = 'Products'
#         table2 = 'Categories'
#         return
Beispiel #21
0
def insert_no_result():
    Personal_code = session['Personal_code']
    article_id1 = request.form['article_id']
    article_id = re.sub("[^0-9]", "", article_id1)
    now = datetime.now()
    article_order_number = session['question_num']

    query = dbManager.commit(
        'insert into facebook_results(Personal_code,article_id,question_order,insert_date) values (%s,%s,%s,%s)',
        (Personal_code, article_id, article_order_number, now))

    return redirect(url_for('page5.index'))
Beispiel #22
0
def index():
    if request.method == 'POST':
        item_data = dbManager.fetch(
            'SELECT * FROM item JOIN item_class ON item_id=id WHERE item_id=%s',
            (request.form['id'], ))
        if dbManager.fetch('SELECT * FROM cart WHERE it_id=%s and u_name=%s',
                           (request.form['id'], session['name'])):
            old_amount = dbManager.fetch(
                'SELECT amount FROM cart WHERE it_id=%s and u_name=%s',
                (request.form['id'], session['name']))
            amount = int(request.form['quantity']) + old_amount[0][0]
            dbManager.commit(
                'UPDATE cart SET amount=%s WHERE it_id=%s AND u_name=%s',
                (amount, item_data[0][0], session['name']))
        else:
            amount = request.form['quantity']
            dbManager.commit('INSERT INTO cart VALUES (%s, %s, %s)',
                             (session['name'], item_data[0][0], amount))
        user_cart_items = dbManager.fetch('SELECT * FROM cart WHERE u_name=%s',
                                          (session['name'], ))
        cart_amount = 0
        for item in user_cart_items:
            cart_amount += item[2]
        session['cart_amount'] = cart_amount
        purchase = True
        return render_template('product.html', purchase=purchase)
    else:
        item_data = dbManager.fetch(
            'SELECT * FROM item JOIN item_class ON item_id=id WHERE item_id=%s',
            (request.args['id'], ))
        item_class = item_data[0].item_class
        recommended_data = dbManager.fetch(
            'SELECT * FROM item JOIN item_class ON item_id=id WHERE item_class=%s AND item_id!=%s ORDER BY price DESC, inventory_amount DESC LIMIT 3',
            (item_class, request.args['id']))
        purchase = False
        return render_template('product.html',
                               current_item=item_data[0],
                               recommended_items=recommended_data,
                               purchase=purchase)
Beispiel #23
0
def cookieOrder():
    if request.method == 'GET':
        maxID = dbManager.fetch('SELECT max(ProductID) AS max FROM products ')
        if maxID[0].max:
            productID = maxID[0].max + 1
        else:
            productID = 1
        ProductName = "קוקילידה"
        Amount = request.args['quantity']
        ShoppingCartID = session.get('ShoppingCartID')
        cookie_chosen = request.args['cookie_chosen']
        cookie_filling = request.args['cookie_filling']
        if cookie_chosen and cookie_filling:
            rowProduct = dbManager.commit(
                'INSERT INTO products VALUES (%s,%s,%s,%s)',
                (productID, ProductName, Amount, ShoppingCartID))
            print(rowProduct)
            rowSanwich = dbManager.commit(
                'INSERT INTO icecream_sandwiches VALUES (%s,%s,%s)',
                (productID, cookie_chosen, cookie_filling))
            print(rowSanwich)
    return render_template('order.html', tab_name='cookie')
Beispiel #24
0
def index():
    if request.method == 'POST':
        maxID = dbManager.fetch('SELECT max(OfferID) AS max FROM occasion_offers ')
        if maxID[0].max:
            OfferID= maxID[0].max+1
        else:
            OfferID=1
        Uname = request.form['FullName']
        Uphone = request.form['PhoneNumber']
        insertData = dbManager.commit('insert into occasion_offers values (%s, %s, %s)', (OfferID, Uname,Uphone))
        if insertData:
            return render_template('events.html')
    elif request.method == 'GET':
        return render_template('events.html')
Beispiel #25
0
def iceCreamOrder():
    if request.method == 'GET':
        maxID = dbManager.fetch('SELECT max(ProductID) AS max FROM products ')
        if maxID[0].max:
            productID = maxID[0].max + 1
        else:
            productID = 1
        selectAmount = request.args['amount']
        ProductName = "גלידה " + selectAmount + " קילו"
        Amount = request.args['quantity']
        ShoppingCartID = session.get('ShoppingCartID')
        ice_cream_tastes = request.args.getlist('ice_cream_tastes')
        if len(ice_cream_tastes) >= 1:
            rowProduct = dbManager.commit(
                'INSERT INTO products VALUES (%s,%s,%s,%s)',
                (productID, ProductName, Amount, ShoppingCartID))
            print(rowProduct)
            for i in range(len(ice_cream_tastes)):
                rowBox = dbManager.commit(
                    'INSERT INTO box_flavours VALUES (%s,%s)',
                    (productID, ice_cream_tastes[i]))
                print(rowBox)
    return render_template('order.html', tab_name='icecream')
Beispiel #26
0
def index():
    if request.method == 'GET':
        return render_template('register.html', registered=False)
    else:
        User_name = request.form['user_name']
        Password = request.form['password']
        Email = request.form['email']
        Phone_number = request.form['phone_number']
        Cc_Number = request.form['cc_number']
        Validation_date = request.form['validation_date']
        Csv = request.form['csv']
        Street = request.form['street']
        St_number = request.form['st_number']
        City = request.form['city']
        Customer_managment_id = '10129438'
        dbManager.commit('INSERT INTO customer_cc VALUES (%s, %s, %s)',
                         (Cc_Number, Validation_date, Csv))
        dbManager.commit(
            'INSERT INTO customer VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)',
            (User_name, Password, Email, Phone_number, Cc_Number, Street,
             St_number, City, Customer_managment_id))
        if request.form["user_type"] == 'private':
            First_name = request.form['first_name']
            Last_name = request.form['last_name']
            dbManager.commit('INSERT INTO private VALUES (%s, %s, %s)',
                             (User_name, First_name, Last_name))
        else:
            Company_name = request.form['company_name']
            Contact_person = request.form['contact_person']
            Licence_number = request.form['licence_number']
            Business_type = request.form['business_type']
            dbManager.commit(
                'INSERT INTO business VALUES (%s, %s, %s, %s)',
                (User_name, Company_name, Contact_person, Licence_number))
            dbManager.commit('INSERT INTO business_type VALUES (%s, %s)',
                             (User_name, Business_type))
        return render_template('register.html', registered=True)
Beispiel #27
0
def insert_result():

    Personal_code = session['Personal_code']
    article_id = request.form['article_id']
    liked = request.form['liked']
    keep_reading = 0
    shared = request.form['shared']
    share_input = request.form['shared_input_to_db']
    now = datetime.now()
    print("now =", now)
    comment_input = request.form['comment_input_to_db']
    article_order_number = session['question_num']

    query = dbManager.commit(
        'insert into facebook_results values (%s,%s,%s,%s,%s,%s,%s,%s,%s)',
        (Personal_code, article_id, liked, article_order_number, keep_reading,
         shared, share_input, now, comment_input))
    return redirect(url_for('page5.index'))
Beispiel #28
0
def form():

    if request.method == 'POST':
        email = request.form['email']
        phone = request.form['phone']
        address_street = request.form['address-street']
        address_number = request.form['address-number']
        city = request.form['city']
        zip = request.form['zip']
        customer_update = dbManager.commit('UPDATE customers SET City=%s, Street=%s, StreetNumber=%s, ZipCode=%s, PhoneNumber=%s WHERE Email = %s', (city, address_street, address_number, zip, phone, email))
        id = request.form['id']
        card_number = request.form['cardnumber']
        cvv = request.form['cvv']
        exp_month = request.form['exp-month']
        exp_year = request.form['exp-year']
        comment = request.form['comment']
        ShoppingCartID = session.get('ShoppingCartID')
        Date = datetime.today().strftime('%y-%m-%d')
        totalPriceResult = dbManager.fetch('''SELECT SUM(Amount*Price) totalPrice FROM products_prices as pp JOIN products as p on pp.ProductName=p.ProductName where ShoppingCartID=%s;''', (ShoppingCartID,))
        totalPrice = totalPriceResult[0].totalPrice
        maxID = dbManager.fetch('SELECT max(OrderID) AS max FROM orders')
        if maxID[0].max :
            OrderID= maxID[0].max+1
        else:
            OrderID=1
        Order_table = dbManager.commit('INSERT into orders VALUES (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s)', (OrderID, id, card_number, cvv, exp_month, exp_year, comment, ShoppingCartID, Date, totalPrice))
        if Order_table:
            product_delete = dbManager.fetch('SELECT productID FROM products WHERE ShoppingCartID = %s', (ShoppingCartID,))
            if product_delete:
                for i in range(len(product_delete)):
                    row1 = dbManager.commit('DELETE from box_flavours where ProductID = %s', (product_delete[i].productID,))
                    row2 = dbManager.commit('DELETE from icecream_sandwiches where ProductID = %s', (product_delete[i].productID,))
                    row3 = dbManager.commit('DELETE from yogurtbox_toppings where ProductID = %s', (product_delete[i].productID,))
                    row4 = dbManager.commit('DELETE from products where ProductID = %s', (product_delete[i].productID,))
            return render_template('confirmOrder.html')
    elif request.method == 'GET':
        return render_template('payment.html')
Beispiel #29
0
 def newLead(self, name, phone, email):
     query = "INSERT INTO open_studio_submissions (fullname, phone, email) VALUES ('%s','%s', '%s')" % (
         name, phone, email)
     dbManager.commit(query)
     return True
Beispiel #30
0
 def createContact(self, firstname, lastname, phonenumber, email, msg):
     query = "INSERT INTO contact_us_submissions (firstname,lastname, phonenumber, email, massage) VALUES ('%s','%s', '%s','%s','%s')" % (
         firstname, lastname, phonenumber, email, msg)
     dbManager.commit(query)
     return True