def assembleProducts(): """Assemble parts to generate products and store them in warehouse""" product_id = request.form['product_id'] class_ = request.form['class'] price = request.form['price'] part_id = request.form['part_id'] warehouse_id = request.form['warehouse_id'] sql = SQL_Server() SF = sql.assembleProducts(product_id, class_, price, part_id, warehouse_id) table = 'ASSEMBLE' attribute = '*' results = sql.selectFromTable(table, attribute) attributeList = sql.getAttributeListForSelectShow(table, attribute) if len(results) != 0: col = len(results[0]) else: col = 0 return render_template('assemble_products_result.html', table=table, attributeList=attributeList, results=results, attribute=attribute, row=len(results), col=col, SF=SF)
def produceParts(): """Workshops produce parts and store them in warehouses""" part_id = request.form['part_id'] weight = request.form['weight'] price = request.form['price'] warehouse_id = request.form['warehouse_id'] workshop_id = request.form['workshop_id'] sql = SQL_Server() SF = sql.produceParts(part_id, weight, price, warehouse_id, workshop_id) table = 'MAKE' attribute = '*' results = sql.selectFromTable(table, attribute) attributeList = sql.getAttributeListForSelectShow(table, attribute) if len(results) != 0: col = len(results[0]) else: col = 0 return render_template('produce_parts_result.html', table=table, attributeList=attributeList, results=results, attribute=attribute, row=len(results), col=col, SF=SF)
def dropPanel(): """detect the table which is to be inserted""" table = request.form['table'] sql = SQL_Server() # detect if the table is in db if not sql.tableDetect(table): # exceptions.BadRequestKeyError here return redirect('/developer') SF = sql.dropTable(table) return render_template('developer_drop.html', table=table, SF=SF)
def registerResult(): """show register result""" username = request.form['username'] password = request.form['password'] address = request.form['address'] sql = SQL_Server() # try to insert (username, password) into USERTABLE result = sql.register(username, password, address) return render_template('register_result.html', username=username, password=password, result=result)
def selectPanel(): """detect the table which is to be selected""" global table table = request.form['table'] sql = SQL_Server() # detect if the table is in db if not sql.tableDetect(table): # exceptions.BadRequestKeyError here return redirect('/developer') attributeList = sql.getAttributeListOfTable(table) return render_template('developer_select.html', table=table, attributeList=attributeList, attributeLen=len(attributeList))
def checkState(): """Check the number of workers, warehouses, workshops, parts and products in each factory""" sql = SQL_Server() results = sql.checkState() row = len(results) col = len(results[0]) attributeList = [ 'factory_name', 'worker_num', 'warehouse_num', 'workshop_num', 'part_num', 'product_num' ] return render_template('state.html', attributeList=attributeList, results=results, row=row, col=col)
def userSelectResult(): """show select option result""" global table attribute = request.form['attribute'] sql = SQL_Server() results = sql.selectFromTable(table, attribute) attributeList = sql.getAttributeListForSelectShow(table, attribute) if len(results) != 0: col = len(results[0]) else: col = 0 return render_template('user_select_result.html', table=table, attributeList=attributeList, results=results, attribute=attribute, row=len(results), col=col)
def role(): """developer or user""" global username, password username = request.form['username'] password = request.form['password'] sql = SQL_Server() if not sql.loginDetect(username, password): return redirect('/login') if not sql.ifManager(username, password): sql = SQL_Server() sql.getTableList() sql.getAttributeList() tableList = sql.tableList attributeList = sql.attributeList return render_template('user.html', user=username, tableList=tableList, attributeList=attributeList, tableLen=len(tableList)) return render_template('role.html', user=username)
def userInsertResult(): """show result after insertion""" global table attribute = '*' sql = SQL_Server() insertSQL = request.form['insertSQL'] # do insertion SF = sql.insertIntoTable(table, insertSQL) results = sql.selectFromTable(table, attribute) attributeList = sql.getAttributeListForSelectShow(table, attribute) if len(results) != 0: col = len(results[0]) else: col = 0 return render_template('user_insert_result.html', table=table, attributeList=attributeList, results=results, attribute=attribute, row=len(results), col=col, SF=SF)
def deleteResult(): """show result after deletion""" global table attribute = '*' sql = SQL_Server() deleteSQL = request.form['deleteSQL'] # do deletion SF = sql.deleteFromUserTable(table, deleteSQL) results = sql.selectFromTable(table, attribute) attributeList = sql.getAttributeListForSelectShow(table, attribute) if len(results) != 0: col = len(results[0]) else: col = 0 return render_template('developer_delete_result.html', table=table, attributeList=attributeList, results=results, attribute=attribute, row=len(results), col=col, SF=SF)
def updateResult(): """show result after insertion""" global table attribute = '*' sql = SQL_Server() updateSQL = request.form['updateSQL'] pending = request.form['pending'] # do insertion SF = sql.updateTable(table, updateSQL, pending) results = sql.selectFromTable(table, attribute) attributeList = sql.getAttributeListForSelectShow(table, attribute) if len(results) != 0: col = len(results[0]) else: col = 0 return render_template('developer_update_result.html', table=table, attributeList=attributeList, results=results, attribute=attribute, row=len(results), col=col, SF=SF)
def userInsertPanel(): """detect the table which is to be inserted""" global table table = request.form['table'] sql = SQL_Server() # detect if the table is in db if not sql.tableDetect(table): # exceptions.BadRequestKeyError here return redirect('/developer') attribute = '*' results = sql.selectFromTable(table, attribute) attributeList = sql.getAttributeListOfTable(table) if len(results) != 0: col = len(results[0]) else: col = 0 return render_template('user_insert.html', table=table, attributeList=attributeList, results=results, attribute=attribute, row=len(results), col=col, attributeLen=len(attributeList))
def userPanel(): global username, password sql = SQL_Server() sql.getTableList() sql.getAttributeList() tableList = sql.tableList attributeList = sql.attributeList return render_template('user.html', user=username, tableList=tableList, attributeList=attributeList, tableLen=len(tableList))
def developerPanel(): """detect developer's password""" # if (username password) not correct global username, password sql = SQL_Server() sql.getTableList() sql.getAttributeList() tableList = sql.tableList attributeList = sql.attributeList # else login succeed return render_template('developer.html', user=username, tableList=tableList, attributeList=attributeList, tableLen=len(tableList))