Skip to content

Commit

Permalink
Merge pull request #13 from uw-it-aca/feature/purp-gold
Browse files Browse the repository at this point in the history
adding purplegold support
  • Loading branch information
devights committed Oct 13, 2020
2 parents 791cdd1 + d197762 commit c849739
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
6 changes: 6 additions & 0 deletions uw_adsel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def assign_cohorts_manual(self, cohort_assignment):
response = self._post_resource(url, request)
return {"response": response, "request": request}

def assign_purple_gold(self, pg_assignments):
url = "{}/assignments/purpleAndGold".format(self.API)
request = pg_assignments.json_data()
response = self._post_resource(url, request)
return {"response": response, "request": request}

def get_quarters(self, **kwargs):
url = "{}/academicqtr".format(self.API)
response = self._get_resource(url)
Expand Down
24 changes: 24 additions & 0 deletions uw_adsel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ def json_data(self):
'systemKey': self.system_key}


class PurpleGoldApplication(Application):
award_amount = models.IntegerField()

def json_data(self):
return {'admissionSelectionId': self.adsel_id,
'applicationNbr': self.application_number,
'systemKey': self.system_key,
'awardAmount': self.award_amount}


class Assignment(models.Model):
assignment_type = models.CharField()
quarter = models.IntegerField()
Expand Down Expand Up @@ -107,3 +117,17 @@ def json_data(self):
'comments': self.comments,
'decisionImportUser': self.user}
}


class PurpleGoldAssignment(Assignment):
def json_data(self):
applicant_json = []
for application in self.applicants:
applicant_json.append(application.json_data())
return {'applicants': applicant_json,
'assignmentDetail': {'assignmentType': self.assignment_type,
'academicQtrKeyId': self.quarter,
'campus': self.campus,
'comments': self.comments,
'decisionImportUser': self.user}
}
17 changes: 17 additions & 0 deletions uw_adsel/resources/adsel/file/api/v1/assignments/purpleAndGold
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"summaryPostStatus": "string",
"items": [
{
"status": "string",
"application": {
"admissionSelectionId": 0,
"applicationNbr": 0,
"systemKey": 0
},
"cohortNbr": 0,
"majorAbbr": "string",
"message": "string"
}
],
"message": "string"
}
31 changes: 30 additions & 1 deletion uw_adsel/tests/test_adsel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from restclients_core.exceptions import DataFailureException
from uw_adsel.utilities import fdao_adsel_override
from uw_adsel import AdSel
from uw_adsel.models import CohortAssignment, MajorAssignment, Application
from uw_adsel.models import CohortAssignment, MajorAssignment, Application,\
PurpleGoldApplication, PurpleGoldAssignment
from datetime import datetime


Expand Down Expand Up @@ -123,3 +124,31 @@ def test_post(self):
def test_get_all_app(self):
apps = self.adsel.get_all_applications_by_qtr(0)
self.assertEqual(len(apps), 4)

def test_purple_gold_assignment(self):
a1 = PurpleGoldApplication()
a1.adsel_id = 123
a1.system_key = 41
a1.application_number = 1
a1.award_amount = 1000
a2 = PurpleGoldApplication()
a2.adsel_id = 734
a2.system_key = 34
a2.application_number = 5
a2.award_amount = 2000

purple_gold_assign = PurpleGoldAssignment()
purple_gold_assign.applicants = [a1, a2]
purple_gold_assign.assignment_type = "upload"
purple_gold_assign.quarter = 0
purple_gold_assign.campus = 1
purple_gold_assign.comments = "My comment"
purple_gold_assign.user = "javerage"

json_data = purple_gold_assign.json_data()
self.assertEqual(json_data['applicants'][0]['awardAmount'], 1000)

try:
submission = self.adsel.assign_purple_gold(purple_gold_assign)
except Exception:
self.fail('assign_purple_gold raised an exception')

0 comments on commit c849739

Please sign in to comment.