Exemplo n.º 1
0
async def completed(request):
    args = request.args

    if 'msg' not in args:
        return html(template('response.html').\
            render(message='Error: Bad Request', error=True))

    return html(template('response.html').render(message=args['msg'][0]))
Exemplo n.º 2
0
async def index(request):
    message = None
    if 'message' in request.args:
        message = request.args['message'][0]
        if message.startswith("Error"):
            return html(
                template('index.html').render(message=message, error=True))
        else:
            return html(
                template('index.html').render(message=message, error=False))
        return html(
            template('index.html').render(message=request.args['message'][0]))
    return html(template('index.html').render())
Exemplo n.º 3
0
async def contact(request):
    if request.method == 'GET':
        return html(template('contact.html').render())
    else:
        name = request.form.get('name')
        email = request.form.get('email')
        subject = request.form.get('subject')
        message = request.form.get('message')

        mailer, url = Mailer(), None
        try:
            mailer.send_message(name, email, subject, message)
            url = app.url_for('index', message='Your message was sent!')
        except:
            url = app.url_for('index', message='Error: message failed to send')
        return redirect(url)
Exemplo n.º 4
0
async def display_request(request):
    args = request.args

    if 'uid' not in args or 'cid' not in args or 'token' not in args:
        return html(template('response.html').\
            render(message='Error: Bad Request', error=True))

    uid, cid, token = args['uid'][0], args['cid'][0], args['token'][0]

    if not db.validate_course_request(uid, cid, token):
        return html(template('response.html').\
            render(message='Error: Invalid or expired request', error=True))

    user = db.get_users_info(uid)
    course = db.get_course_info(cid)

    if user is None:
        return html(template('response.html').\
            render(message='Error: User no longer exists', error=True))
    if course is None:
        return html(template('response.html').\
            render(message='Error: Course no longer exists', error=True))

    first, last, email = user
    leader, year, gender = course

    if leader.endswith('s'):
        leader += "'"
    else:
        leader += "'s"

    message = 'Sign in to add {} ({} {}) to {} {} {}'.format(email, first, last,
                                                   leader, year, gender)
    action = '{}/request/complete'.format(baseURI)

    if 'error' in args:
        return html(template('request.html').\
            render(message=message, action=action, uid=uid, group_id=cid,
                   token=token, id_name='cid', error=args['error'][0]))
    else:
        return html(template('request.html').\
            render(message=message, action=action, uid=uid, group_id=cid,
                   token=token, id_name='cid'))
Exemplo n.º 5
0
async def display_request(request):
    args = request.args

    if 'uid' not in args or 'tid' not in args or 'token' not in args:
        return html(template('response.html').\
            render(message='Error: Bad Request', error=True))

    uid, tid, token = args['uid'][0], args['tid'][0], args['token'][0]

    if not db.validate_team_request(uid, tid, token):
        return html(template('response.html').\
            render(message='Error: Invalid or expired request', error=True))

    user = db.get_users_info(uid)
    team = db.get_team_info(tid)

    if user is None:
        return html(template('response.html').\
            render(message='Error: User does not exist', error=True))
    if team is None:
        return html(template('response.html').\
            render(message='Error: Team does not exist (or no longer exists)',
                   error=True))

    first, last, email = user
    (name, ) = team

    message = 'Sign in to add {} ({} {}) to {} Team'.format(
        email, first, last, name)
    action = '{}/request/complete'.format(baseURI)

    if 'error' in args:
        return html(template('request.html').\
            render(message=message, action=action, uid=uid, group_id=tid,
                   token=token, id_name='tid', error=args['error'][0]))
    else:
        return html(template('request.html').\
            render(message=message, action=action, uid=uid, group_id=tid,
                   token=token, id_name='tid'))
Exemplo n.º 6
0
async def index(request):
    return html(template('index.html').render())
Exemplo n.º 7
0
async def frogger(request):
    return html(template('frogger.html').render())
Exemplo n.º 8
0
async def openai(request):
    return html(template('openai.html').render())
Exemplo n.º 9
0
async def climb(request):
    return html(template('climb.html').render())