From 8c4489f4b88c8dc537d932ff246dae3af5fc1d45 Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Thu, 6 Jul 2017 11:26:24 -0700 Subject: [PATCH] add credit_control in Section --- setup.py | 2 +- uw_sws/models.py | 5 +++++ .../student/v5/course/2013_spring_ELCBUS_451/A.json | 2 +- uw_sws/section.py | 1 + uw_sws/tests/test_section.py | 10 ++++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b82a403..0a56d06 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ author="UW-IT AXDD", author_email="aca-it@uw.edu", include_package_data=True, - install_requires=['UW-RestClients-Core>=0.8.9,<1.0', + install_requires=['UW-RestClients-Core>=0.9,<1.0', 'UW-RestClients-PWS<1.0', 'mock', 'python-dateutil', diff --git a/uw_sws/models.py b/uw_sws/models.py index bd6cb02..209e1ee 100644 --- a/uw_sws/models.py +++ b/uw_sws/models.py @@ -413,6 +413,7 @@ class Section(models.Model): course_title = models.CharField(max_length=20) course_title_long = models.CharField(max_length=50) course_campus = models.CharField(max_length=7) + credit_control = models.CharField(max_length=32, null=True) section_type = models.CharField(max_length=30) is_independent_study = models.NullBooleanField() independent_study_instructor_regid = models.CharField(max_length=32, @@ -583,6 +584,9 @@ def get_grade_date_str(self): return str(self.grade_date) return None + def for_credit(self): + return self.credit_control is not None + def is_summer_a_term(self): return self.summer_term is not None and\ len(self.summer_term) > 0 and\ @@ -627,6 +631,7 @@ def json_data(self): self.limit_estimate_enrollment_indicator, 'auditors': self.auditors, 'meetings': [], + 'for-credit': self.for_credit(), 'credits': str(self.student_credits), 'is_auditor': self.is_auditor, 'grade': self.student_grade, diff --git a/uw_sws/resources/sws/file/student/v5/course/2013_spring_ELCBUS_451/A.json b/uw_sws/resources/sws/file/student/v5/course/2013_spring_ELCBUS_451/A.json index 3508291..6738225 100644 --- a/uw_sws/resources/sws/file/student/v5/course/2013_spring_ELCBUS_451/A.json +++ b/uw_sws/resources/sws/file/student/v5/course/2013_spring_ELCBUS_451/A.json @@ -1 +1 @@ -{"GradingSystem": "standard", "CourseTitle": "FIN PLAN AND PRAC", "Auditors": "0", "PrimarySection": {"CurriculumAbbreviation": "ELCBUS", "SectionID": "A", "Href": "/student/v5/course/2013,spring,ELCBUS,451/A.json", "Year": "2013", "Quarter": "spring", "CourseNumber": "451"}, "CourseDescription": "Emphasizes major current theories and practices in the field of financial management. Topics include financial ratio analysis; break-even analysis; cash, marketable securities, inventory, and accounts receivable management models; dividend policy; short-term and long-term financing decisions; and international finance. Prerequisite: minimum grade of 1.7 in ELCBUS 350.", "LimitEstimateEnrollmentIndicator": "limit", "Curriculum": {"TimeScheduleLinkAbbreviation": ""}, "HonorsCourse": false, "Term": {"Quarter": "spring", "Href": "/student/v5/term/2013,spring.json", "Year": "2013"}, "LimitEstimateEnrollment": "5", "CourseTitleLong": "FINANCIAL POLICY AND PLANNING", "DuplicateEnrollmentAllowed": false, "CourseCampus": "Bothell", "Registrations": {"CurriculumAbbreviation": "ELCBUS", "PageSize": null, "SectionID": "A", "InstructorRegID": null, "Href": "/student/v5/registration.json?year=2013&quarter=spring&curriculum_abbreviation=ELCBUS&course_number=451\u00a7ion_id=A\u00ae_id=&is_active=on&instructor_reg_id=", "Year": "2013", "RegID": null, "PageStart": null, "Quarter": "spring", "CourseNumber": "451", "IsActive": "on"}, "SLN": "11162", "LinkedSectionTypes": [], "ServiceLearning": false, "SectionType": "lecture", "SectionID": "A", "Meetings": [{"Building": "ELC", "MeetingIndex": "1", "RoomNumber": "EVEREST", "Instructors": [{"Person": {"RegID": "FBB38FE46A7C11D5A4AE0004AC494FFE", "Href": "/student/v5/person/FBB38FE46A7C11D5A4AE0004AC494FFE.json", "Name": "TEACHER, BILL AVERAGE"}, "TSPrint": true, "FacultySequenceNumber": "", "GradeRoster": {"Href": "/student/v5/graderoster/2013,spring,ELCBUS,451,A,FBB38FE46A7C11D5A4AE0004AC494FFE"}}], "DaysOfWeek": {"Text": "M W", "Days": [{"Name": "Monday"}, {"Name": "Wednesday"}]}, "MeetingType": "lecture", "RoomToBeArranged": false, "StartTime": "14:30", "DaysOfWeekToBeArranged": false, "EndTime": "19:00", "BuildingToBeArranged": false}], "DeleteFlag": "active", "GeneralEducationRequirements": {"NaturalWorld": false, "Writing": false, "QuantitativeAndSymbolicReasoning": false, "EnglishComposition": false, "IndividualsAndSocieties": false, "VisualLiteraryAndPerformingArts": false}, "springTerm": "A-term", "Course": {"CourseTitleLong": "FINANCIAL POLICY AND PLANNING", "CurriculumAbbreviation": "ELCBUS", "CourseTitle": "FIN PLAN AND PRAC", "Href": "/student/v5/course/2013,spring,ELCBUS,451.json", "Year": "2013", "Quarter": "spring", "CourseNumber": "451"}, "ResearchCredit": false, "GradeSubmissionDelegates": [{"DelegateLevel": "curriculum", "Person": {"RegID": "6DF0A9206A7D11D5A4AE0004AC494FFE", "Href": "/student/v5/person/6DF0A9206A7D11D5A4AE0004AC494FFE.json", "Name": "TEACHER, FRED AVERAGE"}}], "SecondaryGradingOption": false, "ClassWebsiteUrl": "", "CurrentEnrollment": "0"} \ No newline at end of file +{"GradingSystem": "standard", "CourseTitle": "FIN PLAN AND PRAC", "Auditors": "0", "PrimarySection": {"CurriculumAbbreviation": "ELCBUS", "SectionID": "A", "Href": "/student/v5/course/2013,spring,ELCBUS,451/A.json", "Year": "2013", "Quarter": "spring", "CourseNumber": "451"}, "CourseDescription": "Emphasizes major current theories and practices in the field of financial management. Topics include financial ratio analysis; break-even analysis; cash, marketable securities, inventory, and accounts receivable management models; dividend policy; short-term and long-term financing decisions; and international finance. Prerequisite: minimum grade of 1.7 in ELCBUS 350.", "LimitEstimateEnrollmentIndicator": "limit", "Curriculum": {"TimeScheduleLinkAbbreviation": ""}, "HonorsCourse": false, "Term": {"Quarter": "spring", "Href": "/student/v5/term/2013,spring.json", "Year": "2013"}, "LimitEstimateEnrollment": "5", "CourseTitleLong": "FINANCIAL POLICY AND PLANNING", "DuplicateEnrollmentAllowed": false, "CourseCampus": "Bothell", "Registrations": {"CurriculumAbbreviation": "ELCBUS", "PageSize": null, "SectionID": "A", "InstructorRegID": null, "Href": "/student/v5/registration.json?year=2013&quarter=spring&curriculum_abbreviation=ELCBUS&course_number=451\u00a7ion_id=A\u00ae_id=&is_active=on&instructor_reg_id=", "Year": "2013", "RegID": null, "PageStart": null, "Quarter": "spring", "CourseNumber": "451", "IsActive": "on"}, "SLN": "11162", "LinkedSectionTypes": [], "ServiceLearning": false, "SectionType": "lecture", "SectionID": "A", "CreditControl": "zero credits", "Meetings": [{"Building": "ELC", "MeetingIndex": "1", "RoomNumber": "EVEREST", "Instructors": [{"Person": {"RegID": "FBB38FE46A7C11D5A4AE0004AC494FFE", "Href": "/student/v5/person/FBB38FE46A7C11D5A4AE0004AC494FFE.json", "Name": "TEACHER, BILL AVERAGE"}, "TSPrint": true, "FacultySequenceNumber": "", "GradeRoster": {"Href": "/student/v5/graderoster/2013,spring,ELCBUS,451,A,FBB38FE46A7C11D5A4AE0004AC494FFE"}}], "DaysOfWeek": {"Text": "M W", "Days": [{"Name": "Monday"}, {"Name": "Wednesday"}]}, "MeetingType": "lecture", "RoomToBeArranged": false, "StartTime": "14:30", "DaysOfWeekToBeArranged": false, "EndTime": "19:00", "BuildingToBeArranged": false}], "DeleteFlag": "active", "GeneralEducationRequirements": {"NaturalWorld": false, "Writing": false, "QuantitativeAndSymbolicReasoning": false, "EnglishComposition": false, "IndividualsAndSocieties": false, "VisualLiteraryAndPerformingArts": false}, "springTerm": "A-term", "Course": {"CourseTitleLong": "FINANCIAL POLICY AND PLANNING", "CurriculumAbbreviation": "ELCBUS", "CourseTitle": "FIN PLAN AND PRAC", "Href": "/student/v5/course/2013,spring,ELCBUS,451.json", "Year": "2013", "Quarter": "spring", "CourseNumber": "451"}, "ResearchCredit": false, "GradeSubmissionDelegates": [{"DelegateLevel": "curriculum", "Person": {"RegID": "6DF0A9206A7D11D5A4AE0004AC494FFE", "Href": "/student/v5/person/6DF0A9206A7D11D5A4AE0004AC494FFE.json", "Name": "TEACHER, FRED AVERAGE"}}], "SecondaryGradingOption": false, "ClassWebsiteUrl": "", "CurrentEnrollment": "0"} diff --git a/uw_sws/section.py b/uw_sws/section.py index 2a41446..6d49940 100644 --- a/uw_sws/section.py +++ b/uw_sws/section.py @@ -266,6 +266,7 @@ def _json_to_section(section_data, section.lms_ownership = section_data.get("LMSOwnership", None) section.is_independent_start = section_data.get("IsIndependentStart", False) + section.credit_control = section_data.get("CreditControl", "") if "StartDate" in section_data and\ len(section_data["StartDate"]) > 0: diff --git a/uw_sws/tests/test_section.py b/uw_sws/tests/test_section.py index b175c1c..a8c16fd 100644 --- a/uw_sws/tests/test_section.py +++ b/uw_sws/tests/test_section.py @@ -530,3 +530,13 @@ def test_normalized_meeting_time(self): jd = section.meetings[0].json_data() self.assertEqual(jd['start_time'], '18:00') self.assertEqual(jd['end_time'], '21:00') + + def test_for_credit_course(self): + section = get_section_by_label('2013,spring,ESS,107/A') + self.assertFalse(section.for_credit()) + section = get_section_by_label('2013,winter,COM,201/A') + self.assertTrue(section.for_credit()) + section = get_section_by_label('2013,spring,ELCBUS,451/A') + self.assertTrue(section.for_credit()) + section = get_section_by_label('2013,spring,TRAIN,100/A') + self.assertTrue(section.for_credit())