Beispiel #1
0
    def post(self):
        logger = get_logger()
        data = request.form['id_to_delete']
        print(data)

        connection = con()

        if connection:
            try:
                delete(connection, data)
                import os
                path = os.path.dirname(os.path.abspath(__file__))
                path2 = "../static/images/image" + str(data) + '.jpeg'
                file = os.path.join(path, path2)
                os.remove(file)
                logger.debug(
                    "Images deleted successfully from local directory")
                return output_html(
                    render_template('response.html',
                                    message="Items Deleted succesfully"), 200)
            except Exception as e:
                return output_html(render_template("error.html", error=str(e)),
                                   200)
        else:
            return output_html(
                render_template("error.html", error="connection fail"), 200)
Beispiel #2
0
    def post(self):

        time = request.form['timezone']

        connection = con()
        time = time(time)

        if connection:
            try:
                result = SearchByCategory(connection, data)
                return output_html(
                    render_template('aftersearchbycategory.html', message="Items Searched  succesfully", result=result,time=time), 200)
            except Exception as e:
                return output_html(render_template("error.html", error=str(e)), 200)
        else:
            return output_html(render_template("error.html", error="connectionfail"), 200)
    def post(self):

        inventory_id = request.form['id']
        quantity = request.form['quantity']

        connection = con()

        if connection:
            try:
                update(connection, quantity, inventory_id)
                return output_html(
                    render_template('response.html',
                                    message="Item updated succesfully"), 200)
            except Exception as e:
                return output_html(render_template("error.html", error=str(e)),
                                   200)
        else:
            return output_html(
                render_template("error.html", error="connection fail"), 200)
    def post(self):
        file = open("application/common/data.txt", "r")
        id = file.read()

        name = request.form['name']
        category = request.form['category']
        extime = request.form['expirytime']
        quantity = request.form['quantity']
        mnftime = request.form['manufacturingtime']
        image = request.files['image']

        filename = "image" + str(id) + '.' + image.filename.rsplit(
            '.', 1)[1].lower()

        path = os.path.dirname(os.path.abspath(__file__))
        image.save(
            os.path.join(os.path.join(path, '../static/images/'), filename))
        image_path = os.path.join(os.path.join(path, '../static/images/'),
                                  filename)
        print("extime before conversion :", extime)
        extime = datetime1(extime)
        print("extime after conversion :", extime)
        mnftime = datetime1(mnftime)

        connection = con()

        if connection:
            try:
                insert(connection, name, extime, mnftime, image_path, quantity,
                       category)
                id = str(int(id) + 1)
                file = open("application/common/data.txt", "w")
                file.write(id)
                return output_html(
                    render_template('response.html',
                                    message="Item added succesfully" +
                                    image_path), 200)
            except Exception as e:
                return output_html(render_template("error.html", error=str(e)),
                                   200)
        else:
            return output_html(
                render_template("error.html", error="Connection fails"), 200)
    def post(self):
        data = request.form['itemname']
        timezone = request.form['timezone']

        connection = con()

        if connection:
            try:
                result = SearchByName(connection, data)
                ex_time = result[0]['extime']
                timezone = time(timezone, ex_time)
                return output_html(
                    render_template('aftersearchbyname.html',
                                    message="Items Searched  succesfully",
                                    data=result,
                                    timezone=timezone), 200)
            except Exception as e:
                return output_html(render_template("error.html", error=str(e)),
                                   200)
        else:
            return output_html(
                render_template("error.html", error="connectionfail"), 200)
    def get(self):
        connection = con()
        data = select(connection)

        return output_html(render_template('delete.html', data=data), 200)