def addNewEmp(): add = "新規追加" image_id = "" #画像ID作成 for _ in range(10): image_id += (random.choice(string.ascii_letters)) emp_name, emp_age, emp_sex, emp_postal, emp_pref, emp_address, emp_dept, join_date, retire_date, emp_image = getEmpInfo( ) add_emp_image, emp_image = imageSetVariable(emp_image) cursor, cnx = db.connect() dept_info = db.deptInfoData(cursor) info_add, img_add = db.createAddEmpQuery(emp_name, emp_age, emp_sex, emp_postal, emp_pref, emp_address, emp_dept, join_date, retire_date, image_id, add_emp_image) judge, result = db.exeAddEmpQuery(cursor, cnx, emp_name, emp_age, emp_sex, emp_postal, emp_pref, emp_address, emp_dept, join_date, retire_date, image_id, add_emp_image, emp_image, info_add, img_add) return render_template("emp_add.html", add=add, judge=judge, result=result, dept_info=dept_info)
def outputCsv(): cursor, _ = db.connect() csv = db.downloads(cursor) response = make_response(csv) response.headers[ "Content-Disposition"] = f"attachment; filename=employee_information.csv" return response
def deleteEmp(): delete_info, emp_name = getDeleteEmpInfo() cursor, cnx = db.connect() info_delete, img_delete = db.createDeleteEmpQuery(delete_info) emp_info = db.empInfoData() message, emp_info = db.exeDeleteEmpQuery(cursor, cnx, info_delete, img_delete, delete_info, emp_name, exist_info) return render_template("all_emp.html", emp_info=emp_info, message=message)
def searchEmp(): search_dept, search_emp_id, search_name = getSearchEmpInfo() cursor, _ = db.connect() dept_info = db.deptInfoData(cursor) query = db.createSearchQuery(search_dept, search_emp_id, search_name) emp_info, emp_count = db.exeSearchEmpQuery(cursor, query) params = correctSearchEmpValue(search_name, search_emp_id, search_dept, dept_info, emp_info, emp_count) return render_template("emp_search.html", **params)
def deleteDept(): delete_info, dept_name = getDeleteDeptInfo() cursor, cnx = db.connect() dept_info = db.deptInfoData(cursor) dept_delete = db.createDeleteDeptQuery(delete_info) message, dept_info = db.exeDeleteDeptQuery(cursor, cnx, delete_info, dept_name, dept_delete, exist_info, dept_info) return render_template("all_dept.html", dept_info=dept_info, message=message)
def editDept(): dept_name, change_info = getChangeDeptInfo() cursor, cnx = db.connect() dept_update = db.createEditDeptQuery(change_info, dept_name) judge, result = db.exeEditDeptQuery(cursor, cnx, change_info, dept_name, dept_update) return render_template("dept_add.html", judge=judge, result=result, change_info=change_info, dept_name=dept_name)
def addNewDept(): add, dept_name = getAddDeptInfo() cursor, cnx = db.connect() dept_info = db.deptInfoData(cursor) dept_add = db.createAddDeptQuery(dept_name) judge, result = db.exeAddDeptQuery(cursor, cnx, dept_name, dept_add) return render_template("dept_add.html", add=add, judge=judge, result=result, dept_info=dept_info)
def editEmp(): image_id = request.form.get("image_id", "") change_info = request.form.get("change_info", "") emp_name, emp_age, emp_sex, emp_postal, emp_pref, emp_address, emp_dept, join_date, retire_date, emp_image = getEmpInfo( ) add_emp_image, emp_image = imageSetVariable(emp_image) cursor, cnx = db.connect() dept_info = db.deptInfoData(cursor) edit_info, dept_select, pref_select = db.getEditEmpinfo( cursor, change_info) info_update, img_update = db.createEditEmpQuery( change_info, emp_name, emp_age, emp_sex, emp_postal, emp_pref, emp_address, emp_dept, join_date, retire_date, image_id, add_emp_image) judge, result = db.exeEditQuery(cursor, cnx, emp_name, emp_age, emp_sex, emp_postal, emp_pref, emp_address, emp_dept, join_date, retire_date, image_id, add_emp_image, emp_image, info_update, img_update) params = correctEditValue(pref_select, dept_select, dept_info, edit_info, judge, result) return render_template("emp_add.html", **params)
def deptList(): cursor, _ = db.connect() dept_info = db.deptInfoData(cursor) return render_template("all_dept.html", dept_info=dept_info)
def setup(self): database.connect()
#!/usr/bin/env python import nose import os from model import database os.environ['APP_ENVIRONMENT'] = 'testing' args = ['tests', '--with-spec', '--spec-color', '--nologcapture'] database.connect() nose.run(argv=args)
def setup_database(): database.connect() database.create_tables([Star])