#!/usr/bin/python3

from python.webpage_functions import print_html, get_form_data, has_form_data, print_main, get_user, set_cookie
from python.htmlGenerators import viewProducts, nav
from python.password import Password
from python.login import tryLogIn

# Either show login page or landing page
if not get_user().logged_in:
    if has_form_data():
        # Page loading with incoming form data
        # Try to log in with the data
        login_id, password = get_form_data("id"), Password(get_form_data("password"))
        logInCookie = tryLogIn(login_id, password)
        if logInCookie:
            # successful
            set_cookie(logInCookie)
            # print the main dashboard
            print_main(viewProducts.create_table_of_locations())
        else:
            # unsuccessful - print login page with error message
            print_html('login.html')  #### Error message?
    else:
        # No data - Print log in page
        print_html('login.html')

else:
    print_main(viewProducts.create_table_of_locations())
#!/usr/bin/python3

from python.webpage_functions import print_html, get_form_data, has_form_data
from python.databases.databaseQueries import select_all_with_conditions
from python.htmlGenerators.qrElement import create_qr_info

if has_form_data():
    if get_form_data('id'):
        lid = get_form_data('id')
        info = select_all_with_conditions('products', 'id', lid)[0]
        print_html('print_qr.html', dict(title=info['title'], qrcode=create_qr_info(int(lid))))

    else:
        print_html('404.html')
else:
    print_html('404.html')
Beispiel #3
0
#!/usr/bin/python3

from python.webpage_functions import print_html
from python.password import Password
from python.login import logOut

logOut()
print_html('redirect.html', dict(url='/index.py'))
#!/usr/bin/python3

from python.webpage_functions import print_html, get_form_data, has_form_data, print_main, get_user
from python.password import Password
from python.login import register


if not get_user().logged_in:
    if has_form_data():
        # collect data
        fname, lname, email, pword = get_form_data("fname"), get_form_data("lname"), get_form_data("email"), Password(get_form_data("pword"))
        #send to db
        registered = register(email, str(pword), fname, lname)
        print(registered)
        # check if successfully registered
        if registered:
            ## Print "successfully registered" page
            print_html('redirect.html', dict(url='/index.py'))
        else:
            # print signup page
            #### preferably with error message
            print_html("signup.html")
    else:
        print_html("signup.html")
else:
    print_html('redirect.html', dict(url='/index.py'))