Exemplo n.º 1
0
def sample():
    if ('username' in session):
        username2 = session['username']
        return render_template("sample.html",
                               orderid=db.get_id(),
                               username2=username2)
    else:
        return render_template("sample.html", orderid=db.get_id())
Exemplo n.º 2
0
def placeorder(orderid2):
    if (orderid2 == None):
        flash("invalid page")
        return redirect("/")
    if ('username' not in session or session ['username'] == None):
        flash ("You are not logged in")
        return redirect ("/")
    global orderid
    submit = request.args.get("submit")
    if (submit == "Submit"):
        username = session ['username']
        store = request.args.get("store")
        food = request.args.get("food")
        instructions = request.args.get("instructions")
        try:
            cost = float(request.args.get("cost"))
            offer = float(request.args.get("offer"))
            period1 = int(request.args.get("period1"))
            period2 = int(request.args.get("period2"))
        except:
            flash("Order incomplete. Cost, Offer, and periods must all be numbers.")
            return redirect ("/placeorder/" + str(db.get_id()))
        if (username == "" or store == "" or food == "" or cost == 0 or offer == 0 or period1 == 0 or period2 == 0 or (period1 < 1 or period1 > 10) or (period2 < 1 or period2 > 10) or instructions == ""):
            if (offer == 0):
                flash ("Be Generous. Tip More than $0")
            flash("Order incomplete. Field Not filled, Period less than 0 or greater than 10 and/or Offer or Cost = 0")
            return redirect ("/placeorder/" + str(db.get_id()))
        else:
            try:
                db.order_creat(orderid, username, store, food, cost, offer, period1, period2, instructions)
            except: 
                flash("Invalid Format. Do not Use special characters")
                return redirect ("/placeorder/" + str(db.get_id()))
            
            db.up_id()

            username = ""
            store = ""
            food = ""
            cost = 0
            offer = 0
            period1 = 0 
            period2 = 0
            instructions = "" 
            return redirect ("/success/" + str(db.get_id() - 1))
    if ('username' in session):
        username2 = session ['username']
        data = {'username':username2}
        return render_template ("orders.html", username2 = username2, data = data, orderid = db.get_id() );
    else:
        return render_template ("/login")
Exemplo n.º 3
0
def index():
    global orderid
    global orders2
    print (orders2)
    if(request.method=="POST"):
        submit = request.form["submit"]
        if (submit == "Search"):
            return redirect("/results")
    if ('username' not in session or session.get('username') == None):
        loggedin = False
        return render_template ("index.html", orders2 = orders2, orderid = db.get_id(), loggedin = loggedin)
    else:
        loggedin = True
        username2 = session.get('username')
        print(orders2)
        return render_template ("index.html", orders2 = orders2, orderid = db.get_id(), loggedin = loggedin, username2 = username2)
Exemplo n.º 4
0
def success(orderid):
    if (orderid == None or orderid == "" or not (orderid <= db.get_id())):
        flash("invalid page")
        return redirect("/")
    if ('username' in session):
        username2 = session ['username']
        data = []
        data.append (username2)
    else:
        username2 = ""
    return render_template ("success.html", username2 = username2, data = data, orderid = orderid)
Exemplo n.º 5
0
def index():
    global orderid
    global orders2
    print(orders2)
    if (request.method == "POST"):
        submit = request.form["submit"]
        if (submit == "Search"):
            return redirect("/results")
    if ('username' not in session or session.get('username') == None):
        loggedin = False
        return render_template("index.html",
                               orders2=orders2,
                               orderid=db.get_id(),
                               loggedin=loggedin)
    else:
        loggedin = True
        username2 = session.get('username')
        print(orders2)
        return render_template("index.html",
                               orders2=orders2,
                               orderid=db.get_id(),
                               loggedin=loggedin,
                               username2=username2)
