Esempio n. 1
0
def add_action(request):
    form = ActionForm()
    if request.method == 'POST' and form.validate(request.form):
        form.save()
        return redirect('/news/admin/actions/all/')
    images_form = ActionImageForm(action='/news/admin/actions/add_image_action/')
    return render_to_response(
        'news/admin/actions_add.html',
        {'form':form.as_widget(),
         'images_form':images_form.as_widget()})
Esempio n. 2
0
def edit_action(request, key):
    action = Action.get(key)
    if not action:
        return redirect('/news/admin/actions/all/')
    form = ActionForm(instance=action)
    if request.method == 'POST' and form.validate(request.form):
        form.save()
        return redirect('/news/admin/actions/all/')
    images_form = ActionImageForm(action='/news/admin/actions/add_image/%s/' % key)
    return render_to_response(
        'news/admin/actions_add.html',
        {'form':form.as_widget(),
         'images_form':images_form.as_widget(),
         'action':action})