Example #1
0
def set_concern_teams(request):
    generator = BoardGenerator()
    problems = generator.get_problems()
    standing = generator.make_board()
    if request.method == "POST":
        request.session["concern"] = request.POST.getlist("concern_list")
        return show_concerned_ranklist(request)
    if "concern" not in request.session:
        request.session["concern"] = []
    for st in standing:
        if unicode(st["teamId"]) in request.session["concern"]:
            st["concern"] = True
    return render_to_response("ranklist_concern.html", locals(), context_instance=RequestContext(request))
Example #2
0
def set_concern_teams(request):
    generator = BoardGenerator()
    problems = generator.get_problems()
    standing = generator.make_board()
    if request.method == 'POST':
        request.session['concern'] = request.POST.getlist('concern_list')
        return show_concerned_ranklist(request)
    if 'concern' not in request.session:
        request.session['concern'] = []
    for st in standing:
        if unicode(st['teamId']) in request.session['concern']:
            st['concern'] = True
    return render_to_response('ranklist_concern.html',
                              locals(),
                              context_instance=RequestContext(request))
Example #3
0
def export_file(no):
    generator = BoardGenerator()
    problems = generator.get_problems()
    board = generator.make_real_board()
    file_name = EXPORT['name'][no]
    file_path = (FILE_PATH + file_name).encode('utf-8')
    if no == '4':
        board = filter2(board)
        CsvWriter.set_item_list(board, file_name, EXPORT['keys2'], EXPORT['header2'])
    else:
        board = filter(no, board)
        CsvWriter.set_item_list(board, file_name, EXPORT['keys'], EXPORT['header'])
    response = HttpResponse(open(file_path, 'r'), content_type='APPLICATION/OCTET-STREAM') #设定文件头,这种设定可以让任意文件都能正确下载,而且已知文本文件不是本地打开
    response['Content-Disposition'] = 'attachment; filename='+file_name.encode('utf-8')  #设定传输给客户端的文件名称
    response['Content-Length'] = os.path.getsize(file_path)#传输给客户端的文件大小
    return response
Example #4
0
def export_file(no):
    generator = BoardGenerator()
    problems = generator.get_problems()
    board = generator.make_real_board()
    file_name = EXPORT['name'][no]
    file_path = (FILE_PATH + file_name).encode('utf-8')
    if no == '4':
        board = filter2(board)
        CsvWriter.set_item_list(board, file_name, EXPORT['keys2'], EXPORT['header2'])
    else:
        board = filter(no, board)
        CsvWriter.set_item_list(board, file_name, EXPORT['keys'], EXPORT['header'])
    response = HttpResponse(open(file_path, 'r'), content_type='APPLICATION/OCTET-STREAM') #设定文件头,这种设定可以让任意文件都能正确下载,而且已知文本文件不是本地打开
    response['Content-Disposition'] = 'attachment; filename='+file_name.encode('utf-8')  #设定传输给客户端的文件名称
    response['Content-Length'] = os.path.getsize(file_path)#传输给客户端的文件大小
    return response
Example #5
0
def show_ranklist(request, is_concern=False, is_display=False):
    generator = BoardGenerator()
    header = generator.get_header()
    problems = generator.get_problems()
    for pb in problems:
        pb["id"] = chr(pb["id"] + ord("A") - 1)
    board = generator.make_board()
    if is_concern:
        standing = []
        for bd in board:
            if unicode(bd["teamId"]) in request.session["concern"]:
                standing.append(bd)
    else:
        standing = board
    if is_display:
        return render_to_response("ranklist_display.html", locals(), context_instance=RequestContext(request))
    else:
        return render_to_response("ranklist_show.html", locals(), context_instance=RequestContext(request))
Example #6
0
def show_ranklist(request, is_concern=False, is_display=False):
    generator = BoardGenerator()
    header = generator.get_header()
    problems = generator.get_problems()
    for pb in problems:
        pb['id'] = chr(pb['id'] + ord('A') - 1)
    board = generator.make_board()
    if is_concern:
        standing = []
        for bd in board:
            if unicode(bd['teamId']) in request.session['concern']:
                standing.append(bd)
    else:
        standing = board
    if is_display:
        return render_to_response('ranklist_display.html',
                                  locals(),
                                  context_instance=RequestContext(request))
    else:
        return render_to_response('ranklist_show.html',
                                  locals(),
                                  context_instance=RequestContext(request))