Beispiel #1
0
 def update_positions(employee, visions_positions):
     secondary_positions = []
     primary_position = employee.positions.get(is_primary=True)
     did_update = False
     for position in visions_positions:
         if position.position_ranking == "Primary":
             location = VisionsHelper.get_position_location(position.dac)
             primary_position.title = position.description
             primary_position.visions_position_id = position.id
             primary_position.last_updated_by = "Visions"
             primary_position.last_updated_date = date.today()
             if location:
                 primary_position.location = location
             primary_position.save()
             did_update = True
         else:
             secondary_positions.append(position)
     if secondary_positions:
         for secondary_position in secondary_positions:
             new_position = Position.objects.create(
                 person=employee,
                 title=secondary_position.description,
                 is_primary=False,
                 last_updated_by="Visions",
                 last_updated_date=date.today())
             location = VisionsHelper.get_position_location(
                 secondary_position.dac)
             if location:
                 secondary_position.location = location
                 new_position.save()
             did_update = True
     if did_update:
         return (True, "Success")
     return (False, "Nothing Updated")
Beispiel #2
0
 def task_set_transfer_epar_id(**kwargs):
     workflow_task = kwargs["workflow_task"]
     epar_id = kwargs["epar_id"]
     user = TaskWorker.get_user_or_false(kwargs["username"])
     if not VisionsHelper.verify_epar(epar_id):
         return (False, "ePAR not found")
     if TaskWorker.is_transfer_epar_dup(epar_id):
         return (False, "ePAR already linked to an Employee")
     employee = TaskWorker.get_employee_from_workflow_task(workflow_task)
     update_field(employee, "transfer_epar_id", epar_id, user)
     positions = VisionsHelper.get_epar_positions(epar_id)
     if positions:
         return TaskWorker.update_positions(employee, positions)
     else:
         return (False, "No ePAR Positions Found")
Beispiel #3
0
def run():
    VisionsPositions.objects.all().delete()

    positions = VisionsHelper.get_all_visions_positions()
    for position in positions:
        VisionsPositions.objects.create(description=position["Description"],
                                        type=position["PosType"])
def run():
    employees = VisionsHelper.get_employees_for_import()
    for employee in employees:
        new_employee = Employee.objects.create(
            first_name=employee.first_name,
            last_name=employee.last_name,
            ssn=employee.ssn,
            visions_id=employee.id,
            status="visions",
            type="Employee",
        )
    all_employees = Employee.objects.all()
    tandem = User.objects.get(username="******")
    for an_employee in all_employees:
        if an_employee.visions_id:
            # Update demographics from Visions
            an_employee.update_employee_from_visions()
            # Update Synergy username if found
            synergy_username = SynergyHelper.get_synergy_login(
                an_employee.visions_id)
            if synergy_username:
                an_employee.update_synergy_service(synergy_username, tandem)
            # Update Active Directory if found
            ad_username = ldap.get_ad_username_from_visions_id(
                an_employee.visions_id)
            if ad_username:
                an_employee.update_ad_service(ad_username, tandem)
Beispiel #5
0
def update_position_from_employee(employee):
    visions_positions = VisionsHelper.get_positions_for_employee(
        employee.visions_id)
    if not visions_positions:
        return False
    secondary_positions = []
    no_primary = False
    try:
        primary_position = employee.positions.get(is_primary=True)
    except ObjectDoesNotExist:
        no_primary = True
    did_update = False
    for position in visions_positions:
        if position.position_ranking == "Primary":
            if no_primary:
                primary_position = Position.objects.create(person=employee,
                                                           is_primary=True)
            location = VisionsHelper.get_position_location(position.dac)
            primary_position.title = position.description
            primary_position.visions_position_id = position.id
            primary_position.last_updated_by = "Visions"
            primary_position.last_updated_date = date.today()
            if location:
                primary_position.location = location
            primary_position.save()
            did_update = True
        else:
            secondary_positions.append(position)
    if secondary_positions:
        for secondary_position in secondary_positions:
            new_position = Position.objects.create(
                person=employee,
                title=secondary_position.description,
                visions_position_id=secondary_position.id,
                is_primary=False,
                last_updated_by="Visions",
                last_updated_date=date.today())
            location = VisionsHelper.get_position_location(
                secondary_position.dac)
            if location:
                new_position.location = location
                new_position.save()
            did_update = True
    if did_update:
        return True
    return False
