예제 #1
0
def registr():
    context = {'Error': []}
    user_type = UserTypeManager()
    user_type.getTypeUser()
    if session.get('username', None):
        user = UserManager.load_models[session['username']]
        user_type.getTypeGroup()
        context['user'] = user
    context['type'] = user_type

    if request.method == 'POST':
        user = UserManager().getModelFromForm(request.form)
        if user.check_user():
            context['Error'].append('wrong name or email')
        if user.object.type.type_name == 'user':
            if not user.object.password:
                context['Error'].append('incorrect password')
        if context['Error']:
            return render_template('registration.html', context=context)
        if user.save():
            UserManager.load_models[user.object.nickname] = user
            addToSession(user)
            return redirect(url_for('home'))
        context['Error'].append('incorrect data')
    return render_template('registration.html', context=context)
예제 #2
0
def registr_group():
    context = {'Error': []}
    if request.method == 'POST':
        user = UserManager().getModelFromForm(request.form)
        print(user.object.nickname)
        if user.check_user():
            context['Error'].append('wrong Name or email')
        if context['Error']:
            return render_template('registration.html', context=context)
        if user.save_group:
            print("ok")
            return redirect(url_for('home'))

        context['Error'].append('incorrect data')
    return render_template('registration.html', context=context)
예제 #3
0
def registration():
    print('hey man1')
    context = {'Error': []}
    if session.get('username') and request.method == 'GET':
        print('hey man2')
        nickname = session.get('username')
        user = UserManager()
        if user.SelectUser(nickname):
            print(user.object.id)
            print(user)
            context['user'] = user
            context['group'] = True
            if user.save():
                return redirect(url_for('home'))
            else:
                return ('shit')
        else:
            context['group'] = False
        print(context['group'])
    elif request.method == 'POST':
        user = UserManager().getModelFromForm(request.form)
        if user.check_user():
            context['Error'].append('wrong nickname or email')
        if not user.object.password:
            context['Error'].append('incorrect password')
        if context['Error']:
            return render_template('registration.html', context=context)
        if user.save():
            UserManager.load_models[user.object.nickname] = user
            addToSession(user)
            return redirect(url_for('home'))

            context['Error'].append('incorrect data')
        return render_template('registr.html', context=context)
    else:
        context['group'] = False
        print('hey man 2.1')
        print(context['group'])
    return render_template('registr.html', context=context)