Esempio n. 1
0
def assignGoals(year='2018-2019'):
    year = session['year']
    user = current_user.username.lower()
    table = 'GoalSheet'
    cname = eval(table)
    form = GoalSheetAssignmentForm(request.form)
    form.templateList.choices = getTemplateListForSelect()  # Fill-in templates
    if current_user.is_admin:
        form.candiateEmail.choices = getEmailSetForSelect() + [
            ("", "")
        ]  # Fill in e-mails
    elif current_user.is_dclead:  # must be a DC-Lead
        form.candiateEmail.choices = getEmpSetForSelect(user) + [
            ("", "")
        ]  # Fill in e-mails
    else:
        return render_template(
            'goalsheet/message.html',
            message="You are not authorized to assign goals.")

    form1 = GoalSheetAssignmentFormFromFile(request.form)
    form1.templateList.choices = getTemplateListForSelect(
    )  # Fill-in templates

    if request.method == 'POST':
        tempId = request.form['templateList']
        if request.form['addemail'] == 'Add':
            if request.form['candiateEmail']:
                em = request.form['candiateEmail'].strip()
                if em:  # Check after stripping, just be sure
                    flash(assignTemplate(em, tempId, user, year))
                else:
                    flash("E-mail Selected is empty")
            else:
                flash("No e-mail Selected")
        #File-Upload needs to be handled separately as combining it with another submit is causing some issue in the libraries down below.
    if current_user.is_admin:
        sheets = GoalSheet.query.filter_by(assessmentYear=year).all()
    else:
        empInfo = getEmpDictbyEmail(user)
        dcEmpId = int(empInfo["EMPLOYEE_ID"])
        sheets = GoalSheet.query.filter_by(assessingManager=dcEmpId).filter_by(
            assessmentYear=year).all()
    itemSet = []
    for gs in sheets:
        emp = getEmployeebyId(gs.empId)
        if emp:
            itemSet += [{
                'emailId': emp.OFFICE_EMAIL_ID,
                'status': gs.status,
                'year': gs.assessmentYear,
                'title': gs.templateRef.title
            }]
        else:
            print("Goal Sheet found for non-existant emp:" + str(gs.empId))
    #print("ItemSet=" + str(itemSet))
    return render_template('goalsheet/goalsheetslist.html',
                           goalSheets=itemSet,
                           form=form,
                           form1=form1)
Esempio n. 2
0
def getGoalSheetHeader(empEmail, year) :
    msgDict = getEmpDictbyEmail(empEmail) # Get all available fields for the employee
    if not msgDict :
        print("Employee not found with email:" + empEmail)
        return {'FIRST_NAME':"Not available",'EmployeeID':"NA", 'Current Role':'To Be Updated', 'Designation':"Not available", \
        'Project/Department' : "Not available", 'Manager': "Not available" , 'Assessment Year': "Not available"  }
        
    empName = msgDict["FIRST_NAME"] + " " + msgDict["LAST_NAME"]
    empId = str(msgDict["EMPLOYEE_ID"])
    empDesignation =  msgDict["DESIGNATION"]
    empDepartment = msgDict["DEPARTMENT"]
#    empManager = msgDict["MANAGER_NAME"]
    empManager = msgDict["DC_LEAD"]
    empInfo = {'FIRST_NAME':empName,'EmployeeID':empId, 'Manager2': get2ndLineManagerName(empId), 'Designation':empDesignation, \
        'Project/Department' : empDepartment, 'Manager': empManager , 'Assessment Year': year  }
    return empInfo
