コード例 #1
0
ファイル: taevals.py プロジェクト: ucsb-cs/taevals
    def get(self, key, ta='', responses=None, success=None, errors=None):
        invite = EvalInvite.get_by_key_name(key)
        if not invite:
            return self.redirect('/')

        settings = Settings.get_by_key_name('settings')
        invite.expired = datetime.datetime.now() > settings.expire_date
        success = success or []
        errors = errors or []

        remaining = invite.remaining_evals()
        if not remaining and not invite.tas:
            if settings.send_completed_email:
                body = const.COMPLETED_EMAIL_TEMPLATE.format(invite.name)
                try:
                    to_email = '{} <{}>'.format(invite.name, invite.email)
                    mail.send_mail(settings.admin_email, to_email,
                                   const.COMPLETED_EMAIL_SUBJECT, body)
                except apiproxy_errors.OverQuotaError as message:
                    logging.error(message)
            completed = Completed(name=invite.name, email=invite.email)
            completed.put()
            invite.delete()
            questions = None
        else:
            if not responses:
                responses = [''] * len(const.QUESTIONS)
            questions = zip(const.QUESTIONS, responses)

        values = {'invite': invite, 'success': success, 'errors': errors,
                  'sel_ta': ta, 'questions': questions, 'remaining': remaining}
        template = jinja_environment.get_template('eval.html')
        self.response.out.write(template.render(values))
コード例 #2
0
ファイル: taevals.py プロジェクト: ucsb-cs/taevals
 def reset(self):
     if self.request.get('confirm') != '0xDEADBEEF':
         self.get(errors=['Invalid confirmation'])
     else:
         keys = [x for x in EvalInvite.all(keys_only=True)]
         keys.extend([x for x in Eval.all(keys_only=True)])
         keys.extend([x for x in Completed.all(keys_only=True)])
         for i in range(int(math.ceil(len(keys) * 1. / MAX_DELETES))):
             db.delete(keys[i * MAX_DELETES:(i + 1) * MAX_DELETES])
         self.get(successes=['Reset Database'])