def view():
    # return stores based on category
    # print(request.args)
    # categories = request.args['categories']
    categories = system.getCategories()
    if request.method == "POST":

        if "a" in request.form:
            if request.form["a"] == "main":
                company = []
                print(system.user)
                # for u in system.user:
                #     if u.id == 1:
                u = system.user[0]
                company = u.retrieveCompany("all")
                return redirect(url_for('view'))
            if request.form["a"] == "receipt":
                return redirect(url_for('receipt', receipt="receipt1"))
        elif "b" in request.form:
            return redirect(url_for('store', name=request.form["b"]))
        elif "choice" in request.form and (request.form["c"] != "all"):
            # print(request.form["c"])
            cat = request.form["c"]
            u = system.user[0]
            company = u.retrieveCompany(cat)
            print(company)
            return render_template("home/main.html",
                                   categories=categories,
                                   company=company)

        else:
            print("hello----")
            for c in system.getCategories():
                if c in request.form:
                    for u in system.user:
                        if u.id == 1:
                            company = u.retrieveCompany(c)
                else:
                    # render_template("home/main.html" company=company)
                    for u in system.user:
                        if u.id == 1:
                            company = u.retrieveCompany("all")
                            for name in company:
                                if name in request.form:
                                    return redirect(url_for('store',
                                                            name=name))
    company = []
    # print(system.user)
    # for u in system.user:
    #     if u.id == 1:
    u = system.user[0]
    company = u.retrieveCompany("all")
    return render_template("home/main.html",
                           categories=categories,
                           company=company)
示例#2
0
def save(company, id):
    # system.user_receipt('sample.json', 1)
    if request.method == "POST":
        if "save_receipt" in request.form:
            if request.form["save_receipt"] == True:
                saved = system.user_receipt('sample.json',
                                            1)  # hardcoded! returns boolean
                # do some error handling here for when the receipt does not belong
                # to the same user
    return redirect(url_for('view', categories=system.getCategories()))
def home():
    # bunch of redirects here depending on what the the user chooses to see or do
    if request.method == "POST":
        if "start" in request.form:
            categories = system.getCategories()
            # request.args['categories'] = categories
            return redirect(url_for('view'))

    # new_receipt = Receipt()
    # new_receipt.createReceipt("sample.json")
    saved = system.user_receipt('sample.json', 1)
    saved = system.user_receipt('sample2.json', 1)

    return render_template('home/index.html')
示例#4
0
def view(categories):
    # return stores based on category
    if request.method == "POST":
        for c in system.getCategories():
            if c in request.form:
                for u in system._user:
                    if u.id == 1:
                        company = u.retrieveCompany(c)
                else:
                    # render_template("home/main.html" company=company)
                    for u in system._user:
                        if u.id == 1:
                            company = u.retrieveCompany("all")
                            for name in company:
                                if name in request.form:
                                    return redirect(url_for('store',
                                                            name=name))
    company = []
    for u in system._user:
        if u.id == 1:
            company = u.retrieveCompany("all")
            return render_template("home/main.html",
                                   categories=categories,
                                   company=company)
示例#5
0
def home():
    # bunch of redirects here depending on what the the user chooses to see or do
    if request.method == "POST":
        if "start" in request.form:
            return redirect(url_for('view', categories=system.getCategories()))
    return render_template('home/index.html')
示例#6
0
def home():
    system = updateSystem()
    categories = system.getCategories()
    bestOfCategories = system.getBestOfCategories()
    return render_template('home.html', categories=categories, bestOfCategories=bestOfCategories)