Exemplo n.º 6
0
def success(orderid):
    if (orderid == None or orderid == "" or not (orderid <= db.get_id())):
        flash("invalid page")
        return redirect("/")
    if ('username' in session):
        username2 = session['username']
        data = []
        data.append(username2)
    else:
        username2 = ""
    return render_template("success.html",
                           username2=username2,
                           data=data,
                           orderid=orderid)
Exemplo n.º 7
0
def placeorder(orderid2):
    if (orderid2 == None):
        flash("invalid page")
        return redirect("/")
    if ('username' not in session or session['username'] == None):
        flash("You are not logged in")
        return redirect("/")
    global orderid
    submit = request.args.get("submit")
    if (submit == "Submit"):
        username = session['username']
        store = request.args.get("store")
        food = request.args.get("food")
        instructions = request.args.get("instructions")
        try:
            cost = float(request.args.get("cost"))
            offer = float(request.args.get("offer"))
            period1 = int(request.args.get("period1"))
            period2 = int(request.args.get("period2"))
        except:
            flash(
                "Order incomplete. Cost, Offer, and periods must all be numbers."
            )
            return redirect("/placeorder/" + str(db.get_id()))
        if (username == "" or store == "" or food == "" or cost == 0
                or offer == 0 or period1 == 0 or period2 == 0
                or (period1 < 1 or period1 > 10)
                or (period2 < 1 or period2 > 10) or instructions == ""):
            if (offer == 0):
                flash("Be Generous. Tip More than $0")
            flash(
                "Order incomplete. Field Not filled, Period less than 0 or greater than 10 and/or Offer or Cost = 0"
            )
            return redirect("/placeorder/" + str(db.get_id()))
        else:
            try:
                db.order_creat(orderid, username, store, food, cost, offer,
                               period1, period2, instructions)
            except:
                flash("Invalid Format. Do not Use special characters")
                return redirect("/placeorder/" + str(db.get_id()))

            db.up_id()

            username = ""
            store = ""
            food = ""
            cost = 0
            offer = 0
            period1 = 0
            period2 = 0
            instructions = ""
            return redirect("/success/" + str(db.get_id() - 1))
    if ('username' in session):
        username2 = session['username']
        data = {'username': username2}
        return render_template("orders.html",
                               username2=username2,
                               data=data,
                               orderid=db.get_id())
    else:
        return render_template("/login")
Exemplo n.º 8
0
from flask import Flask, request, url_for, redirect, render_template, flash, session
import json, urllib2
from functools import wraps
import db_helper as db
import yelp

app = Flask(__name__)
app.config['SECRET_KEY'] = "secret key"

app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

orderid = db.get_id()
id = 0
orders2 = []


def search(func):
    @wraps(func)
    def inner(*args, **kwargs):
        global orders2
        select = request.args.get("select")
        search = request.args.get("search")
        searchsubmit = request.args.get("searchsubmit")
        if ('username' in session and session.get('username') != None):
            loggedin = True
            username2 = session['username']
        else:
            loggedin = False
        if (searchsubmit == "Search" and search != ""):
            if (select == "Period"):
                try:
Exemplo n.º 9
0
def sample ():
    if ('username' in session):
        username2 = session ['username']
        return render_template("sample.html", orderid = db.get_id(), username2 = username2)
    else:
       return render_template("sample.html", orderid = db.get_id())
Exemplo n.º 10
0
from flask import Flask,request,url_for,redirect,render_template, flash, session
import json, urllib2
from functools import wraps
import db_helper as db
import yelp


app=Flask(__name__)
app.config['SECRET_KEY'] = "secret key"

app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

orderid = db.get_id()
id = 0
orders2 = []

def search(func):
    @wraps(func)
    def inner(*args,**kwargs):
        global orders2
        select = request.args.get("select")
        search = request.args.get("search")
        searchsubmit = request.args.get("searchsubmit")
        if ('username' in session and session.get('username') != None):
            loggedin = True
            username2 = session['username'];
        else:
            loggedin = False
        if(searchsubmit == "Search" and search != ""):
            if (select == "Period"):
                try: