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
def handle(self, isPost): # Fetch all instructor instances, place them in a dictionary based on key instructors = {} for instructor in Instructor.query_user(self.user_key).fetch(): iid = str(instructor.key.id()) instructors[iid] = instructor if isPost: instructor.name = self.user.full_name = self.request.get('name-' + iid) instructor.email = self.request.get('email-' + iid) instructor.put() if isPost: action = self.request.get('action') if action.startswith('off-'): iid = action[4:] term = Term.build_term(self.request.get('sem-' + iid), self.request.get('year-' + iid)) self.redirect(uri_for('manage-instructor-office', iid=iid, term=term), True) elif action.startswith('del-'): iid = action[4:] instructors[iid].key.delete() del instructors[iid] elif action == 'new': instructor = Instructor.create(self.user_key) instructor.put() instructors[str(instructor.key.id())] = instructor self.send_page(LIST_TEMP, { 'instructors': instructors, })
def post_step_8(self): self.syll.calendar.notes = self.request.get('notes') self.syll.calendar.final = date( Term.term_year(self.syll.term), sint(self.request.get("monthfinal"), 1), sint(self.request.get("dayfinal"), 1)) self.syll.calendar.final_desc = self.request.get("descfinal") i = 1 for cent in self.syll.calendar.entries: cent.reading = self.request.get('reading' + str(i)).strip() cent.topic = self.request.get('topic' + str(i)).strip() i += 1 self.syll.calendar.weekly = self.request.get('weekly') == 'true' start = date(Term.term_year(self.syll.term), sint(self.request.get("monthstart"), 1), sint(self.request.get("daystart"), 1)) end = date(start.year, sint(self.request.get("monthend"), 1), sint(self.request.get("dayend"), 1)) if end < start: end = end.replace(start.year + 1) self.syll.calendar.update(self.syll.meetTimes, start, end)
def handle(self, isPost, iid, term): if iid is None: instructor = self.user.instructor office = instructor.get_office_user_term(self.user_key, term) else: instructor = Instructor.get_by_id(sint(iid), parent=self.user_key) office = instructor.get_office_term(term) if isPost: office.room = self.request.get("room") office.phone = self.request.get("phone") i = 1 for t in office.times: 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': office.add() elif action != '' and action != 'return': index = sint(action, -1) if index >= 0: office.remove_index(index) office.put() if action == 'return': if iid is None: self.redirect(uri_for('manage-profile'), abort=True) else: self.redirect(uri_for('manage-instructor'), abort=True) self.send_page(OFFICE_TEMP, { 'instructor': instructor, 'office': office, 'term': term, 'term_name': Term.get_extended(term), })
def handle(self, isPost): error = "" if isPost: self.user.instructor.name = self.request.get('name') self.user.instructor.email = self.request.get('email') newpass = self.request.get('newpass1') if len(newpass) > 0: if newpass != self.request.get('newpass2'): error = "New password does not match." else: try: retdict = self.auth.get_user_by_password( self.user_name, self.request.get('oldpass'), save_session=False) if retdict['user_id'] == self.user_info['user_id']: self.user.set_password(newpass) error = "Password change successful." else: error = "Invalid session." except (InvalidAuthIdError, InvalidPasswordError): error = "Invalid password." self.user.put() if self.request.get('action') == 'office': term = Term.build_term(self.request.get('sem'), self.request.get('year')) self.redirect(uri_for('manage-profile-office', term=term), True) self.send_page(PROFILE_TEMP, { 'instructor': self.user.instructor, 'error': error, })
def term_string(self): return Term.get_extended(self.term)
def build_id_ext(cls, semester, year, name): return cls.build_id(Term.build_term(semester, year), name)