Ejemplo n.º 1
0
def deletebusiness(business_id):
    qry = db.session.query(Business).filter(Business.id == id)

    business = qry.first()
    if Business:
        form = BusinessForm(formdata=request.form, obj=Business)
        if request.method == 'POST' and form.validate():
            business = Business.query.get_or_404(business_id)
            db.session.delete(business)
            db.session.commit()
            flash('Your business has been deleted', 'success')
            return redirect(url_for('available'))
        return render_template('delete.html', form=form)
    else:
        return 'Error deleting #{id}'.format(id=id)
Ejemplo n.º 2
0
def update_business(business_id):
    business = Business.query.get_or_404(business_id)
    form = BusinessForm()
    if form.validate_on_submit():
        business.name = form.name.data
        business.location = form.location.data
        business.business_description = form.business_description.data
        db.session.commit()
        flash(f'Your business has been updated', 'success')
        return redirect(url_for('single_business', business_id=business.id))
    elif request.method == 'GET':
        form.name.data = business.name
        form.location.data = business.location
        form.business_description.data = business.business_description
        return render_template('register_biz.html', title='update', form=form)
Ejemplo n.º 3
0
def businesses():
    form = BusinessForm()
    if form.validate_on_submit():
        business = Business(
            name=form.name.data,
            location=form.location.data,
            started=form.date.data,
            business_description=form.business_description.data)
        db.session.add(business)
        db.session.commit()
        flash(f'Successfully registered {business.name} business', 'success')
        return redirect(url_for('businesses_present'))
    else:
        flash(
            'Your business was not registered. Please check your details and try again ',
            'danger')
    return render_template('register_biz.html',
                           title='Register-biz',
                           form=form)
Ejemplo n.º 4
0
def update_business(business_id):
    business = Business.query.get_or_404(business_id)
    if business.owner != current_user:
        abort(403)
    form = BusinessForm()
    if form.validate_on_submit():
        business.BusinessName = form.BusinessName.data
        business.BusinessLocation = form.BusinessLocation.data
        business.business_description = form.business_description.data
        db.session.commit()
        flash(f'Your business has been updated', 'success')
        return redirect(url_for('single_business', business_id=business.id))
    elif request.method == 'GET':
        form.BusinessName.data = business.BusinessName
        form.BusinessLocation.data = business.BusinessLocation
        form.business_description.data = business.business_description
    return render_template('business.html',
                           title='update',
                           form=form,
                           legend='Update Business',
                           btn='Update')
Ejemplo n.º 5
0
def BusinessFunction():
    form = BusinessForm()
    if form.validate_on_submit():
        business = Business(
            BusinessName=form.BusinessName.data,
            BusinessLocation=form.BusinessLocation.data,
            date_established=form.date_established.data,
            business_description=form.business_description.data)
        db.session.add(business)
        db.session.commit()
        flash(
            f'Your Business {business.BusinessName} has successfully been registered',
            'success')
        return redirect(url_for('available'))
    else:
        flash(
            'Your business not registered please check on your details and try again',
            'danger')
    return render_template('business.html',
                           title='Business',
                           form=form,
                           legend='Register Business',
                           btn='Register')
Ejemplo n.º 6
0
 def setUp(self):
     self.login = LoginForm()
     self.register = RegisterForm()
     self.business = BusinessForm()