Skip to content

Commit

Permalink
Updated Person's resident_code and resident_desc
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang committed Dec 5, 2024
1 parent de96a52 commit fe0b021
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
8 changes: 5 additions & 3 deletions uw_sws/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class SwsPerson(models.Model):
permanent_phone = models.CharField(max_length=64, null=True, blank=True)
visa_type = models.CharField(max_length=2, null=True, blank=True)
veteran_code = models.CharField(max_length=2)
resident_code = models.SmallIntegerField(null=True)
resident_code = models.CharField(max_length=2, null=True, blank=True)
resident_desc = models.CharField(max_length=32, null=True, blank=True)

def is_veteran(self):
return self.veteran_code != "0"
Expand Down Expand Up @@ -135,9 +136,10 @@ def json_data(self):
'permanent_address': get_student_address_json(
self.permanent_address),
'permanent_phone': self.permanent_phone,
'visa_type': self.visa_type,
'resident_desc': self.resident_desc,
'resident_code': self.resident_code,
'veteran_code': self.veteran_code,
'resident_code': self.resident_code
'visa_type': self.visa_type
}

def __str__(self):
Expand Down
1 change: 1 addition & 0 deletions uw_sws/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ def _process_json_data(person_data):
person.uwnetid = person_data.get("UWNetID")
person.visa_type = person_data.get("VisaType")
person.resident_code = person_data.get("Resident")
person.resident_desc = person_data.get("ResidencyDescription")

return person
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"PermanentPhone":null,
"RegID":"00000000000000000000000000000001",
"RegisteredName":null,
"ResidencyDescription": null,
"Resident":null,
"StudentName":"SYSTEM OVERHEAD",
"StudentNumber":null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"PermanentPhone":null,
"RegID":"12345678901234567890123456789012",
"RegisteredName":"EIGHT STUDENT",
"Resident":"5",
"ResidencyDescription": "NONRESIDENT CITIZEN",
"Resident": "3",
"StudentName":"Eight Student",
"StudentNumber":"1443336",
"StudentSystemKey":"000083857",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"Zip":""},
"PermanentPhone":null,
"RegID":"9136CCB8F66711D5BE060004AC494F31",
"Resident":null,
"ResidencyDescription": "NONRESIDENT STUDENT VISA",
"Resident": "5",
"StudentName":"Chakrabarti,Japendra",
"StudentNumber":"1233334",
"StudentSystemKey":"000018235",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"Zip":"98005-1234"},
"PermanentPhone":"2065555555",
"RegID":"9136CCB8F66711D5BE060004AC494FFE",
"Resident":1,
"Resident":"1",
"ResidencyDescription": "RESIDENT",
"StudentName":"John Joseph Average",
"StudentNumber":"1033334",
Expand Down
15 changes: 12 additions & 3 deletions uw_sws/tests/test_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_person_resource(self):
"/student/v5/term/2013,autumn.json")
self.assertEqual(data.last_enrolled.quarter, "autumn")
self.assertEqual(data.last_enrolled.year, 2013)
self.assertEqual(data.resident_code, 1)
self.assertEqual(data.resident_code, "1")
self.assertEqual(data.resident_desc, "RESIDENT")

def test_person_jinter(self):
data = get_person_by_regid("9136CCB8F66711D5BE060004AC494F31")
Expand Down Expand Up @@ -89,7 +90,8 @@ def test_person_jinter(self):
self.assertEqual(data.permanent_address.postal_code, "400001")
self.assertEqual(data.permanent_address.state, "Mumbai")
self.assertEqual(data.permanent_address.zip_code, "")
self.assertIsNone(data.resident_code)
self.assertEqual(data.resident_code, "5")
self.assertEqual(data.resident_desc, "NONRESIDENT STUDENT VISA")

data = get_person_by_regid("12345678901234567890123456789012")
self.assertTrue(data.is_J1())
Expand Down Expand Up @@ -118,8 +120,15 @@ def test_person_none(self):
self.assertIsNone(data.permanent_phone)
self.assertIsNone(data.permanent_address)
self.assertIsNone(data.resident_code)
self.assertIsNone(data.resident_desc)

def test_json_datat(self):
def test_json_data(self):
data = get_person_by_regid("9136CCB8F66711D5BE060004AC494FFE")
self.assertEqual(data.json_data()['email'],
"[email protected]")
self.assertEqual(data.json_data()['resident_code'],
"1")
self.assertEqual(data.json_data()['resident_desc'],
"RESIDENT")
self.assertEqual(data.json_data()['visa_type'],
"")

0 comments on commit fe0b021

Please sign in to comment.