コード例 #1
0
def edit(request):
    """customer edit """
    id = request.matchdict['id']
    dbsession = DBSession()
    customer = dbsession.query(Customer).filter_by(id=id).one()
    print customer
    address = dbsession.query(Address).filter_by(user_id=id).one()
    
    
    if customer is None or address is None:
        request.session.flash("error;Customer not found!")
        return HTTPFound(location=request.route_url("customer_list"))        
    

    generalForm = Form(request, schema=CustomerForm, obj=customer)
    locationForm = Form(request, schema=LocationForm, obj=address)
       
    if "general_submitted" in request.POST and generalForm.validate():
        generalForm.bind(customer)
        dbsession.add(customer)
        request.session.flash("success; Successful call to update customer")
    if "location_submitted" in request.POST:
        locationForm.bind(address)
        dbsession.add(address)
        request.session.flash("success; Successful call to update location")
        


    action_url = request.route_url("customer_edit", id=id)
    return dict(generalForm=FormRenderer(generalForm),
                locationForm=FormRenderer(locationForm), 
                action_url=action_url)
コード例 #2
0
def new(request):
    """new country """
    form = Form(request, schema=CountryForm)    
    if "form_submitted" in request.POST and form.validate():
        dbsession = DBSession()
        country = form.bind(Country())
        # TODO: db error control?
        dbsession.add(country)
        request.session.flash("warning;New Country is saved!")
        return HTTPFound(location = request.route_url("country_list"))
        
    return dict(form=FormRenderer(form), 
                action_url=request.route_url("country_new"))
コード例 #3
0
def new(request):
    """new country """
    form = Form(request, schema=CountryForm)
    if "form_submitted" in request.POST and form.validate():
        dbsession = DBSession()
        country = form.bind(Country())
        # TODO: db error control?
        dbsession.add(country)
        request.session.flash("warning;New Country is saved!")
        return HTTPFound(location=request.route_url("country_list"))

    return dict(form=FormRenderer(form),
                action_url=request.route_url("country_new"))
コード例 #4
0
def new(request):
    """new customer """
    categories = get_categories()
    countries = get_countries()
    
    form = Form(request, schema=CustomerForm)    
    if "form_submitted" in request.POST and form.validate():
        dbsession = DBSession()
        customer = form.bind(Customer())
        dbsession.add(customer)
        request.session.flash("warning;New Customer is saved!")
        return HTTPFound(location = request.route_url("customer_list"))
        
    return dict(form=FormRenderer(form),
                categories=categories, 
                countries=countries, 
                action_url=request.route_url("customer_new"))
コード例 #5
0
def new(request):
    """new customer """
    categories = get_categories()
    countries = get_countries()

    form = Form(request, schema=CustomerForm)
    if "form_submitted" in request.POST and form.validate():
        dbsession = DBSession()
        customer = form.bind(Customer())
        dbsession.add(customer)
        request.session.flash("warning;New Customer is saved!")
        return HTTPFound(location=request.route_url("customer_list"))

    return dict(form=FormRenderer(form),
                categories=categories,
                countries=countries,
                action_url=request.route_url("customer_new"))
コード例 #6
0
def edit(request):
    """country edit """
    id = request.matchdict['id']
    dbsession = DBSession()
    country = dbsession.query(Country).filter_by(id=id).one()
    if country is None:
        request.session.flash("error;Country not found!")
        return HTTPFound(location=request.route_url("country_list"))

    form = Form(request, schema=CountryForm, obj=country)
    if "form_submitted" in request.POST and form.validate():
        form.bind(country)
        dbsession.add(country)
        request.session.flash("warning;The Country is saved!")
        return HTTPFound(location=request.route_url("country_list"))

    action_url = request.route_url("country_edit", id=id)
    return dict(form=FormRenderer(form), action_url=action_url)
コード例 #7
0
def edit(request):
    """country edit """
    id = request.matchdict['id']
    dbsession = DBSession()
    country = dbsession.query(Country).filter_by(id=id).one()
    if country is None:
        request.session.flash("error;Country not found!")
        return HTTPFound(location=request.route_url("country_list"))        
    

    form = Form(request, schema=CountryForm, obj=country)    
    if "form_submitted" in request.POST and form.validate():
        form.bind(country)
        dbsession.add(country)
        request.session.flash("warning;The Country is saved!")
        return HTTPFound(location = request.route_url("country_list"))

    action_url = request.route_url("country_edit", id=id)
    return dict(form=FormRenderer(form), 
                action_url=action_url)
コード例 #8
0
def new(request):
    """new customer """
    #categories = get_categories()
    #countries = get_countries()
    
    generalForm = Form(request, schema=CustomerForm)
    locationForm = Form(request, schema=LocationForm)    
    if "form_submitted" in request.POST and generalForm.validate():
        dbsession = DBSession()
        customer = generalForm.bind(Customer())
        dbsession.add(customer)
        request.session.flash("warning;New Customer is saved!")
        return HTTPFound(location = request.route_url("customer_list"))
    
    if "location_submitted" in request.POST and locationForm.validate():
        dbsession = DBSession()
        location = locationForm.bind(Address())
        dbsession.add(location)
        request.session.flash("warning;Customer Address is saved!")
        
    return dict(generalForm=FormRenderer(generalForm), 
                action_url=request.route_url("customer_new"))
コード例 #9
0
def edit(request):
    """customer edit """
    id = request.matchdict['id']
    dbsession = DBSession()
    customer = dbsession.query(Customer).filter_by(id=id).one()
    if customer is None:
        request.session.flash("error;Customer not found!")
        return HTTPFound(location=request.route_url("customer_list"))        
    
    categories = get_categories()
    countries = get_countries()

    form = Form(request, schema=CustomerForm, obj=customer)    
    if "form_submitted" in request.POST and form.validate():
        form.bind(customer)
        dbsession.add(customer)
        request.session.flash("warning;The Customer is saved!")
        return HTTPFound(location = request.route_url("customer_list"))

    action_url = request.route_url("customer_edit", id=id)
    return dict(form=FormRenderer(form),
                categories=categories, 
                countries=countries, 
                action_url=action_url)
コード例 #10
0
def edit(request):
    """customer edit """
    id = request.matchdict['id']
    dbsession = DBSession()
    customer = dbsession.query(Customer).filter_by(id=id).one()
    if customer is None:
        request.session.flash("error;Customer not found!")
        return HTTPFound(location=request.route_url("customer_list"))

    categories = get_categories()
    countries = get_countries()

    form = Form(request, schema=CustomerForm, obj=customer)
    if "form_submitted" in request.POST and form.validate():
        form.bind(customer)
        dbsession.add(customer)
        request.session.flash("warning;The Customer is saved!")
        return HTTPFound(location=request.route_url("customer_list"))

    action_url = request.route_url("customer_edit", id=id)
    return dict(form=FormRenderer(form),
                categories=categories,
                countries=countries,
                action_url=action_url)