Commit 4f3d6d34 by aa.gusti

Penambahan get_routes

1 parent c86bc624
...@@ -188,14 +188,20 @@ class BaseView(object): ...@@ -188,14 +188,20 @@ class BaseView(object):
def query_register(self, **kwargs): def query_register(self, **kwargs):
pass pass
def get_routes(self):
"""
Digunakan untuk mendapatkan default url apabula list_url tidak ada
"""
def route_list(self, **kwargs): def route_list(self, **kwargs):
msg = kwargs.get("msg") msg = kwargs.get("msg")
error = kwargs.get("error", "") error = kwargs.get("error", "")
list_url = kwargs.get("list_url", None) list_url = kwargs.get("list_url", self.get_routes())
if msg: if msg:
self.ses.flash(msg, error) self.ses.flash(msg, error)
if not list_url: if not list_url:
list_url = self.req.route_url(self.list_route) list_url = self.req.route_url(self.list_route, **kwargs)
log.error(list_url) log.error(list_url)
if self.headers: if self.headers:
return HTTPFound(location=get_urls(list_url), return HTTPFound(location=get_urls(list_url),
...@@ -295,13 +301,13 @@ class BaseView(object): ...@@ -295,13 +301,13 @@ class BaseView(object):
if not new_buttons: if not new_buttons:
new_buttons = self.new_buttons new_buttons = self.new_buttons
if not list_url and self.list_route: if not list_url and self.list_route:
list_url = self.req.route_url(self.list_route) list_url = self.req.route_url(self.list_route)
else: else:
list_url = list_url and list_url[0:1] != "/" and "/" + \ if list_url[:4] != 'http':
list_url or list_url list_url = f"/{list_url}".replace("//", "/")
list_url = self.home + list_url list_url = self.home + list_url
table = DeTable(schema, table = DeTable(schema,
action=list_url, action=list_url,
......
...@@ -144,9 +144,11 @@ class DeTable(field.Field): ...@@ -144,9 +144,11 @@ class DeTable(field.Field):
new_buttons = kw.get("new_buttons") or {} new_buttons = kw.get("new_buttons") or {}
action_suffix = f"{action_suffix}{params}" action_suffix = f"{action_suffix}{params}"
close_url = self.action.split("/") close_url = self.action
close_url = "/".join(close_url[:-1]) if close_url[:4] != "http":
close_url.replace(":/", "://") close_url = self.action.split("/")
close_url = "/".join(close_url[:-1])
close_url.replace(":/", "://")
params = params and f"?{params}" or "" params = params and f"?{params}" or ""
dict_buttons = { dict_buttons = {
"close": "{window.location = '" + close_url + "'; return false;}", "close": "{window.location = '" + close_url + "'; return false;}",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!