def getRelationshipsForSelect(emailid=None) :
    firstname="He(him)/She(her)"
    if  emailid :   
        empDict = getEmpDictbyEmail(emailid)
        if empDict and empDict['FIRST_NAME']:
            firstname = empDict['FIRST_NAME']
    return sorted([ ("",""),
        ('%s managed you directly' % (firstname) ,'%s managed you directly' % (firstname) ),\
        ('%s was your DC Lead' % (firstname),'%s was your DC Lead' % (firstname) ), \
        ('%s reported directly to you'% (firstname),'%s reported directly to you'% (firstname)), \
        ('%s reported in your DC'% (firstname),'%s reported in your DC'% (firstname)), \
        ("%s was senior to you but didn’t manage directly"% (firstname),"%s was senior to you but didn’t manage directly"% (firstname)), \
        ("You were senior to %s but didn’t manage directly"% (firstname),"You were senior to %s but didn’t manage directly" % (firstname)), \
        ('%s mentored you'% (firstname),'%s mentored you'% (firstname)), \
        ('%s was your mentee'% (firstname),'%s was your mentee'% (firstname)), \


        ('%s and you worked together in same DC '% (firstname) ,'%s and you worked together in same DC '% (firstname)), \
        ('%s and you worked together but reported in different DC '% (firstname) ,'%s and you worked together but reported in different DC '% (firstname)), \
        ])
def emailBCSInfoToEmp(empEmail, date, fullmsgbuf, bcsProjSummary,
                      bcsUtilSummary):
    #Get emp Details
    empDict = getEmpDictbyEmail(empEmail)
    #Form Message
    subject = "BCS Booking and Error Summary:" + date.strftime('%d-%m-%y')
    message = htmlhead + "<h4>Summary for : " + empDict[
        "FIRST_NAME"] + " " + empDict["LAST_NAME"] + "</h4>"
    message = "<h4>This is in BETA Test. Kindly help by pointing out any errors to K.Srinivas.</h4>"
    tstr = "<table>"
    for m in fullmsgbuf:
        tstr += "<tr><td>" + m + "</td></tr>"
    tstr += "</table>"
    message += tstr
    message += "<h3>Available Hours[%d], Booked Hours[%d], Billed Hours[%d] and Leave Hours[%d]</h3>" % \
        (bcsUtilSummary["AvailableHours"], bcsUtilSummary["BookedHours"], \
        bcsUtilSummary["BilledHours"],bcsUtilSummary["LeaveHours"] )

    message += hrmsfooter + htmlfooter
    #Send e-mail
    notify(empEmail, "BETA:" + subject, message, templateId="-1")
Esempio n. 5
0
def manageGoalSheets(id=-1):
    if True:
        user = '******'
    else:
        user = current_user.username
    empInfo = getEmpDictbyEmail(user)
    table = 'GoalSheet'
    cname = eval(table)

    sheets = GoalSheet.query.filter_by(
        assessingManager=int(empInfo['EMPLOYEE_ID'])).filter_by(
            status='Assigned').all()
    itemSet = []
    for gs in sheets:
        itemSet += [{
            'emailId': getEmployeebyId(gs.empId).OFFICE_EMAIL_ID,
            'status': gs.status,
            'year': gs.assessmentYear,
            'title': gs.templateRef.title,
            'id': gs.id
        }]
    #print("ItemSet=" + str(itemSet))
    return render_template('goalsheet/managegoalsheets.html',
                           goalSheets=itemSet)
