示例#1
0
    def create(cls, user_key, sid, old=None):
        if user_key is None or not user_key.kind() == 'User':
            raise ValueError("Invalid parent.")
        term = sid.split("/")[0]

        syllabus = Syllabus(id=sid, parent=user_key, term=term)

        if old is None:
            syllabus.populate(
                **{
                    'meetTimes': [MeetingTime.create()],
                    'sections': [],
                    'textbooks': [],
                    'asmt': [],
                    'scale': [GradeScale.create() for i in range(14)],
                    'policies': [],
                    'calendar': Calendar.create(term),
                })
        else:
            syllabus.populate(**old.to_dict())

        syllabus.term = term
        syllabus.calendar.update(syllabus.meetTimes, Term.start_date(term),
                                 Term.end_date(term))
        syllabus.active = False
        syllabus.currstep = 1

        syllabus.put()
        return syllabus
示例#2
0
    def scrape_populate(self, course_info):
        self.course.dept = course_info[0]
        self.course.num = course_info[1]
        self.courseName = course_info[2]

        sections = course_info[3]
        if len(sections) > 0:
            self.room = sections[0].room
            self.meetTimes = MeetingTime.parse_strings(sections[0].days,
                                                       sections[0].hours)
            self.suggestion = sections[0].instructor

            self.sections = []
            for sect_data in sections[1:]:
                section = Section.create(
                    sect_data.name, sect_data.room,
                    sect_data.days + " " + sect_data.hours, None,
                    sect_data.instructor)
                self.sections.append(section)
        print "will modify here"
    def post_step_2(self):
        self.syll.course = CourseID.create(self.request.get('dept'),
                                           sint(self.request.get('num')))
        self.syll.courseName = self.request.get('course_title')
        self.syll.room = self.request.get('room')

        iid = self.request.get('instructor')
        print self.syll.instructor
        if iid == 'none':
            self.syll.instructor = None
        else:
            try:
                self.syll.instructor = self.instructors_list[iid].key
                print "success"
            except KeyError:
                self.syll.instructor = None

        i = 1
        for t in self.syll.meetTimes:
            t.weekday = sint(self.request.get('day' + str(i)))
            t.set_start_12h(sint(self.request.get('starth' + str(i))),
                            sint(self.request.get('startm' + str(i))),
                            self.request.get('startp' + str(i)) == 'y')
            t.set_dur(sint(self.request.get('durh' + str(i))),
                      sint(self.request.get('durm' + str(i))))
            i += 1

        action = self.request.get('action')

        if action == 'new':
            self.syll.meetTimes.append(MeetingTime.create())
        elif action != '' and len(self.syll.meetTimes) > 1:
            index = sint(action, -1) - 1
            if index >= 0:
                self.syll.meetTimes.remove(self.syll.meetTimes[index])

        self.syll.calendar.update(self.syll.meetTimes)
示例#4
0
 def schedule_string(self):
     return MeetingTime.build_string(self.meetTimes, True)
示例#5
0
 def test_getstartHour(self):
     m = MeetingTime(startMins=600)
     self.assertEqual(m.get_start_hour(), 10)
示例#6
0
 def test_set_dur(self):
     i = MeetingTime(durMins=0)
     i.set_dur(1,45)
     self.assertEqual(i.durMins, 105)
示例#7
0
 def test_add_to_Datastore(self):
     mtime = MeetingTime(weekday=4, startMins=600, durMins=50)
     mtime.put()
     self.assertEqual(1, len(MeetingTime.query().fetch()))
示例#8
0
 def test_set_start(self):
     i = MeetingTime(startMins=0)
     i.set_start(1,50)
     self.assertEqual(i.startMins, 110)
示例#9
0
 def test_getDurMin(self):
     start = MeetingTime(weekday=2, startMins=600, durMins=50)
     self.assertEqual(start.get_dur_min(), 50)
示例#10
0
 def test_get_start_min(self):
     m = MeetingTime(startMins=50)
     self.assertEqual(m.get_start_min(), 50)
示例#11
0
 def test_get_start_pm(self):
     m = MeetingTime(startMins=1200)
     m.get_start_pm()
     self.assertTrue(m.get_start_pm())
示例#12
0
 def test_getstartHour_12h(self):
     m = MeetingTime(startMins=50)
     self.assertEqual(m.get_start_hour(), 0)