

def _update(request, state, template, result_template, form=NewsletterForm):
    'Add a subscription and return the results in the requested template.'
    success = False
    result = ''
    if (request.method == 'POST'):
        workform = form(request.POST)
        if workform.is_valid():
            if (state == 'FORM'):
                result = workform.save()
            else:
                result = workform.save(state)
            success = True
        else:
            result = ugettext('Error, not valid.')
    else:
        workform = form()
    ctx = RequestContext(request, {
        'result': result,
        'form': workform,
    })
    if success:
        return render_to_response(result_template, context_instance=ctx)
    else:
        return render_to_response(template, context_instance=ctx)

dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/satchmo_ext/newsletter/views.py _update/original