def getAllComments(loginedInEmpId,
                   sheet,
                   allgoals,
                   alltasks,
                   visibleToEmp=True,
                   authLevel=0):
    allSheetComments = dict()
    allGoalComments = dict()
    allTaskComments = dict()
    #print("AuthLevel=" + str(authLevel))
    #print("loginedInEmpId=" + str(loginedInEmpId))
    allSheetComments = getGoalFeedback(loginedInEmpId, visibleToEmp, authLevel,
                                       sheet.id, ELEMENT_TYPE_SHEET)
    for sfs in allSheetComments:
        sfs.commentorName = getEmployeeNameById(sfs.giverEmpId)

    for gg in allgoals:
        for g in gg:
            gId = g.id
            allgfs = getGoalFeedback(loginedInEmpId, visibleToEmp, authLevel,
                                     gId, ELEMENT_TYPE_GOAL)
            for gfs in allgfs:
                gfs.commentorName = getEmployeeNameById(gfs.giverEmpId)
            allGoalComments[gId] = allgfs

    for k in alltasks.keys():
        for t in alltasks[k]:
            tId = t.id
            alltfs = getGoalFeedback(loginedInEmpId, visibleToEmp, authLevel,
                                     tId, ELEMENT_TYPE_TASK)
            for tfs in alltfs:
                tfs.commentorName = getEmployeeNameById(tfs.giverEmpId)
            allTaskComments[tId] = alltfs
            #        print("ALlTasks:" + str(allTaskComments) + len(alltfs) + ":" + str(tId))

            #  Add Ask Feedback Comments here to allTaskComments[tId]
            #Get e-mail from loginedInEmpId
            receiverEmail = getEmployeeEmail(loginedInEmpId)
            #get all Asks for this task - allAsksForUser(receiverEmail, year)
            allAsks = allAsksForUserByTaskId(receiverEmail,
                                             sheet.assessmentYear,
                                             tId,
                                             authLevel=authLevel)
            for ask in allAsks:
                #Create a new GoalFeedback object (name, value pair)
                gfb = GoalFeedback()
                #get commentorName
                giverEmpDict = getEmpDictbyEmail(ask.giverEmail)
                if giverEmpDict:
                    gfb.commentorName = giverEmpDict["FIRST_NAME"] + " " + \
                        giverEmpDict["LAST_NAME"]
                else:
                    gfb.commentorName = "Unknown"
                gfb.commentorName += ":" + ask.relationship
                # Copy role:feedback, date
                gfb.feedback = ask.feedback
                gfb.dateRecorded = ask.dateRecorded
                #Add the object to allTaskComments
                allTaskComments[tId].append(gfb)

    return (allSheetComments, allGoalComments, allTaskComments)
def getTaskComments(taskId, authLevel):
    #All Task Comments
    retList = []
    #Get Task Activity
    task = goaldomain.getTaskById(taskId)
    activity = "None"
    if task.personalNotes:
        activity = task.personalNotes
    if task:
        fbObj = {
            'name': 'Activity',
            'feedback': activity,
            'date': task.dateEnd.strftime('%m-%d-%y')
        }
        retList.append(fbObj)
    else:
        fbObj = {
            'name': 'Activity',
            'feedback': "Error Task Not found" + str(taskId),
            'date': "Not Found"
        }
        retList.append(fbObj)

    gfl = GoalFeedback.query.filter_by(elementId = taskId). \
            filter( GoalFeedback.visiblityLevel <=  authLevel). \
            filter_by(elementType = ELEMENT_TYPE_TASK). \
            all()

    #Convert into a serializable list
    for f in gfl:
        giverEmpDict = getEmpDictbyEmpid(f.giverEmpId)
        if giverEmpDict:
            commentorName = giverEmpDict["FIRST_NAME"] + " " + \
                giverEmpDict["LAST_NAME"]
        else:
            commentorName = "Unknown"
        fbObj = {
            'name': commentorName,
            'feedback': f.feedback,
            'date': f.dateRecorded.strftime('%m-%d-%y')
        }
        retList.append(fbObj)
    #All Ask-For-Feedbacks
    allAsks = allAsksByTaskId(taskId, visibleToEmp=True, authLevel=authLevel)
    #Process Ask-For-Feedbacks into GoalFeedback Objects for display
    for ask in allAsks:
        #get commentorName
        giverEmpDict = getEmpDictbyEmail(ask.giverEmail)
        if giverEmpDict:
            commentorName = giverEmpDict["FIRST_NAME"] + " " + \
                giverEmpDict["LAST_NAME"]
        else:
            commentorName = "Unknown"
        commentorName += ":" + ask.relationship

        fbObj = {
            'name': commentorName,
            'feedback': ask.feedback,
            'date': ask.dateRecorded.strftime('%m-%d-%y')
        }
        #Add the object to allTaskComments
        retList.append(fbObj)

    return retList