예제 #1
0
파일: views.py 프로젝트: YLAsce/oj
def login(request):
    if request.method != 'POST':
        return redirect('/')

    try:
        username = request.POST['username']
        passwd = request.POST['passwd']
        u = User.getUserByRawUsername(username)
        if u!=None and u!=False and u.checkPasswd(passwd):
            request.session['uid'] = u.uid
            return redirect(referer(request))
        else:
            raise Exception('login err')
    except Exception as e:
        messages.error(request, u'用户名或密码错误')
        return redirect(referer(request))
예제 #2
0
def login(request):
    if request.method != 'POST':
        return redirect('/')

    try:
        username = request.POST['username']
        passwd = request.POST['passwd']
        u = User.getUserByRawUsername(username)
        if u != None and u != False and u.checkPasswd(passwd):
            request.session['uid'] = u.uid
            return redirect(referer(request))
        else:
            raise Exception('login err')
    except Exception as e:
        messages.error(request, u'用户名或密码错误')
        return redirect(referer(request))
예제 #3
0
파일: views.py 프로젝트: YLAsce/oj
def showContest(request):
    logger.info(unicode(request).replace('\n', '\t'))
    try:
        pass
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.WARNING, unicode(e))
        return redirect(referer(request))
예제 #4
0
파일: views.py 프로젝트: Mr-Phoebe/BOJ-V2
def showContest(request):
    logger.info(unicode(request).replace('\n', '\t'))
    try:
        pass
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.WARNING, unicode(e))
        return redirect(referer(request))
예제 #5
0
파일: views.py 프로젝트: Mr-Phoebe/BOJ-V2
def adminLogin(request):
    logger.info(unicode(request).replace('\n', '\t'))
    try:
        if request.method != 'POST':
            return render(request, 'newtpl/register/enter_admin.html', {})

        key = request.POST['key']
        if key != Const.ADMIN_KEY:
            raise Exception('Invalid Key')
        request.session['admin'] = True
        return redirect('Register:view_teams')
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect(referer(request))
        return redirect('Register:admin_login')
예제 #6
0
파일: views.py 프로젝트: YLAsce/oj
def adminLogin(request):
    logger.info(unicode(request).replace('\n', '\t'))
    try:
        if request.method != 'POST':
            return render(request, 'newtpl/register/enter_admin.html', {})

        key = request.POST['key']
        if key != Const.ADMIN_KEY:
            raise Exception('Invalid Key')
        request.session['admin'] = True
        return redirect('Register:view_teams')
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect(referer(request))
        return redirect('Register:admin_login')
예제 #7
0
파일: views.py 프로젝트: YLAsce/oj
def adminLogin(request):
    logger.info(unicode(request).replace("\n", "\t"))
    try:
        if request.method != "POST":
            return render(request, "newtpl/register/enter_admin.html", {})

        key = request.POST["key"]
        if key != Const.ADMIN_KEY:
            raise Exception("Invalid Key")
        request.session["admin"] = True
        return redirect("Register:view_teams")
    except Exception as e:
        logger.error(unicode(e).replace("\n", "\t"))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect(referer(request))
        return redirect("Register:admin_login")
예제 #8
0
파일: views.py 프로젝트: Mr-Phoebe/BOJ-V2
def judgeTeamResult(request, tid, result):
    logger.info(unicode(request).replace('\n', '\t'))
    try:
        admin = request.session.get('admin', None)
        if not admin:
            messages.add_message(request, messages.INFO, u'Not admin!')
            return redirect('Register:admin_login')

        valid_result = False
        for status in Const.TEAM_STATUS:
            if status == result:
                valid_result = True
                break
        if not valid_result:
            raise Exception('Invalid Result')

        tid = int(tid)
        team = Team.getById(tid)
        team.updateStatus(result)
        return redirect('Register:judge_team', tid = tid+1)
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.WARNING, unicode(e))
        return redirect(referer(request))
예제 #9
0
파일: views.py 프로젝트: YLAsce/oj
def judgeTeamResult(request, tid, result):
    logger.info(unicode(request).replace('\n', '\t'))
    try:
        admin = request.session.get('admin', None)
        if not admin:
            messages.add_message(request, messages.INFO, u'Not admin!')
            return redirect('Register:admin_login')

        valid_result = False
        for status in Const.TEAM_STATUS:
            if status == result:
                valid_result = True
                break
        if not valid_result:
            raise Exception('Invalid Result')

        tid = int(tid)
        team = Team.getById(tid)
        team.updateStatus(result)
        return redirect('Register:judge_team')
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.WARNING, unicode(e))
        return redirect(referer(request))