Skip to content

Commit

Permalink
Merge pull request #7 from uw-it-aca/develop
Browse files Browse the repository at this point in the history
worker position state url parameter
  • Loading branch information
fanglinfang committed May 31, 2019
2 parents fe686ab + 5cddf8a commit 3133693
Show file tree
Hide file tree
Showing 7 changed files with 825 additions and 63 deletions.
45 changes: 20 additions & 25 deletions uw_hrp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,13 @@ def __init__(self, *args, **kwargs):

self.status = data.get("EmployeeStatus")
self.status_code = data.get("EmployeeStatusCode")
if data.get("EndEmploymentDate") is not None:
self.end_emp_date = parse_date(data["EndEmploymentDate"])
self.end_emp_date = parse_date(data.get("EndEmploymentDate"))
self.is_active = data.get("IsActive")
self.is_retired = data.get("IsRetired")
self.is_terminated = data.get("IsTerminated")
if data.get("HireDate") is not None:
self.hire_date = parse_date(data["HireDate"])
if data.get("RetirementDate") is not None:
self.retirement_date = parse_date(data["RetirementDate"])
if data.get("TerminationDate") is not None:
self.termination_date = parse_date(data["TerminationDate"])
self.hire_date = parse_date(data.get("HireDate"))
self.retirement_date = parse_date(data.get("RetirementDate"))
self.termination_date = parse_date(data.get("TerminationDate"))

def __str__(self):
return json.dumps(self.to_json())
Expand Down Expand Up @@ -116,6 +112,7 @@ class WorkerPosition(models.Model):
end_date = models.DateTimeField(null=True, default=None)
ecs_job_cla_code_desc = models.CharField(max_length=96,
null=True, default=None)
is_future_date = models.BooleanField(default=False)
is_primary = models.BooleanField(default=False)
location = models.CharField(max_length=96, null=True, default=None)
pos_type = models.CharField(max_length=64, null=True, default=None)
Expand All @@ -129,14 +126,12 @@ class WorkerPosition(models.Model):
def is_active_position(self):
return self.end_date is None or self.end_date > get_now()

def is_future_position(self):
return self.start_date is not None and self.start_date > get_now()

