def make_district_managers(): """ Adds district managers to the employee table. """ d01 = Employee(emp_id='11111', fname='Nidhi', lname='Sharma', ssn=fake.ssn(), password='******', store_id='999', pos_id='10-DM') d02 = Employee(emp_id='22222', fname='Erin', lname='Cusick', ssn=fake.ssn(), password='******', store_id='999', pos_id='10-DM') d03 = Employee(emp_id='33333', fname='Anjou', lname='Ahlborn-Kay', ssn=fake.ssn(), password='******', store_id='999', pos_id='10-DM') d04 = Employee(emp_id='44444', fname='Courtney', lname='Cohan', ssn=fake.ssn(), password='******', store_id='999', pos_id='10-DM') d05 = Employee(emp_id='55555', fname='Kourtney', lname='Young', ssn=fake.ssn(), password='******', store_id='999', pos_id='10-DM') db.session.add_all([d01, d02, d03, d04, d05]) db.session.commit()
def deleteEmployee(name): emp = Employee.findEmployeeByName(name) if emp == 0: return "Employee Not Found" emp = Employee.findEmployeeByName("Mujtaba") Employee.deleteEmployee(emp) return "Employee Deleted, Database Updated"
def createNewEmployee(): print("Input Information : ") Employee.createEmployee( input("EmpployeeID : "), input('FirstName: ') , input('LastName: '), input("Gender: "), input( 'HiredDate: '), input('Salary: ') ) print() print("New Employee Created") return
def make_emps(): """ Make fake users and load into database. """ print 'Making Employees...' # Since I like to run this file over and over again: Employee.query.delete() # QUESTION: Hm, how do I solve for duplicates, though? *scratches head* for emp in range(1,301): emp_id = "{:0>5}".format(emp) # emp_id is 5 digits long fname = fake.first_name() lname = fake.last_name() ssn = fake.ssn() password = '******' # '{}{}'.format((ssn[-4:]), (lname[0])) store_id = get_random_store() if mgmt_position[store_id] == []: pos_id = '03-SS' else: pos_id = mgmt_position[store_id].pop() # Instantiate an employee using class in model.py emp = Employee(emp_id=emp_id, fname=fname, lname=lname, ssn=ssn, password=password, store_id=store_id, pos_id=pos_id) # Add employee to db db.session.add(emp) db.session.commit()
def updateSalary(name, salary): emp = Employee.findEmployeeByName(name) if emp == 0: return "Employee Not Found" emp.updateSalary(salary) emp.viewEmployee() return "Salary Updated"
def change_info_user_employees(self): Employee_Num = View.get_data('Employee_Num') Employee_Name = View.get_data('Employee_Name') User_User_Num = View.get_data('User_User_Num') employee = Employee.Change_user_employee(Employee_Num, Employee_Name, User_User_Num) return View.change_info_users(employee)
def get(self): out = '\n' for emp in Employee.query().fetch(): out += unicode( emp.firstname ) + ' ' + unicode( emp.lastname ) + '\n' + \ ' http://stromcekakodarcek.appspot.com/?key=' + emp.key.urlsafe() + '\n'; logging.info(out); self.abort(404)
def create_employee(ename, egender, edob, esalary, ephno): employee = Employee(employee_name=ename, employee_gender=egender, employee_dob=edob, employee_salary=esalary, employee_phno=ephno) session.add(employee) session.commit()
def load(self, filename): lst = [] self.fo = open(filename, "a+") self.fo.seek(0, os.SEEK_SET) line = self.fo.readline() while line != '': name, age, city = line.split(',') lst.append(Employee(name=name, age=int(age), city=city[:-1])) line = self.fo.readline() self.fo.seek(0, os.SEEK_END) self.employee_list = lst
def apply_input(self): try: user_input = self.user_input.split() user_input = ''.join(user_input) user_input = user_input.split(",") name, age, city = user_input assert (name.isalpha() and age.isdigit()) self.orm.write(name + ',' + age + ', ' + city + '\n') self.orm.employee_list.append( Employee(name=name, age=int(age), city=city)) except AssertionError: raise DataEntryError
def create(cls, name, photo_file_path, login, password): # O password já chega encriptado nesse nível. manager = Employee(name=name, photo_file_path=photo_file_path, login=login, password=password, access_level=AccessLevel.WORKSHOP_MANAGER) if cls.exists(manager): raise UniqueObjectViolated cls.__db_session.add(manager) cls.__db_session.commit()
def employee(): my_form = EmployeeForm() # convert to list if my_form.validate_on_submit(): # my_form.submitted() # file we are importing file_csv = request.files.get('file_csv') if file_csv: file_full_path = os.path.join(app.config['UPLOAD_FOLDER'], file_csv.filename) # print("file_full_path", file_full_path) # save to upload folder file_csv.save(file_full_path) # load the data in the table using pandas df = pd.read_csv(file_full_path) # print("raw_data", df.iloc[0]) # print("shape", df.shape) employee_list_raw = df.to_dict('records') # print("dictionary", employee_list_raw) employee_list = [] for curr_emp in employee_list_raw: emp = Employee.from_dict(curr_emp) employee_list.append(emp) # db.session.add(emp) # db.session.commit() print("employee_list_count", len(employee_list)) # save t0 DB db.session.bulk_save_objects(employee_list) db.session.commit() # test query e_list = Employee.query.limit(5).all() print("*******") print(e_list) print("*******") # send us to the display page # return redirect("/employee/" + str(my_data.id)) return render_template('employee.html', my_form=my_form)
def add_nancy(): """ Adds me & corp to the employee & store tables """ corp_store = Store(store_id='999', name='Corporate Headquarters', address='400 Valley Drive', city='Brisbane', state='CA', zipcode='94005', phone='(415) 555-1234', district_id='D99') nancy = Employee(emp_id='09332', fname='Nancy', lname='Reyes', ssn='123-45-6789', password='******', store_id='999', pos_id='99-HQ') db.session.add_all([nancy, corp_store]) db.session.commit()
def add_employee(): body = request.json password = body['password'] email = body['email'] fullname = body['fullname'] position = body['position'] try: employee = Employee(password=password, email=email, fullname=fullname, position=position) db.session.add(employee) db.session.commit() return "add employee. employee id={}".format(employee.employee_id), 200 except Exception as e: return (str(e)), 400
def load_employees(employee_filename): """Load games from game.data into database.""" print("Employees") for i, row in enumerate(open(employee_filename)): row = row.rstrip() employee_id, fname, lname, email = row.split("|")[:4] print(row.split("|")[:4]) employee = Employee(employee_id=employee_id, fname=fname, lname=lname, email=email) # We need to add to the session or it won't ever be stored db.session.add(employee) # provide some sense of progress if i % 10 == 0: print(i) # Once we're done, we should commit our work db.session.commit()
employee_columns[employee_columns["prefix"]] = "selected" employee_columns[employee_columns["maritalStatus"]] = "selected" print("Content-type: text/html\n") f = open('./template/header.html', encoding='utf-8') print(f.read() % header) f.close() f = open('./template/edit_profile.html') print(f.read() % employee_columns) f.close() f = open('./template/footer.html', encoding="utf_8") print(f.read() % footer) f.close() elif os.environ['REQUEST_METHOD'] == 'POST': dict_fields = get_formvalues() e = Employee(dict_fields) employee_id = str(employee_id) update_query = e.update_employee(employee_id) execute(update_query) if dict_fields['photo'].filename: image_ext = dict_fields['photo'].filename.split('.')[-1] image_name = employee_id + '.' + image_ext image_query = e.set_image(image_ext, employee_id) execute(image_query) save_uploaded_file(dict_fields['photo'], config.get('profile', 'path'), image_name) print("Location: http://localhost/edit_profile.py\n") else: print("Location: http://localhost/login.py\n") except Exception as e: create_log("Edit_profile.py : "+str(e))
import os import random # from model import * from tabulate import tabulate from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from model import (Base, Employee, Room, OfficeAvailale, LivingSpacesAvailable) engine = create_engine('sqlite:///amity.db') Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) session = DBSession() Employee = open("input.txt", "r") result = Employee.readline().strip() output = [] for i in result: output.append(Employee.readline().strip().split(' ')) sessiom.add(Employee) session.commit() newroom = Room(room_name='Bugundry', romm_type='Office') session.add(newroom) session.commit() # class Database: # def __init__(self,amity.db):
def test_02(self): emp = Employee() emp.first_name = "John" emp.set_dirty(False) self.failIf(emp._pyport_dirty)
def test_01(self): emp = Employee() emp.first_name = "John" self.failIf(not emp.is_dirty()) self.failIf(emp._pyport_dirty_list != {"first_name": 1})
def test_attribute_assign(self): emp = Employee() emp.first_name = "John" self.failIf(emp.first_name != "John") self.failIf(emp._pyport_data["first_name"] != "John")
def delete_user_employees(self): num = View.get_data('Employee_Num') employee = Employee.Delete_user_employee(num) return View.delete_user_employees(employee)
def makeANewemployee(name, description): employee = Employee(name=name, description=description) session.add(employee) session.commit() return jsonify(employee=employee.serialize)
def add_user_employees(self): Employee_Num = View.get_data('Employee_Num') Employee_Name = View.get_data('Employee_Name') User_User_Num = View.get_data('User_User_Num') employee = Employee.Add_user_employee(Employee_Num, Employee_Name, User_User_Num)
def createTestEmployee(): empl = Employee() empl.firstname = 'jozko' empl.lastname = 'mrkvicka' empl.sex ='m' empl.put()
input('LastName: '), input("Gender: "), input( 'HiredDate: '), input('Salary: ') ) print() print("New Employee Created") return @staticmethod def updateSalary(name, salary): emp = Employee.findEmployeeByName(name) if emp == 0: return "Employee Not Found" emp.updateSalary(salary) emp.viewEmployee() return "Salary Updated" @staticmethod def deleteEmployee(name): emp = Employee.findEmployeeByName(name) if emp == 0: return "Employee Not Found" emp = Employee.findEmployeeByName("Mujtaba") Employee.deleteEmployee(emp) return "Employee Deleted, Database Updated" Employee.viewEmployees()
def deleteEmployee(emp): Employee.deleteEmployee(emp) print("Employee " + emp.FirstName + "Deleted from Database") print("Updated Data : ") Employee.viewEmployees() return
def viewEmployees(): Employee.viewEmployees() return
def show_user_employees(self): employee = Employee.Get_user_employees() return View.show_user_employees(employee)
} if os.environ['REQUEST_METHOD'] == 'GET': print("Content-type: text/html\n") f = open('./template/header.html') print(f.read() % header) f.close() f = open('./template/register.html') print(f.read()) f.close() f = open('./template/footer.html') print(f.read() % footer) f.close() elif os.environ['REQUEST_METHOD'] == 'POST': print("Content-type:text/html\r\n\r\n") dict_fields = get_formvalues() e = Employee(dict_fields) insert_query = e.insert_employee() activation = e.activation() last_id = execute(insert_query)["lastrowid"] if dict_fields['photo'].filename: image_ext = dict_fields['photo'].filename.split('.')[-1] image_name = str(last_id) + '.' + image_ext image_query = e.set_image(image_ext, str(last_id)) execute(image_query) save_uploaded_file(dict_fields['photo'], config.get('profile', 'path'), image_name) print("Please click on activation link sent in email in order to complete registration process.") send_email(dict_fields["email"], activation) except Exception as e: create_log("Register.py : "+str(e)) show_404()