Example #1
0
    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')
Example #2
0
    def post(self):
        """
        Attempt to persist the learner data in the GAE datastore and in the
        session, send the email, and redirect to the certificate view.
        """
        state = LearnerState(self.session)

        # fake that we've really completed the scenarios
        self.session.setdefault('completed', {})
        for s in scenario_order:
            self.session['completed'][s] = datetime.now().isoformat()

        # persist the learner data
        try:
            name = self.request.params.get('learner_name', "")
            board_id = self.request.params.get('learner_board_id', "")
            date = self.request.params.get('learner_date', "")
            state.persist_learner(name, board_id, date)
        except InvalidLearnerException:
            self.redirect('/cheater')
            return

        # redirect to the certificate view
        self.redirect('/certificate')