def to_json(self):
data = {'start_date': date_to_str(self.start_date),
'end_date': date_to_str(self.end_date),
'ecs_job_cla_code_desc': self.ecs_job_cla_code_desc,
'fte_percent': self.fte_percent,
'is_future_date': self.is_future_date,
'is_primary': self.is_primary,
'location': self.location,
'pos_type': self.pos_type,
Expand Down Expand Up @@ -169,17 +164,16 @@ def __init__(self, *args, **kwargs):

self.ecs_job_cla_code_desc = \
data.get("EcsJobClassificationCodeDescription")
self.is_future_date = data.get("IsFutureDate")
self.is_primary = data.get("IsPrimaryPosition")
if data.get("Location") is not None:
self.location = data["Location"]["ID"]
self.title = data.get("PositionBusinessTitle")
self.pos_type = data.get("PositionType")
self.pos_time_type_id = data.get("PositionTimeTypeID")
self.fte_percent = float(data.get("PositionFTEPercent"))
if data.get("PositionStartDate") is not None:
self.start_date = parse_date(data["PositionStartDate"])
if data.get("PositionEndDate") is not None:
self.end_date = parse_date(data["PositionEndDate"])
self.start_date = parse_date(data.get("PositionStartDate"))
self.end_date = parse_date(data.get("PositionEndDate"))
if data.get("PositionSupervisor") is not None:
self.supervisor_eid = data["PositionSupervisor"]["EmployeeID"]

Expand Down Expand Up @@ -227,13 +221,14 @@ def __init__(self, *args, **kwargs):
self.employee_status = EmploymentStatus(
data=data.get("WorkerEmploymentStatus"))

if (self.employee_status.is_active and
data.get("WorkerPositions") is not None):
for position in data["WorkerPositions"]:
position = WorkerPosition(data=position)
if position.is_active_position():
if position.is_primary:
self.primary_manager_id = position.supervisor_eid
self.primary_position = position
else:
self.other_active_positions.append(position)
if self.employee_status.is_active:
positions = data.get("WorkerPositions")
if positions is not None and len(positions) > 0:
for position in positions:
position = WorkerPosition(data=position)
if position.is_active_position():
if position.is_primary:
self.primary_manager_id = position.supervisor_eid
self.primary_position = position
else:
self.other_active_positions.append(position)
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
{
"AcademicAppointments":
[{"AcademicAppointmentCompletedDate":"2017-06-22T07:00:00.000Z",
"AcademicAppointmentEndDate":null,
"AcademicAppointmentIdentifierID":"A",
"AcademicAppointmentIdentifierTypeID":"Administrative",
"AcademicAppointmentStartDate":"2017-04-01T07:00:00.000Z",
"AcademicAppointmentState":"Current",
"AcademicAppointmentTitle":"Chair",
"AcademicAppointmentTrackID":"AC-000000015-2",
"AcademicUnitID":"050",
"AcademicUnitName":"Family Medicine",
"AcademicUnitSupervisoryOrganizations":
[{"AcademicUnitID":"050",
"Code":"SOM:",
"CostCenter":
{"Description":"WORKDAY DEFAULT DEPTBG",
"ID":"681925",
"OrganizationCode":"3040111000",
"OrganizationDescription":"FAMILY MEDICINE"},
"Description":"SOM: Family Medicine (Visor, Super1)",
"Href":"\/hrp\/v2\/organization\/SOM_000420.json",
"ID":"SOM_000420",
"Name":"Family Medicine"},
{"AcademicUnitID":"081",
"Code":"SOM:",
"CostCenter":
{"Description":"DOM PAYROLL SUSPENSE",
"ID":"656131",
"OrganizationCode":"3040510019",
"OrganizationDescription":"FINANCE ABC\/DEANS HR"},
"Description":"School of Medicine (Dean, Bill)",
"Href":"\/hrp\/v2\/organization\/SOM_000001.json",
"ID":"SOM_000001",
"Name":"School of Medicine"}
],
"ActualAcademicAppointmentEndDate":null,
"AppointmentPositionID":null,
"PositionSupervisoryOrganization":null,
"PrimaryPositionID":"PN-0000809",
"SuperiorAcademicUnitID":"081"},
{"AcademicAppointmentCompletedDate":"2017-06-22T07:00:00.000Z",
"AcademicAppointmentEndDate":null,
"AcademicAppointmentIdentifierID":"P",
"AcademicAppointmentIdentifierTypeID":"Primary",
"AcademicAppointmentStartDate":"2017-04-01T07:00:00.000Z",
"AcademicAppointmentState":"Current",
"AcademicAppointmentTitle":"Professor",
"AcademicAppointmentTrackID":"AC-000000015-1",
"AcademicUnitID":"050",
"AcademicUnitName":"Family Medicine",
"AcademicUnitSupervisoryOrganizations":
[{"AcademicUnitID":"050",
"Code":"SOM:",
"CostCenter":
{"Description":"WORKDAY DEFAULT DEPTBG",
"ID":"681925",
"OrganizationCode":"3040111000",
"OrganizationDescription":"FAMILY MEDICINE"},
"Description":"SOM: Family Medicine (Visor, Super1)",
"Href":"\/hrp\/v2\/organization\/SOM_000420.json",
"ID":"SOM_000420",
"Name":"Family Medicine"},
{"AcademicUnitID":"081",
"Code":"SOM:",
"CostCenter":
{"Description":"DOM PAYROLL SUSPENSE",
"ID":"656131",
"OrganizationCode":"3040510019",
"OrganizationDescription":"FINANCE ABC\/DEANS HR"},
"Description":"School of Medicine (Dean, Bill)",
"Href":"\/hrp\/v2\/organization\/SOM_000001.json",
"ID":"SOM_000001",
"Name":"School of Medicine"}
],
"ActualAcademicAppointmentEndDate":null,
"AppointmentPositionID":"PN-0000809",
"PositionSupervisoryOrganization":
{"AcademicUnitID":null,
"Code":"SOM:",
"CostCenter":
{"Description":"DOM PAYROLL SUSPENSE",
"ID":"656131",
"OrganizationCode":"3040510019",
"OrganizationDescription":"FINANCE ABC\/DEANS HR"},
"Description":"School of Medicine (Dean, Bill)",
"Href":"\/hrp\/v2\/organization\/SOM_000001.json",
"ID":"SOM_000001",
"Name":"School of Medicine"},
"PrimaryPositionID":"PN-0000809",
"SuperiorAcademicUnitID":"081"}],
"DisplayFirstName":"Super1",
"DisplayLastName":"Visor",
"DisplayMiddleName":null,
"DisplayName":"Super1 Visor",
"EmployeeID":"100000015",
"EmployeeIDPrior":null,
"FormattedLegalNameFirstLast":"Super1 Visor",
"FormattedLegalNameFirstMiddleLast":"Super1 Visor",
"FormattedLegalNameLastFirstMiddle":"Visor, Super1",
"FormattedPreferredNameFirstLast":"Super1 Visor",
"FormattedPreferredNameFirstMiddleLast":"Super1 Visor",
"FormattedPreferredNameLastFirstMiddle":"Visor, Super1",
"HuskyCardOverride":null,
"IsCurrentFaculty":true,
"IsFutureDate":false,
"LegalFirstName":"Super1",
"LegalLastName":"Visor",
"LegalMiddleName":"A",
"LegalNameSuffix":null,
"NetID":"jamespa",
"PreferredFirstName":"Super1",
"PreferredLastName":"Visor",
"PreferredMiddleName":null,
"PreferredNameSuffix":null,
"RegID":"10000000000000000000000000000015",
"RepositoryTimeStamp":"2019-03-06T16:12:12.214Z",
"SystemMetadata":{"LastModified":null},
"WorkdayPersonType":"Employee",
"WorkerContact":
{"Addresses":[
{"Country":"United States of America",
"CountryCodeISO2":"US",
"IsPrimary":true,
"IsPubliclyAvailable":true,
"Lines":["Seattle Main Campus"],
"Municipality":"Seattle",
"PostalCode":"98195",
"Region":"Washington",
"Type":"WORK"},
{"Country":"United States of America",
"CountryCodeISO2":"US",
"IsPrimary":false,
"IsPubliclyAvailable":true,
"Lines":["1705 NE Pacific St"],
"Municipality":"Seattle",
"PostalCode":"98195-0000",
"Region":"Washington",
"Type":"WORK"}],
"CampusBox":"356390",
"EmailAddresses":[
{"Address":"jamespa@uw.edu",
"IsPrimary":true,
"IsPubliclyAvailable":true,
"Type":"WORK"}],
"Phones":[{"AreaCode":"206",
"DeviceType":"Telephone",
"InternationalCode":"1",
"IsPrimary":true,
"IsPubliclyAvailable":true,
"NANPPhoneNumber":"+1 (206) 123-1234",
"Number":"123-1234",
"Type":"WORK"},
{"AreaCode":"206",
"DeviceType":"Telephone",
"InternationalCode":"1",
"IsPrimary":false,
"IsPubliclyAvailable":true,
"NANPPhoneNumber":"+1 (206) 123-1235",
"Number":"123-1235",
"Type":"WORK"}
]
},
"WorkerEmploymentStatus":
{"ActiveStatusDate":"2017-04-01T07:00:00.000Z",
"EmployeeStatus":"Active",
"EmployeeStatusCode":"A",
"EndEmploymentDate":null,
"EstimatedLastDayOfLeave":null,
"FirstDayOfLeave":null,
"FirstDayOfWork":"2017-04-01T07:00:00.000Z",
"HireDate":"2017-04-01T07:00:00.000Z",
"IsActive":true,
"IsRetired":false,
"IsTerminated":false,
"LastDayOfWorkForLeave":null,
"OriginalHireDate":"2017-03-31T07:00:00.000Z",
"RetirementDate":null,
"TerminationDate":null},
"WorkerPositions":[
{"CostCenter":
{"Description":"WORKDAY DEFAULT DEPTBG",
"ID":"681925",
"OrganizationCode":"3040111000",
"OrganizationDescription":"FAMILY MEDICINE"
},
"EcsJobClassificationCode":"F",
"EcsJobClassificationCodeDescription":"Academic Personnel",
"FutureTransactions":[],
"IsFutureDate":false,
"IsMedicalCenterPosition":false,
"IsOnLeaveFromPosition":false,
"IsPrimaryPosition":true,
"JobProfileSummary":
{"Href":"\/hrp\/v2\/jobProfile\/10101.json",
"JobCategory":"Faculty",
"JobFamilies":[
{"JobFamilyID":"Faculty - Indefinite and Multi-Year",
"JobFamilyName":"01 - Academic Personnel - Faculty - Indefinite and Multi-Year",
"JobFamilySummary":"Academic positions designated as faculty under the Faculty Code Chapter 21"}
],
"JobProfileDescription":"Professor",
"JobProfileID":"10101"
},
"Location":
{"ID":"Seattle Campus",
"Name":"Seattle Campus"
},
"ObjectCode":"01",
"PayRateType":"Salary",
"PayrollUnitCode":"00753",
"PlannedDistributions":{},
"PositionBusinessTitle":"Chair",
"PositionEffectiveDate":"2017-04-01T07:00:00.000Z",
"PositionEndDate":null,
"PositionFTEPercent":"100.00000",
"PositionID":"PN-0000809",
"PositionStartDate":"2017-04-01T00:00:00.000Z",
"PositionSupervisor":
{"EmployeeID":"100000115",
"Href":"\/hrp\/v2\/worker\/100000115.json"
},
"PositionTimeTypeID":"Full_time",
"PositionTitle":"PROFESSOR, School of Medicine",
"PositionType":"Regular_Practice_Plan",
"ServicePeriodDescription":"Service_Period_12.00",
"ServicePeriodID":"12",
"SubObjectCode":"10",
"SupervisoryOrganization":
{"AcademicUnitID":null,
"Code":"SOM:",
"CostCenter":
{"Description":"DOM PAYROLL SUSPENSE",
"ID":"656131",
"OrganizationCode":"3040510019",
"OrganizationDescription":"FINANCE ABC\/DEANS HR"
},
"Description":"School of Medicine (Dean, Bill)",
"Href":"\/hrp\/v2\/organization\/SOM_000001.json",
"ID":"SOM_000001",
"Name":"School of Medicine"
},
"TotalBasePayAmount":"0.00000",
"TotalBasePayAnnualizedAmount":"0.00000",
"TotalBasePayFrequency":"Monthly",
"TotalPayAnnualizedAmount":"0.00000",
"WorkShift":"First Shift"
}
]
}

0 comments on commit 3133693

Please sign in to comment.