Example #1
0
def public_user_register_contest(account_num, contest):
    # can not register started contest
    if has_started(contest):
        return False

    account_num = public_user.check_account_num_valid(account_num)
    # if invalid
    if account_num == -1:
        return False
    public_contestants = public_user.get_public_contestant(contest)
    need = account_num - len(public_contestants)
    # public contestant attend more than needed, kick some out
    if need < 0:
        public_user.delete_public_contestants(
            public_contestants[account_num:len(public_contestants)])
        return account_num
    # public contestant is not enough
    available_users = public_user.get_available_public_users()
    lack = need - len(available_users)
    # available public user is enough
    if lack <= 0:
        add_contestants_and_activate(available_users[0:need], contest)
    # available public user not enough, then create some
    else:
        new_users = public_user.create_public_users(lack)
        add_contestants_and_activate(new_users, contest)
        add_contestants_and_activate(available_users, contest)
    return account_num
def public_user_register_contest(account_num, contest):
    # can not register started contest
    if has_started(contest):
        return False

    account_num = public_user.check_account_num_valid(account_num)
    # if invalid
    if account_num == -1:
        return False
    public_contestants = public_user.get_public_contestant(contest)
    need = account_num - len(public_contestants)
    # public contestant attend more than needed, kick some out
    if need < 0:
        public_user.delete_public_contestants(\
            public_contestants[account_num:len(public_contestants)])
        return account_num
    #public contestant is not enough
    available_users = public_user.get_available_public_users()
    lack = need - len(available_users)
    # available public user is enough
    if lack <=0:
        add_contestants_and_activate(available_users[0:need], contest)
    # available public user not enough, then create some
    else:
        new_users = public_user.create_public_users(lack)
        add_contestants_and_activate(new_users, contest)
        add_contestants_and_activate(available_users, contest)
    return account_num
Example #3
0
def register_page(request, cid):
    contest = get_contest_or_404(cid)
    groups = get_owned_group(request.user)
    public_user = len(get_public_contestant(contest))
    return render_index(request,
        'contest/register.html',
        {'contest':contest, 'groups':groups,'max_public_user':settings.MAX_PUBLIC_USER,
         'public_user':public_user})
Example #4
0
def register_page(request, cid):
    contest = get_contest_or_404(cid)
    groups = get_owned_group(request.user)
    public_user = len(get_public_contestant(contest))
    return render_index(
        request,
        "contest/register.html",
        {"contest": contest, "groups": groups, "max_public_user": settings.MAX_PUBLIC_USER, "public_user": public_user},
    )
Example #5
0
def get_public_user_password_csv(contest):
    public_contestants = public_user.get_public_contestant(contest)
    response = HttpResponse(content_type='text/csv')
    filename = contest.cname.encode('utf-8') + '-password'
    response['Content-Disposition'] = 'attachment; filename=' + filename

    # init
    writer = csv.writer(response)
    write_public_user_password_csv(writer, contest, public_contestants)

    return response
Example #6
0
def get_public_user_password_csv(contest):
    public_contestants = public_user.get_public_contestant(contest)
    response = HttpResponse(content_type='text/csv')
    filename = contest.cname.encode('utf-8') + '-password'
    response['Content-Disposition'] = 'attachment; filename=' + filename

    # init
    writer = csv.writer(response)
    write_public_user_password_csv(writer, contest, public_contestants)

    return response
Example #7
0
def register_page(request, cid):
    contest = get_contest_or_404(cid)
    groups = get_owned_group(request.user)
    public_user = len(get_public_contestant(contest))
    return render_index(
        request, 'contest/register.html', {
            'contest': contest,
            'groups': groups,
            'max_public_user': settings.MAX_PUBLIC_USER,
            'public_user': public_user
        })