Beispiel #1
0
def add_client():
    form = ClientForm(request.form)
    if form.validate_on_submit():
        client = Client(form.name.data, form.adress.data)
        db_session.add(client)
        db_session.commit()
        flash('Thanks for registering')
        return redirect(url_for('settings'))
    return redirect(url_for('settings'))
Beispiel #2
0
def edit_client(id):
    form = ClientForm()
    if form.validate_on_submit():
        print('cont')
        client = controllers.edit_client(id, form)
        print('/cont')
        return redirect(url_for('client', id=client.id))
    elif request.method == 'GET':
        client = controllers.find_client(id)
        controllers.fill_client_form(client, form)
    return render_template('edit_client.html', client=client, form=form)
Beispiel #3
0
def client():
    form = ClientForm()
    client = Client()
    if form.validate_on_submit():
        client.service_to_client = Service.query.filter_by(name=form.service.data).first()
        client.name = form.username.data.strip()
        client.tel = form.phone.data.strip()
        client.metro, client.exit_num = form.station.data.split('(')
        client.metro = client.metro.strip()
        if client.exit_num:
            client.exit_num = client.exit_num.replace(')', '').strip()
        client.info = form.about.data
        client.cost = form.cost.data
        db.session.add(client)
        db.session.commit()
        return redirect(url_for('client'))
    return render_template('client.html', form=form, service_data=Service.query.all())
Beispiel #4
0
def register():
    form = ClientForm()
    if form.validate_on_submit():
        # hash the password of the form
        hashed = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        # create a new user/client instance with the form fields and commit to our database
        user = UserInfo(first_name=form.first_name.data,
                        last_name=form.last_name.data,
                        email=form.email.data,
                        password=hashed)
        db.session.add(user)
        db.session.commit()
        flash(
            f'User {form.first_name.data} {form.last_name.data}has been created!You can now login in'
        )
        return redirect(url_for('login'))
    else:
        flash('Failed')
    return render_template('register.html', form=form)
def cadastrar_propriedade():
    if 'logged_in' in session:
        print(session['id_usuario'])
        admin = Administrador.query.filter_by(id_usuario=session['id_usuario']).first()
        if admin is not None and admin.client is None:
            form = ClientForm()
            if form.validate_on_submit():
                admin.client = Client()
                admin.client.component = ModuloPrivado(form.nome.data)

                db.session.commit()

                flash('Propriedade cadastrada')
                return redirect(url_for('dashboard.index'))
            return render_template('dashboard/cadastrar_propriedade.html', form=form)
        else:
            flash('Você já tem uma propriedade ou não é administrador do sistema')
            return redirect('/dashboard/')
    else:
        flash('Entre primeiro')
        return redirect('/')
Beispiel #6
0
def create_client():
    form = ClientForm()
    if form.validate_on_submit():
        form.save(current_user)
        return redirect(url_for('home.index'))
    return render_template('auth/create_client.html', form=form)
Beispiel #7
0
def add_client():
    form = ClientForm()
    if form.validate_on_submit():
        client = controllers.add_client(form)
        return redirect(url_for('client', id=client.id))
    return render_template('new_client.html', form=form)