Exemplo n.º 1
0
def register(request):
    if request.method == 'GET':
        from logic.models import User
        new_user = User()
        new_user.uid = request.GET['reg_user']
        new_user.password = request.GET['reg_password']
        password_again = request.GET['reg_password_again']
        new_user.name = request.GET['reg_name']
        new_user.lobby_id = 0
        new_user.iconnum = request.GET['iconnum']
        new_user.status = 10000
        new_user.latest_time = "2015-01-01 12:00:00"
        new_user.score = 0
        new_user.win_num = 0
        new_user.tie_num = 0
        new_user.lose_num = 0
        dict1 = {'login': '******', 'reg': '0' }
        form = RegisterForm()
        all_lobbies = Lobby.objects.all()
        lobbies = []
        lobby_length = all_lobbies.__len__()
        for i in range(0, lobby_length):
            user_num = User.objects.filter(lobby_id=(i+1)).__len__()
            lobby = {
                'user_num': user_num,
                'lobby_name': all_lobbies[i].name
            }
            lobbies.append(lobby)
        if new_user.password == password_again :
            if not has_same_uid(new_user):
                new_user.save()
                return render(request, 'index.html', {
                    'Dict': json.dumps(dict1),
                    'lobbies': lobbies,
                    'form': form,
                })
            else:
                dict1['reg'] = '1'
                return render(request, 'index.html', {
                    'Dict': json.dumps(dict1),
                    'lobbies': lobbies,
                    'form': form,
                })
        else:
            dict1['reg'] = '2'
            return render(request, 'index.html', {
                'Dict': json.dumps(dict1),
                'lobbies': lobbies,
                'form': form,
            })
Exemplo n.º 2
0
def register(request):
    if request.method == 'GET':
        from logic.models import User
        new_user = User()
        new_user.uid = request.GET['reg_user']
        new_user.password = request.GET['reg_password']
        password_again = request.GET['reg_password_again']
        new_user.name = request.GET['reg_name']
        new_user.lobby_id = 0
        new_user.iconnum = request.GET['iconnum']
        new_user.status = 10000
        new_user.latest_time = "2015-01-01 12:00:00"
        new_user.score = 0
        new_user.win_num = 0
        new_user.tie_num = 0
        new_user.lose_num = 0
        dict1 = {'login': '******', 'reg': '0'}
        form = RegisterForm()
        all_lobbies = Lobby.objects.all()
        lobbies = []
        lobby_length = all_lobbies.__len__()
        for i in range(0, lobby_length):
            user_num = User.objects.filter(lobby_id=(i + 1)).__len__()
            lobby = {'user_num': user_num, 'lobby_name': all_lobbies[i].name}
            lobbies.append(lobby)
        if new_user.password == password_again:
            if not has_same_uid(new_user):
                new_user.save()
                return render(request, 'index.html', {
                    'Dict': json.dumps(dict1),
                    'lobbies': lobbies,
                    'form': form,
                })
            else:
                dict1['reg'] = '1'
                return render(request, 'index.html', {
                    'Dict': json.dumps(dict1),
                    'lobbies': lobbies,
                    'form': form,
                })
        else:
            dict1['reg'] = '2'
            return render(request, 'index.html', {
                'Dict': json.dumps(dict1),
                'lobbies': lobbies,
                'form': form,
            })
Exemplo n.º 3
0
def register(request):
    if request.method == 'GET':
        from logic.models import User
        new_user = User()
        new_user.uid = request.GET['reg_user']
        new_user.password = request.GET['reg_password']
        password_again = request.GET['reg_password_again']
        new_user.name = request.GET['reg_name']
        new_user.lobby_id = 0
        if new_user.password == password_again:
            if not has_same_uid(new_user):
                new_user.save()
                return HttpResponseRedirect("http://127.0.0.1:8000")
            else:
                return HttpResponse("same name!")
        else:
            return HttpResponse("两次密码输入不一致!")
Exemplo n.º 4
0
def register(request):
    if request.method == 'GET':
        from logic.models import User
        new_user = User()
        new_user.uid = request.GET['reg_user']
        new_user.password = request.GET['reg_password']
        password_again = request.GET['reg_password_again']
        new_user.name = request.GET['reg_name']
        new_user.lobby_id = 0
        if new_user.password == password_again:
            if not has_same_uid(new_user):
                new_user.save()
                return HttpResponseRedirect("http://127.0.0.1:8000")
            else:
                return HttpResponse("same name!")
        else:
            return HttpResponse("两次密码输入不一致!")