oshipka/vm_gen/templates/_hooks.py

63 lines
1.6 KiB
Python
Raw Normal View History

2020-06-06 13:33:39 +02:00
from oshipka.webapp.views import ViewContext, default_get_args_func, default_get_func, default_list_func, \
default_get_form_func, default_create_func, default_update_func, default_delete_func, default_search_func
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
def get_template(vc):
vc.template = "{}/get.html".format(vc.model_view.model_name)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
def search_template(vc):
vc.template = "{}/search.html".format(vc.model_view.model_name)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
def list_template(vc):
vc.template = "{}/list.html".format(vc.model_view.model_name)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
def create_template(vc):
vc.template = "{}/create.html".format(vc.model_view.model_name)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
def update_template(vc):
vc.template = "{}/update.html".format(vc.model_view.model_name)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
def delete_template(vc):
vc.template = "delete_instance.html".format(vc.model_view.model_name)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
get_view_context = ViewContext(
filter_func=default_get_func,
template_func=get_template,
)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
list_view_context = ViewContext(
filter_func=default_list_func,
template_func=list_template,
)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
search_view_context = ViewContext(
filter_func=default_search_func,
template_func=list_template,
)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
create_view_context = ViewContext(
args_get_func=default_get_form_func,
template_func=create_template,
execute_func=default_create_func,
)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
update_view_context = ViewContext(
args_get_func=default_get_form_func,
filter_func=default_get_func,
template_func=update_template,
execute_func=default_update_func,
)
2020-06-05 12:38:25 +02:00
2020-06-06 13:33:39 +02:00
delete_view_context = ViewContext(
args_get_func=default_get_form_func,
filter_func=default_get_func,
template_func=delete_template,
execute_func=default_delete_func,
)