def post(self): """ Attempt to persist the learner data in the appengine datastore and in the session, send the email, and redirect to the certificate view. """ state = LearnerState(self.session) # persist the learner data try: name = self.request.params.get('learner_name', "") board_id = self.request.params.get('learner_board_id', "") state.persist_learner(name, board_id, None) except InvalidLearnerException: logging.warn("caught invalid learner") self.redirect('/learner') return # send the completion email try: name = state.learner_name() board = state.learner_board() send_completion(name, board) except: pass # redirect to the certificate view self.redirect('/certificate')
def get(self, *argv): state = LearnerState(self.session) context = dict( show_prevnext=False, version=VERSION, now=datetime.now(), state=state.as_string(), learner_name=state.learner_name(), learner_board=state.learner_board(), learner_date=state.learner_date(), ) jt = self.jinja_environment().get_template("certificate.djt") self.response.write(jt.render(context))