Exemplo n.º 1
0
def newcustomer():
    if checkSession() == False: 
        return redirect('login')
    if request.form.get('fname') is None:
        c = customerList()
        c.set('fname','')
        c.set('lname','')
        c.set('email','')
        c.set('password','')
        c.set('subscribed','')
        c.add()
        return render_template('newcustomer.html', title='New Customer',  customer=c.data[0]) 
    else:
        c = customerList()
        c.set('fname',request.form.get('fname'))
        c.set('lname',request.form.get('lname'))
        c.set('email',request.form.get('email'))
        c.set('password',request.form.get('password'))
        c.set('subscribed',request.form.get('subscribed'))
        c.add()
        if c.verifyNew():
            c.insert()
            print(c.data)
            return render_template('savedcustomer.html', title='Customer Saved',  customer=c.data[0])
        else:
            return render_template('newcustomer.html', title='Customer Not Saved',  customer=c.data[0],msg=c.errorList)
Exemplo n.º 2
0
def savecustomer():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')
    elif session['user']['userType'] == 'customer':
        return redirect('login')

    c = customerList()
    c.set('id', request.form.get('id'))
    c.set('fname', request.form.get('fname'))
    c.set('lname', request.form.get('lname'))
    c.set('email', request.form.get('email'))
    c.set('password', request.form.get('password'))
    c.set('subscribed', request.form.get('subscribed'))
    c.add()
    if c.verifyNew():
        c.update()
        print(c.data)
        return render_template('customer/savedcustomer.html',
                               title='Customer Saved',
                               customer=c.data[0])
    else:
        return render_template('customer/newcustomer.html',
                               title='Customer Not Saved',
                               customer=c.data[0],
                               msg=c.errorList)
    print(c.data)
    #return ''
    return render_template('customer/savedcustomer.html',
                           title='Customer Saved',
                           customer=c.data[0])
Exemplo n.º 3
0
def login():
    '''
    -check login
    -set session
    -redirect menu
    --check session on login page
    '''
    if request.form.get('email') is not None and request.form.get(
            'password') is not None:
        c = customerList()
        if c.tryLogin(request.form.get('email'), request.form.get('password')):
            print('login ok')
            session['user'] = c.data[0]
            session['active'] = time.time()

            return redirect('main')
        else:
            print('login failed')
            return render_template('login.html',
                                   title='Login',
                                   msg='Incorrect username or password')
    else:
        if 'msg' not in session.keys() or session['msg'] is None:
            m = 'Type your email and password to continue.'
        else:
            m = session['msg']
            session['msg'] = None
        return render_template('login.html', title='Login', msg=m)
Exemplo n.º 4
0
def customers():
    if checkSession() == False: 
        return redirect('login')
    c = customerList()
    c.getAll()
    
    print(c.data)
    #return ''
    return render_template('customers.html', title='Customer List',  customers=c.data)
Exemplo n.º 5
0
def customers():
    c = customerList()
    c.getAll()

    print(c.data)
    #return ''
    return render_template('customers.html',
                           title='Customer List',
                           customers=c.data)
