def statement_edit(statement_id=None):
    ls = LicenseStatement.pull(statement_id)
    form = LicenseForm(request.form, ls)

    if request.method == "POST" and form.validate():
        if not ls:
            ls = LicenseStatement()
        ls.license_statement = form.license_statement.data
        ls.license_type = form.license_type.data
        if form.version.data:
            ls.version = form.version.data
        if form.example_doi.data:
            ls.example_doi = form.example_doi.data
        ls.save()
        sleep(1.5)  # ugly hack, make sure statement is saved before showing to user
        return redirect(url_for(".list_statements", _anchor=ls.edit_id))

    return render_template("statement.html", form=form)