Exemplo n.º 1
0
    def generate(self) -> Schedule:
        classes = []

        for C in self.schedule_param.courses:
            assigned_instructors = self._get_assigned_Instructors_for(
                C, )

            for sec_i in range(C.num_of_sections):
                instructor, timeslot, room = self._get_unique_Instr_Timeslot_Room(
                    assigned_instructors, C, classes, )

                section = Section(C, sec_i+1)
                classes.append(Class(section, instructor, room, timeslot))

        return Schedule(classes)
Exemplo n.º 2
0
	def update_sections(self, term):

		sections = self._get_with_session(
			term,
			"searchResults/searchResults?txt_term={term}&pageOffset={offset}&pageMaxSize=500",
			"section(s)"
		)

		self.log(f'[{term}] Updating database')

		for s in sections:

			# We can't use update_or_create() here b/c it calls save() before mandatory fields are set
			crn = s["courseReferenceNumber"]
			try:
				section = Section.objects.get(term=term, crn=crn)
			except Section.DoesNotExist:
				section = Section(term=term, crn=crn)

			try:
				course = Course.objects.get(
					subject__short_title=s["subject"], number=s["courseNumber"]
				)
			except Course.DoesNotExist:
				self.log(f"[crn={crn}] New courses found, please run update courses")
				continue

			section.course = course
			section.section_num = s["sequenceNumber"]
			section.section_title = s["courseTitle"]

			if (credit_hours := s["creditHours"]) is None:
				section.credit_hours = s["creditHourLow"]
			else:
				section.credit_hours = credit_hours

			if faculty := s["faculty"]:
				professor = faculty[0]
				professor_name = professor["displayName"].split(", ")

				section.professor, _ = Professor.objects.update_or_create(
					email=professor["emailAddress"],
					defaults={
						"firstname": professor_name[1],
						"lastname": professor_name[0]
					}
				)
Exemplo n.º 3
0
            id=user_id,
            user=user,
            biography=get_field(old_user, "bio", "(no biography)"),
            position=get_field(old_user, "position", "(no position)"),
            graduation_year=2000 + int(get_field(old_user, "gradyear", -2001)))
        profile.save()

if ask_reimport("categories"):
    Section.objects.all().delete()
    categories = read_table("category")

    for old_category in categories:
        parent_id = int(get_field(old_category, "pid"))
        section = Section(id=get_field(old_category, "id"),
                          parent=(Section.objects.get(
                              id=parent_id) if parent_id > 0 else None),
                          name=get_field(old_category, "url_name"),
                          title=get_field(old_category, "name"))
        section.save()

if ask_reimport("pictures"):
    Image.objects.all().delete()

    reimport_files = ask_reimport("image files")

    for old_pic in read_table("picture"):
        try:
            pic_id = get_field(old_pic, "id")
            date = read_date(get_field(old_pic, "date"))
            pic = Image(id=get_field(old_pic, "id"),
                        title=get_field(old_pic, "title", "(no title)"),