Пример #1
0
def index(id):

    if bottle.request.POST.get('description'):
        i = EntityManager().find_one_by_id('Image', id)
        i.description = bottle.request.POST.get('description')
        EntityManager().save('Image', i)

    return bottle.redirect('/admin/images')
Пример #2
0
def index():
    n = bottle.request.POST.name
    d = bottle.request.POST.description
    s = bottle.request.POST.scheme

    if n:
        if bottle.request.POST.get('id'):
            cat = EntityManager().find_one_by_id('Category', bottle.request.POST.id)
        else:
            cat = Category()

        cat.name = n
        cat.description = d
        cat.payment_scheme_id = s

        EntityManager().save('Category', cat)

        return bottle.redirect('/admin/categories')

    else:
        viewdata = commonViewDataAdmin()
        viewdata['error'] = 'Required data is missing'

        return bottle.template('admin_category', vd=viewdata)