示例#1
0
def products_edit(app_id, product_id):
    product = models.products_detail(app_id, product_id)
    if not product:
        return abort(404)

    form = forms.ProductForm()
    if form.validate_on_submit():
        models.products_edit(form)
        return redirect('/apps/%d/products' % (app_id))

    form.app_id.data = product['app_id']
    form.app_id.readonly = True
    form.product_id.data = product['product_id']
    form.product_id.readonly = True
    form.product_name.data = product['product_name']
    form.product_detail.data = product['product_detail']
    form.product_price.data = product['product_price']
    form.inapp_id.data = product['inapp_id']
    form.service_platform.choices = models.service_platform_choices()
    form.service_platform.data = models.service_platform_index(product['service_platform'])
    form.currency.choices = models.currency_type_choices()
    form.currency.data = models.currency_type_index(product['currency'])
    form.status.choices = models.product_status_choices()
    form.status.data = models.product_status_index(product['status'])
    
    return render_template('apps/products_edit.html',
                           app_id = app_id,
                           form = form, h = helpers)
示例#2
0
def products_new(app_id):
    form = forms.ProductForm()
    if form.validate_on_submit():
        models.products_new(form)
        return redirect('/apps/%d/products' % (app_id))

    form.app_id.data = app_id
    form.app_id.readonly = True
    form.product_id.data = models.auto_created()
    form.product_id.readonly = True
    form.service_platform.choices = models.service_platform_choices()
    form.currency.choices = models.currency_type_choices()
    form.status.choices = models.product_status_choices()

    return render_template('apps/products_edit.html',
                           app_id = app_id,
                           form = form, h = helpers)