Skip to content

Commit

Permalink
Merge pull request #57 from uw-it-aca/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
fanglinfang committed Jan 4, 2018
2 parents 08cf8be + c4bc2bf commit c91c4d1
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 11 deletions.
60 changes: 55 additions & 5 deletions uw_sws/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,12 @@ class Section(models.Model):
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()
section_type = models.CharField(max_length=30, null=True)
is_independent_study = models.NullBooleanField(default=False)
independent_study_instructor_regid = models.CharField(max_length=32,
null=True)
institute_name = models.CharField(max_length=200, null=True)
metadata = models.CharField(max_length=100, null=True)
class_website_url = models.URLField(max_length=255,
blank=True)
sln = models.PositiveIntegerField()
Expand Down Expand Up @@ -590,7 +591,7 @@ def canvas_course_sis_id(self):
self.course_number,
self.section_id.upper())

if self.is_independent_study:
if self.is_ind_study():
if self.independent_study_instructor_regid is None:
raise InvalidCanvasIndependentStudyCourse(
"Undefined " +
Expand All @@ -610,7 +611,7 @@ def canvas_section_sis_id(self):
if self.is_primary_section:
sis_id = self.canvas_course_sis_id()

if not self.is_independent_study and len(self.linked_section_urls):
if not self.is_ind_study() and len(self.linked_section_urls):
raise InvalidCanvasSection(sis_id)

sis_id += "--"
Expand Down Expand Up @@ -660,13 +661,62 @@ def is_same_summer_term(self, summer_term):
self.summer_term is not None and summer_term is not None and\
self.summer_term.lower() == summer_term.lower()

def is_clerkship(self):
return self.section_type is not None and\
(self.section_type.lower() == "clerkship" or
self.section_type.lower() == "ck")

def is_clinic(self):
return self.section_type is not None and\
(self.section_type.lower() == "clinic" or
self.section_type.lower() == "cl")

def is_conference(self):
return self.section_type is not None and\
(self.section_type.lower() == "conference" or
self.section_type.lower() == "co")

def is_lab(self):
return self.section_type is not None and\
(self.section_type.lower() == "laboratory" or
self.section_type.lower() == "lb")

def is_lecture(self):
return self.section_type is not None and\
(self.section_type.lower() == "lecture" or
self.section_type.lower() == "lc")

def is_ind_study(self):
return self.is_independent_study

def is_practicum(self):
return self.section_type is not None and\
(self.section_type.lower() == "practicum" or
self.section_type.lower() == "pr")

def is_quiz(self):
return self.section_type is not None and\
(self.section_type == "quiz" or
self.section_type.lower() == "qz")

def is_seminar(self):
return self.section_type is not None and\
(self.section_type.lower() == "seminar" or
self.section_type.lower() == "sm")

def is_studio(self):
return self.section_type is not None and\
(self.section_type.lower() == "studio" or
self.section_type.lower() == "st")

def json_data(self):
data = {
'curriculum_abbr': self.curriculum_abbr,
'course_number': self.course_number,
'section_id': self.section_id,
'is_primary_section': self.is_primary_section,
'is_independent_study': self.is_independent_study,
'is_independent_study': self.is_ind_study(),
'section_type': self.section_type,
'independent_study_instructor_regid':
self.independent_study_instructor_regid,
'course_title': self.course_title,
Expand Down
17 changes: 11 additions & 6 deletions uw_sws/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,21 @@ def _json_to_section(section_data,
section.course_campus = section_data["CourseCampus"]
section.section_id = section_data["SectionID"]
section.institute_name = section_data.get("InstituteName", "")
section.metadata = section_data.get("Metadata", "")
section.primary_lms = section_data.get("PrimaryLMS", None)
section.lms_ownership = section_data.get("LMSOwnership", None)
section.is_independent_start = section_data.get("IsIndependentStart",
False)
section.section_type = section_data["SectionType"]
if "independent study" == section.section_type or\
"IS" == section.section_type:
is_independent_study = True
else:
is_independent_study = False

section.is_independent_study = section_data.get(
"IndependentStudy", is_independent_study)

section.credit_control = section_data.get("CreditControl", "")

if "StartDate" in section_data and\
Expand All @@ -303,12 +314,6 @@ def _json_to_section(section_data,
len(section_data["EndDate"]) > 0:
section.end_date = parse(section_data["EndDate"]).date()

section.section_type = section_data["SectionType"]
if "independent study" == section.section_type:
section.is_independent_study = True
else:
section.is_independent_study = False

section.class_website_url = section_data["ClassWebsiteUrl"]

if is_valid_sln(section_data["SLN"]):
Expand Down
15 changes: 15 additions & 0 deletions uw_sws/tests/test_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,31 @@ class SWSTestSectionData(TestCase):
def test_section(self):
section = get_section_by_label('2012,autumn,B BIO,180/A')
self.assertTrue(section.is_campus_bothell())
self.assertTrue(section.is_lecture())
section = get_section_by_label('2013,summer,MATH,125/G')
self.assertTrue(section.is_campus_seattle())
self.assertTrue(section.is_lecture())
section = get_section_by_label('2013,autumn,T BUS,310/A')
self.assertTrue(section.is_campus_tacoma())
self.assertFalse(section.is_lab())
section = get_section_by_label('2013,winter,RES D,630/A')
self.assertTrue(section.is_clinic())
section = get_section_by_label('2013,spring,BIGDATA,230/A')
self.assertFalse(section.is_ind_study())
section = get_section_by_label('2013,summer,PHIL,495/A')
self.assertTrue(section.is_ind_study())
section = get_section_by_label('2013,summer,PHYS,121/AK')
self.assertTrue(section.is_quiz())
section = get_section_by_label('2013,summer,PHYS,121/AQ')
self.assertTrue(section.is_lab())
self.assertIsNotNone(section.json_data())

def test_non_credit_certificate_couse_section(self):
section = get_section_by_label('2013,winter,BIGDATA,220/A')
self.assertTrue(section.is_campus_pce())
self.assertEquals(str(section.start_date), "2013-01-16")
self.assertEquals(str(section.end_date), "2013-03-20")
self.assertEquals(section.metadata, "SectionSourceKey=EOS;")

section = get_section_by_label('2013,spring,BIGDATA,230/A')
self.assertTrue(section.is_campus_pce())
Expand Down

0 comments on commit c91c4d1

Please sign in to comment.