Exemplo n.º 6
0
def deletecustomer():
    if checkSession() == False: 
        return redirect('login')
    print("cid:",request.form.get('id')) 
    #return ''
    c = customerList()
    c.deleteById(request.form.get('id'))
    return render_template('confirmaction.html', title='Customer Deleted',  msg='Customer deleted.')
    '''
Exemplo n.º 7
0
def allCustomers():
    if checkSession() == False:  #check to make sure the user is logged in
        return redirect('login')
    c = customerList()
    c.getAll()
    print(c.data)
    #return ''
    return render_template('customers.html',
                           title='Customer List',
                           customers=c.data)
Exemplo n.º 8
0
def customers():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')
    elif session['user']['userType'] == 'customer':
        return redirect('login')
    c = customerList()
    c.getAll()

    print(c.data)
    #return ''
    return render_template('customer/customers.html',
                           title='Customer List',
                           customers=c.data)
Exemplo n.º 9
0
def customer():
    if checkSession() == False: 
        return redirect('login')
    c = customerList()
    if request.args.get(c.pk) is None:
        return render_template('error.html', msg='No customer id given.')  

    c.getById(request.args.get(c.pk))
    if len(c.data) <= 0:
        return render_template('error.html', msg='Customer not found.')  
    
    print(c.data)
    return render_template('customer.html', title='Customer ',  customer=c.data[0])  
Exemplo n.º 10
0
def customer():
    c = customerList()
    if request.args.get(c.pk) is None:
        return render_template('error.html', msg='No customer id given')

    c.getById(request.args.get(c.pk))
    if len(c.data) <= 0:
        return render_template('error.html', msg='Customer not found')

    print(c.data)
    #return ''
    return render_template('customer.html',
                           title='Customer',
                           customer=c.data[0])
Exemplo n.º 11
0
def savecustomer():
    c = customerList()
    c.set('id', request.form.get('id'))
    c.set('fname', request.form.get('fname'))
    c.set('lname', request.form.get('lname'))
    c.set('email', request.form.get('email'))
    c.set('password', request.form.get('password'))
    c.set('subscribed', request.form.get('subscribed'))
    c.add()
    c.update()
    print(c.data)
    #return ''
    return render_template('savedcustomer.html',
                           title='Customer Saved',
                           customer=c.data[0])
Exemplo n.º 12
0
def customersByID():
    if checkSession() == False:  #check to make sure the user is logged in
        return redirect('login')
    c = customerList()
    if request.args.get(c.pk) is None:
        return render_template('customersError.html',
                               msg='No Customer ID is given.')

    c.getByID(request.args.get(c.pk))
    if len(c.data) <= 0:
        return render_template('customersError.html',
                               msg='Customer ID does not exist')
    print(c.data)
    #return ''
    return render_template('customersByID.html',
                           title='Customer',
                           customer=c.data[0])
Exemplo n.º 13
0
def editCustomer():
    if checkSession() == False:  #check to make sure the user is logged in
        return redirect('login')
    c = customerList()
    c.set('id', request.form.get('id'))
    c.set('fname', request.form.get('fname'))
    c.set('lname', request.form.get('lname'))
    c.set('email', request.form.get('email'))
    c.set('password', request.form.get('password'))
    c.set('subscribed', request.form.get('subcribed'))
    c.add()
    c.update()
    print(c.data)
    #return ''
    return render_template('savedCustomer.html',
                           title='Customer Saved',
                           customer=c.data[0])
Exemplo n.º 14
0
def savecustomer():
    if checkSession() == False: 
        return redirect('login')
    c = customerList()
    c.set('id',request.form.get('id'))
    c.set('fname',request.form.get('fname'))
    c.set('lname',request.form.get('lname'))
    c.set('email',request.form.get('email'))
    c.set('password',request.form.get('password'))
    c.set('subscribed',request.form.get('subscribed'))
    c.add()
    if c.verifyChange():
        c.update()
        #print(c.data)
        #return ''
        return render_template('savedcustomer.html', title='Customer Saved',  customer=c.data[0])
    else:
        return render_template('customer.html', title='Customer Not Saved',  customer=c.data[0],msg=c.errorList)
Exemplo n.º 15
0
def savecustomer():
    if checkSession() == False:
        return redirect('login')
    c = customerList()
    c.set('UID', request.form.get('UID'))
    c.set('fname', request.form.get('fname'))
    c.set('lname', request.form.get('lname'))
    c.set('email', request.form.get('email'))
    c.set('address', request.form.get('address'))
    c.set('phonenumber', request.form.get('phonenumber'))
    c.set('password', request.form.get('password'))
    c.set('admin', request.form.get('admin'))
    c.add()
    c.update()
    print(c.data)
    #return ''
    return render_template('savedcustomer.html',
                           title='Customer Saved',
                           customer=c.data[0])
Exemplo n.º 16
0
def login():

    if request.form.get('email') is not None and request.form.get(
            'password') is not None:
        c = customerList()
        if c.tryLogin(request.form.get('email'), request.form.get('password')):
            print("Login Ok")
            session['user'] = c.data[0]
            session['active'] = time.time()

            return redirect('main')
        else:
            print("Login Failed...!!!")
            return render_template('login.html',
                                   title='Login',
                                   msg='Incorrect Username or Password...!!!')
    else:
        #if 'msg' not in session.keys():
        if 'msg' not in session.keys() or session['msg'] is None:
            m = 'Type your email and password to continue.'
        else:
            m = session['msg']
            session['msg'] = None
        return render_template('login.html', title='Login', msg=m)
Exemplo n.º 17
0
from customer import customerList

c = customerList()

for fn in c.fnl:
    var = input("Enter " + fn + "\n")
    c.set(fn, var)
c.add()
c.insert()
print(c.data)
Exemplo n.º 18
0
 def __init__(self, name, defPIN, defBalance, randomCustomerCard):
     self.name = name
     self.defPIN = defPIN
     self.defBalance = defBalance
     self.randomCustomerCard = randomCustomerCard
     customerList(self.name, self.defPIN, self.defBalance, self.randomCustomerCard)
Exemplo n.º 19
0
from customer import customerList
import time

cl = customerList()

print(cl.fnl)
print(cl.pk)

c = customerList()
c.set('fname', 'Testguy')
c.set('lname', 'Test')
c.set('email', '*****@*****.**')
c.set('subscribed', 'True')
c.set('password', '12345')
c.add()
# A - show the mysql table

c.insert()

c = customerList()
c.getAll()
print(c.data)
Exemplo n.º 20
0
from customer import customerList

cl = customerList()  #instance of a customerList class

cl.set('fname', 'Testguy')
cl.set('lname', 'Test')
cl.set('email', '*****@*****.**')
cl.set('password', '12345')
cl.set('subscribed', 'True')
cl.add()

#cl.update(0,'email','*****@*****.**')

#print(cl.data[0])
# cl.delete()
# print(cl.data)
cl.deleteByID(cl.data[1]['id'])
#cl.insert()
'''
# d = {'fname':'Testguy','lname':'test','email':'*****@*****.**','password':'******','subscribed':'1'}

# cl.add(d) #could call add on an integer even and add it to the list, check to make sure it's a dictionary and that item in customer.py has data in it with right structure (dict) make sure names of keys match in all files. 

cl.set('fname','Testguy')
cl.set('lname','Test')
cl.set('lastname','Test')
cl.set('email','*****@*****.**')
cl.set('password','12345')
cl.set('subscribed','True')
cl.add()
# cl.add()