oshipka/vm_gen/templates/_hooks.py

79 lines
1.9 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 list_template(vc):
vc.template = "{}/list.html".format(vc.model_view.model_name)
2020-06-05 12:38:25 +02:00
2020-06-07 20:29:51 +02:00
def table_template(vc):
vc.template = "{}/table.html".format(vc.model_view.model_name)
def search_template(vc):
vc.template = "{}/search.html".format(vc.model_view.model_name)
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,
2021-05-14 23:37:30 +02:00
verb="get",
2020-06-06 13:33:39 +02:00
)
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,
2021-05-14 23:37:30 +02:00
verb="list",
2020-06-06 13:33:39 +02:00
)
2020-06-05 12:38:25 +02:00
2020-06-07 20:29:51 +02:00
table_view_context = ViewContext(
filter_func=default_list_func,
template_func=table_template,
2021-05-14 23:37:30 +02:00
verb="list",
2020-06-07 20:29:51 +02:00
)
2020-06-06 13:33:39 +02:00
search_view_context = ViewContext(
filter_func=default_search_func,
template_func=list_template,
2021-05-14 23:37:30 +02:00
verb="search",
2020-06-06 13:33:39 +02:00
)
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,
2021-05-14 23:37:30 +02:00
verb="create",
2020-06-06 13:33:39 +02:00
)
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,
2021-05-14 23:37:30 +02:00
verb="update",
2020-06-06 13:33:39 +02:00
)
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,
2021-05-14 23:37:30 +02:00
verb="delete",
2020-06-06 13:33:39 +02:00
)