def progUpdate( id ): # id is the id of the GoalSection, goes as is into the object creation empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'MsgProgram' cname = eval(table) form = MsgProgramForm( request.form) # Create an itemList from request.form, in case of post prog = cname.query.filter_by(id=id).first() acct = MsgAccount.query.filter_by(id=prog.accountId).first() acctTitle = acct.accountName if request.method == "POST": form.populate_obj(prog) db.session.commit() return redirect(url_for('progListAdd', id=prog.accountId)) form = MsgProgramForm( obj=prog) # Create an itemList from request.form, in case of post form.managerEmail.choices = getEmailSetForSelect() + [("", "")] allProgs = cname.query.filter_by(accountId=id).all() return render_template('bcsdata/projprogram.html', itemSet=allProgs, form=form, projTitle=acctTitle)
def projUpdate( id ): # id is the id of the GoalSection, goes as is into the object creation empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'MsgProject' cname = eval(table) form = MsgProjectForm( request.form) # Create an itemList from request.form, in case of post proj = cname.query.filter_by(id=id).first() acct = MsgAccount.query.filter_by(id=proj.accountId).first() acctTitle = acct.accountName if request.method == "POST": form.populate_obj(proj) # app.logger.info(str(request.form)) db.session.commit() return redirect(url_for('projListAdd', id=proj.accountId)) allProjs = cname.query.all() # allProjs = cname.query.filter(db.not_(cname.projBCSName.contains("G103DC"))).all() # Fixed in the data load form = MsgProjectForm( obj=proj) # Create an itemList from request.form, in case of post projectFormSetSelect(form) form.billability.value = re.search('BIL', proj.billability) or re.search( 'SHO', proj.billability) return render_template('bcsdata/projshowlist.html', itemSet=allProjs, form=form, projTitle=acctTitle, parentid=proj.accountId)
def projRoleUpdate( id ): # id is the id of the GoalSection, goes as is into the object creation empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'ProjectRole' cname = eval(table) form = MsgProjectRoleForm( request.form) # Create an itemList from request.form, in case of post role = cname.query.filter_by(id=id).first() proj = MsgProject.query.filter_by(id=role.projectId).first() projTitle = proj.projName if request.method == "POST": app.logger.info(str(role.assignedEmpBcsName)) form.populate_obj(role) projRoleFormSetCandidate(form, role) app.logger.info(str(role.assignedEmpBcsName)) db.session.commit() return redirect(url_for('projRoleListAdd', id=role.projectId)) form = MsgProjectRoleForm( obj=role) # Create an itemList from request.form, in case of post projRoleFormSetSelect(form) allRoles = cname.query.filter_by(projectId=proj.id).all() return render_template('bcsdata/projroleshowlist.html', itemSet=allRoles, form=form, projTitle=projTitle, parentid=role.projectId)
def acctDelete(id): # id of the GoalSection is passed here empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'MsgAccount' cname = eval(table) item = cname.query.filter_by(id=id).delete( synchronize_session='evaluate') # Assuming ID to be an INT!! Watchout db.session.commit() return redirect(url_for('acctListAdd'))
def projnavhome(): empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) allAccts = MsgAccount.query.all() allProgs = MsgProgram.query.all() allProjs = MsgProject.query.all() # allRoles = ProjectRole.query.all() return render_template('bcsdata/projnavhome.html', allAccts=allAccts, allProgs=allProgs, allProjs=allProjs)
def projRoleDelete(id): # id of the GoalSection is passed here empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'ProjectRole' cname = eval(table) role = cname.query.filter_by(id=id).first() projid = role.projectId item = cname.query.filter_by(id=id).delete( synchronize_session='evaluate') # Assuming ID to be an INT!! Watchout db.session.commit() return redirect(url_for('projRoleListAdd', id=projid))
def checkBcsData(): form = BcsDataView(request.form) empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) if request.method == 'POST': date = form.date.data # Get the date mrange = date.day year = date.year month = date.month if 'allEmps' in request.form.keys(): allErrors = [] for e in getEmailSetForSelect(): print("Processing:" + e[0]) allErrors += ["Processing:" + e[0]] (fullmsgbuf, bcsProjSummary, bcsUtilSummary) = validEmpBcsData(e[0], month, year, mrange) if 'emailToEmps' in request.form.keys(): emailBCSInfoToEmp(e[0], date, fullmsgbuf, bcsProjSummary, bcsUtilSummary) allErrors += fullmsgbuf if 'emailToPmo' in request.form.keys(): if allErrors: # Something was added, notify the PMO group return emailBCSInfoToPMO(date, allErrors) return ("Surprise!! No errors found for any of the employees.") else: if request.form['candiateEmail']: em = request.form['candiateEmail'].strip() if em: # Check after stripping, just be sure empEmail = em (fullmsgbuf, bcsProjSummary, bcsUtilSummary) = validEmpBcsData(empEmail, month, year, mrange) if 'emailToEmps' in request.form.keys(): emailBCSInfoToEmp(empEmail, date, fullmsgbuf, bcsProjSummary, bcsUtilSummary) else: #No candidate, no "all", do nothing form.candiateEmail.choices = getEmailSetForSelect() + [ ("", "") ] # Fill in e-mails return render_template("bcsdata/empdatacheck.html", form=form) return render_template("bcsdata/empdatashow.html" , mesgSet = fullmsgbuf, \ bcsProjSummary = bcsProjSummary, bcsUtilSummary = bcsUtilSummary ) form.candiateEmail.choices = getEmailSetForSelect() + [("", "") ] # Fill in e-mails return render_template("bcsdata/empdatacheck.html", form=form)
def projListAdd( id=-1, inProg=False ): # id is the id of the GoalSection, goes as is into the object creation empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'MsgProject' cname = eval(table) if id > 0: if inProg: acct = MsgProgram.query.filter_by(id=id).first() acctTitle = acct.programName else: acct = MsgAccount.query.filter_by(id=id).first() acctTitle = acct.accountName else: acctTitle = "All" #form.pmE-mail = This needs to be a drop-down if request.method == "POST": #and form.validate_on_submit(): form = MsgProjectForm( request.form ) # Create an itemList from request.form, in case of post proj = createMsgProject() form.populate_obj(proj) db.session.add(proj) # Add it to the data base db.session.commit() form = MsgProjectForm( ) # Create an itemList from request.form, in case of post projectFormSetSelect(form) if id > 0: if inProg: allProjs = cname.query.filter_by(programId=id).all() # allProjs = cname.query.filter_by(programId = id).filter(db.not_(cname.projBCSName.contains("G103DC"))).all() else: allProjs = cname.query.filter_by(accountId=id).all() # allProjs = cname.query.filter_by(accountId = id).filter(db.not_(cname.projBCSName.contains("G103DC"))).all() else: allProjs = cname.query.filter( db.not_(cname.projBCSName.contains( "G103DC"))).all() # Simply show all projects return render_template('bcsdata/projshowlist.html', itemSet=allProjs, form=form, projTitle=acctTitle)
def savebcsFilesTest(): # id of the GoalSection is passed here import documentdomain as dd empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) form = DataFilesUpload(request.form) if request.method == 'POST': cf = request.files['file1'] lf = request.files['file2'] pf = request.files['file3'] fid = dd.saveFile(cf, empEmail, encrypt=False, retensionPeriod=0) fid = dd.saveFile(lf, empEmail, encrypt=False, retensionPeriod=0) fid = dd.saveFile(pf, empEmail, encrypt=False, retensionPeriod=0) return "Check the DB = " + str(fid) return render_template('bcsdata/bcsdataupload.html', form=form)
def loadbcsdata(): # id of the GoalSection is passed here empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) form = DataFilesUpload(request.form) if request.method == 'POST': cf = request.files['file1'] lf = request.files['file2'] pf = request.files['file3'] fname1 = secure_filename(cf.filename) claimfile = os.path.join(app.config['UPLOAD_FOLDER'], fname1) cf.save(claimfile) fname2 = secure_filename(lf.filename) leavefile = os.path.join(app.config['UPLOAD_FOLDER'], fname2) lf.save(leavefile) fname3 = secure_filename(pf.filename) orgfile = os.path.join(app.config['UPLOAD_FOLDER'], fname3) pf.save(orgfile) #Now these files are read and processed (error, nameHash) = readBCSOrgStructure(orgfile) #Check if the file was parsed correctly if error: flash(nameHash) return render_template('bcsdata/bcsdataupload.html', form=form) (error, mesg) = readBCSLeaveData(leavefile, nameHash) if error: flash(mesg) return render_template('bcsdata/bcsdataupload.html', form=form) (error, mesg) = readBCSClaimData(claimfile, nameHash) if error: flash(mesg) return render_template('bcsdata/bcsdataupload.html', form=form) if 'updateProjs' in request.form.keys(): flash(updateProjectsAndRoles()) flash(checkBCSEmailsWithHRMS(nameHash)) flash("Data Successfully loaded to DB.") return render_template('bcsdata/bcsdataupload.html', form=form)
def projRoleListAdd( id=-1 ): # id is the id of the GoalSection, goes as is into the object creation empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'ProjectRole' cname = eval(table) if id > 0: proj = MsgProject.query.filter_by(id=id).first() projTitle = proj.projName else: projTitle = "All" # return ("Invalid Role ID") form = MsgProjectRoleForm( request.form) # Create an itemList from request.form, in case of post if request.method == "POST" and id > 0: #and form.validate_on_submit(): obj = cname() form.populate_obj(obj) projRoleFormSetCandidate(form, obj) obj.projectId = id obj.assgined_billLevel = 1 # TO BE FIXED, make it NULL ALLOWED db.session.add(obj) # Add it to the data base db.session.commit() form = MsgProjectRoleForm( ) # Create an itemList from request.form, in case of post projRoleFormSetSelect(form) if id > 0: allRoles = cname.query.filter_by(projectId=proj.id).all() else: allRoles = cname.query.all() return render_template('bcsdata/projroleshowlist.html', itemSet=allRoles, form=form, projTitle=projTitle)
def progListAdd( id=-1 ): # id is the id of the GoalSection, goes as is into the object creation empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'MsgProgram' cname = eval(table) if id > 0: acct = MsgAccount.query.filter_by(id=id).first() acctTitle = acct.accountName else: acctTitle = "All" if request.method == "POST": #and form.validate_on_submit(): form = MsgProgramForm( request.form ) # Create an itemList from request.form, in case of post obj = cname() form.populate_obj(obj) if id > 0: obj.accountId = id else: obj.accountId = 1 db.session.add(obj) # Add it to the data base db.session.commit() form = MsgProgramForm( ) # Create an itemList from request.form, in case of post form.managerEmail.choices = getEmailSetForSelect() + [("", "")] if id > 0: allProgs = cname.query.filter_by(accountId=id).all() else: allProgs = cname.query.all() return render_template('bcsdata/projprogram.html', itemSet=allProgs, form=form, projTitle=acctTitle)
def progdetails(): empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) # if request.method == "GET" : # app.logger.info("GET request: "+request.args.get('name1')) accIdStr = request.args.get('name1') try: accId = int(accIdStr) except: return ("AccID Str is not an Int: " + accIdStr) acc = MsgAccount.query.filter_by(id=accId).first() if not acc: return ("No account with the number given:" + accIdStr) form = ProgramAjax() form.programId.choices = getProgramsForSelect(accId) retStr = render_template('bcsdata/progdetails.html', form=form) # print("Returning:" + retStr) return retStr
def acctUpdate( id ): # id is the id of the GoalSection, goes as is into the object creation empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) table = 'MsgAccount' cname = eval(table) form = MsgAccountForm( request.form) # Create an itemList from request.form, in case of post acct = cname.query.filter_by(id=id).first() if request.method == "POST": form.populate_obj(acct) db.session.commit() return redirect(url_for('acctListAdd')) form = MsgAccountForm( obj=acct) # Create an itemList from request.form, in case of post form.managerEmail.choices = getEmailSetForSelect() + [("", "")] allAcct = cname.query.all() return render_template('bcsdata/projaccount.html', itemSet=allAcct, form=form)
def bcstest(): # id of the GoalSection is passed here empEmail = current_user.username.lower() if not bcscheckauth(empEmail): return redirect(url_for('unauthorized')) return ("DB-Reset is disabled") db.drop_all(bind='bcsproj') db.create_all(bind='bcsproj') createDefaultsAccAndProg() baseDir = "C:\\Users\\kambhs\\Desktop\\Learning\\OpenPyxl\\BCS\\" nameHash = readBCSOrgStructure( baseDir + "Employee Email & Organisational_Structure_2018-05-11.xlsx") readBCSLeaveData(baseDir + "Leave_and_Flextime_Dates_21-05-2018.xlsx", nameHash) readBCSClaimData(baseDir + "Employee BCS Bookings_July18_02-08-2018.xlsx", nameHash) #Create Project and Role Data updateProjectsAndRoles() #Drop down lists obj = ProjectType() obj.name = "POC" db.session.add(obj) obj = ProjectType() obj.name = "Maintenance" db.session.add(obj) obj = ProjectType() obj.name = "Development" db.session.add(obj) obj = ProjectType() obj.name = "Implementation" db.session.add(obj) obj = ProjectType() obj.name = "DevOps" db.session.add(obj) obj = BillingModel() obj.name = "MonthlyFTE" db.session.add(obj) obj = BillingModel() obj.name = "DailyEffort" db.session.add(obj) obj = BillingModel() obj.name = "AlternateModel2" db.session.add(obj) obj = StaffingStatus() obj.name = "Open" db.session.add(obj) obj = StaffingStatus() obj.name = "Proposed" db.session.add(obj) obj = StaffingStatus() obj.name = "Blocked" db.session.add(obj) obj = StaffingStatus() obj.name = "Confirmed" db.session.add(obj) obj = StaffingStatus() obj.name = "Shadowing" db.session.add(obj) obj = StaffingStatus() obj.name = "AwaitingResourceJoin" db.session.add(obj) obj = DeliveryStatus() obj.name = "AwaitingConfirmation" db.session.add(obj) obj = DeliveryStatus() obj.name = "AwaitingStaffing" db.session.add(obj) obj = DeliveryStatus() obj.name = "InProgress" db.session.add(obj) obj = DeliveryStatus() obj.name = "Closed" db.session.add(obj) obj = ContractStatus() obj.name = "Opportunity" db.session.add(obj) obj = ContractStatus() obj.name = "Proposed" db.session.add(obj) obj = ContractStatus() obj.name = "Signed" db.session.add(obj) obj = ContractStatus() obj.name = "Terminated" db.session.add(obj) obj = ContractStatus() obj.name = "Ended" db.session.add(obj) obj = ContractStatus() obj.name = "OnHold" db.session.add(obj) db.session.commit() return ("Update completed")