Beispiel #6
0
 def task_update_position(**kwargs):
     workflow_task = kwargs["workflow_task"]
     employee = TaskWorker.get_employee_from_workflow_task(workflow_task)
     visions_positions = VisionsHelper.get_positions_for_employee(
         employee.visions_id)
     if not visions_positions:
         return (False, "No positions found")
     return TaskWorker.update_positions(employee, visions_positions)
Beispiel #7
0
 def task_set_tcp_id(**kwargs):
     workflow_task = kwargs["workflow_task"]
     employee = TaskWorker.get_employee_from_workflow_task(workflow_task)
     tcp_id = VisionsHelper.get_tcp_id_for_employee(employee.visions_id)
     if not tcp_id:
         return (False, "No Time Clock Plus record found in Visions")
     else:
         employee.tcp_id = tcp_id
         employee.save()
         return (True, "Success")
Beispiel #8
0
 def task_set_term_epar_id(**kwargs):
     workflow_task = kwargs["workflow_task"]
     epar_id = kwargs["epar_id"]
     user = TaskWorker.get_user_or_false(kwargs["username"])
     if not VisionsHelper.verify_epar(epar_id):
         return (False, "ePAR not found")
     if TaskWorker.is_term_epar_dup(epar_id):
         return (False, "ePAR already linked to an Employee")
     employee = TaskWorker.get_employee_from_workflow_task(workflow_task)
     update_field(employee, "termination_epar_id", epar_id, user)
     return (True, "Success")
Beispiel #9
0
 def task_mark_long_term(**kwargs):
     workflow_task = kwargs["workflow_task"]
     visions_id = kwargs["visions_id"]
     person = TaskWorker.get_person_from_workflow_task(workflow_task)
     if visions_id and visions_id != "":
         if not VisionsHelper.verify_employee(visions_id):
             return (False, "Employee not found")
         else:
             person.long_term_sub_replacing = visions_id
     person.long_term_sub = True
     person.save()
     return (True, "Success")
Beispiel #10
0
 def task_set_visions_id(**kwargs):
     workflow_task = kwargs["workflow_task"]
     visions_id = kwargs["visions_id"]
     if not VisionsHelper.verify_employee(visions_id):
         return (False, "Employee not found")
     if TaskWorker.is_visions_id_dup(visions_id):
         return (False, "Visions Employee already linked to an Employee")
     employee = TaskWorker.get_employee_from_workflow_task(workflow_task)
     employee.visions_id = visions_id
     employee.save()
     employee.update_employee_from_visions()
     return (True, "Success")
Beispiel #11
0
 def retrieve(self, request, pk=None):
     employee = VisionsHelper.get_employee(pk)
     serializer = VisionsEmployeeSerializer(instance=employee)
     return Response(serializer.data)
Beispiel #12
0
 def list(self, request):
     employees = VisionsHelper.get_all_employees()
     serializer = VisionsEmployeeSerializer(instance=employees, many=True)
     return Response(serializer.data)
Beispiel #13
0
 def retrieve(self, request, pk=None):
     epar = VisionsHelper.get_epar(pk)
     serializer = EparSerializer(instance=epar)
     return Response(serializer.data)
Beispiel #14
0
 def list(self, request):
     epars = VisionsHelper.get_all_epars()
     serializer = EparSerializer(instance=epars, many=True)
     return Response(serializer.data)