def task_create_long_term_synergy(**kwargs): workflow_task = kwargs["workflow_task"] person = TaskWorker.get_person_from_workflow_task(workflow_task) # If the 'status' arg is defined, that means the request # originated from the front end. We need to check it and # see if the user opted to skip over Synergy creation. if "status" in kwargs: status = kwargs["status"] if not status: update_field(person, "is_synergy_account_needed", False) return ("True", "Success") if kwargs["synergy_username"] == "": return ("False", "No Synergy username entered.") synergy_username = SynergyHelper.verify_synergy_username( kwargs["synergy_username"]) user = TaskWorker.get_user_or_false(kwargs["username"]) if not user: return (False, "Invalid User") if not synergy_username: return (False, "Synergy user not found") did_update = person.update_synergy_service(synergy_username, user) if did_update: return (True, "Success") else: return (False, "Unknown Error")
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")
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")
def task_check_synergy(**kwargs): workflow_task = kwargs["workflow_task"] employee = TaskWorker.get_employee_from_workflow_task(workflow_task) if "status" in kwargs: status = kwargs["status"] if not status: update_field(employee, "is_synergy_account_needed", False) return ("True", "Success") synergy_username = SynergyHelper.get_synergy_login(employee.visions_id) user = TaskWorker.get_user_or_false(kwargs["username"]) if not user: return (False, "Invalid User") if not synergy_username: return (False, "Synergy user not found") did_update = employee.update_synergy_service(synergy_username, user) if did_update: return (True, "Success") else: return (False, "Unknown Error")
def task_transfer_synergy(**kwargs): workflow_task = kwargs["workflow_task"] employee = TaskWorker.get_employee_from_workflow_task(workflow_task) # If the 'status' arg is defined, that means the request # originated from the front end. We need to check it and # see if the user opted to skip over Synergy creation. if "status" in kwargs: status = kwargs["status"] if not status: update_field(employee, "is_synergy_account_needed", False) return ("True", "Success") synergy_username = SynergyHelper.get_synergy_login(employee.visions_id) user = TaskWorker.get_user_or_false(kwargs["username"]) if not user: return (False, "Invalid User") if not synergy_username: return (True, "Success. The employee/contractor has no Synergy account.") did_update = employee.update_synergy_service(synergy_username, user) if did_update: return (True, "Success") else: return (False, "Unknown Error")
def test_update_field(self): # Does our custom update function work? update_jon = Employee.objects.get(talented_id=12345) update_field(update_jon, "middle_name", "Stark") final_jon = Employee.objects.get(talented_id=12345) self.assertEqual(final_jon.middle_name, "Stark")
def update(self, instance, validated_data): user = False if validated_data.get("last_updated_by", False): user = User.objects.get(username=validated_data["last_updated_by"]) update_field(instance, 'first_name', validated_data.get('first_name', instance.first_name), user) update_field(instance, 'last_name', validated_data.get('last_name', instance.last_name), user) update_field(instance, 'middle_name', validated_data.get('middle_name', instance.middle_name), user) update_field(instance, 'badge_number', validated_data.get('badge_number', instance.badge_number), user) update_field(instance, 'birth_date', validated_data.get('birth_date', instance.birth_date), user) update_field(instance, 'gender', validated_data.get('gender', instance.gender), user) update_field(instance, 'race_white', validated_data.get('race_white', instance.race_white), user) update_field(instance, 'race_asian', validated_data.get('race_asian', instance.race_asian), user) update_field(instance, 'race_black', validated_data.get('race_black', instance.race_black), user) update_field( instance, 'race_islander', validated_data.get('race_islander', instance.race_islander), user) update_field( instance, 'race_american_indian', validated_data.get('race_american_indian', instance.race_american_indian), user) update_field(instance, 'ethnicity', validated_data.get('ethnicity', instance.ethnicity), user) update_field(instance, 'hqt', validated_data.get('hqt', instance.hqt), user) update_field(instance, 'ssn', validated_data.get('ssn', instance.ssn), user) update_field(instance, 'tcp_id', validated_data.get('tcp_id', instance.tcp_id), user) update_field(instance, 'talented_id', validated_data.get('talented_id', instance.talented_id), user) update_field(instance, 'start_date', validated_data.get('start_date', instance.start_date), user) instance.refresh_from_db() return instance