Esempio n. 1
0
def admin_edit(request, uid):
    showcase = Showcase.get_by_id(uid)
    if not showcase:
        return redirect(url_for('showcase/admin/list'))
    form = ShowcaseForm(instance=showcase)
    if request.method == 'POST':
        if form.validate(request.form):
            form.save()
            return redirect(url_for('showcase/admin/list'))
        else:
            return render_to_response(
                    'showcase/admin/edit.html', {
                        'form': form.as_widget(),
                        'showcase': showcase
                    })
    return render_to_response(
        'showcase/admin/edit.html', {
            'form': form.as_widget(),
            'showcase': showcase
        })
Esempio n. 2
0
def admin_add(request):
    showcase = Showcase()
    showcase.put()
    form = ShowcaseForm(instance=showcase, action=url_for('showcase/admin/edit', uid=showcase.key().id()))
    return render_to_response('showcase/admin/edit.html', {'form': form.as_widget(), 'showcase': showcase})