extend get view with template ctx
This commit is contained in:
parent
f0de52fc14
commit
c85f6c3622
@ -30,7 +30,7 @@ def get_view(model_view, template, template_ctx_func=None):
|
|||||||
|
|
||||||
|
|
||||||
def serialize_form():
|
def serialize_form():
|
||||||
return dict(request.form)
|
return dict(filter(lambda k: not k[0].startswith("__"), dict(request.form).items()))
|
||||||
|
|
||||||
|
|
||||||
def update_view(model_view, template):
|
def update_view(model_view, template):
|
||||||
@ -55,10 +55,11 @@ def update_view(model_view, template):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
def create_view(model_view, template, post_add=None, post_create=None):
|
def create_view(model_view, template, template_ctx_func=None, post_add=None, post_create=None):
|
||||||
def inner():
|
def inner():
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
return render_template(template)
|
template_ctx = template_ctx_func() if template_ctx_func else {}
|
||||||
|
return render_template(template, **template_ctx)
|
||||||
serialized_form = serialize_form()
|
serialized_form = serialize_form()
|
||||||
|
|
||||||
_next = serialized_form.pop('_next') if '_next' in serialized_form else None
|
_next = serialized_form.pop('_next') if '_next' in serialized_form else None
|
||||||
|
Loading…
Reference in New Issue
Block a user