Commit 8de27740 by aa.gusti

allow order by id

1 parent 4f3d6d34
...@@ -475,6 +475,14 @@ class BaseView(object): ...@@ -475,6 +475,14 @@ class BaseView(object):
return {"row": row} return {"row": row}
def next_edit(self, form, **kwargs): def next_edit(self, form, **kwargs):
"""Digunakan untuk memproses button post yang lainnya
Args:
form (_type_): _description_
Returns:
_type_: _description_
"""
return self.route_list(**kwargs) return self.route_list(**kwargs)
def returned_form(self, form, table=None, **kwargs): def returned_form(self, form, table=None, **kwargs):
...@@ -657,6 +665,13 @@ class BaseView(object): ...@@ -657,6 +665,13 @@ class BaseView(object):
return self.route_list(**kwargs) return self.route_list(**kwargs)
def after_edit(self, row=None, **kwargs): def after_edit(self, row=None, **kwargs):
"""Digunakan untuk memproses setelah proses penyimpanan
Args:
row (objek, optional): Berupa objek row dari tabel yang disimpan.
Defaults to None.
Returns:
HTTPFound: URL yang akan ditampilkan atau procedure tampilan yang lain
"""
return self.route_list(**kwargs) return self.route_list(**kwargs)
def get_captcha_url(self): def get_captcha_url(self):
...@@ -719,7 +734,11 @@ class BaseView(object): ...@@ -719,7 +734,11 @@ class BaseView(object):
row.updated = datetime.now() row.updated = datetime.now()
row.update_uid = user and user.id or None row.update_uid = user and user.id or None
row.from_dict(values) for key, value in values.items():
if hasattr(row, key):
setattr(row, key, value)
# row.from_dict(values)
# if hasattr(row, "status"): # if hasattr(row, "status"):
# status = "status" in values and values["status"] or 0 # status = "status" in values and values["status"] or 0
# log.debug(status) # log.debug(status)
...@@ -759,13 +778,20 @@ class BaseView(object): ...@@ -759,13 +778,20 @@ class BaseView(object):
return self.route_list(**kwargs) return self.route_list(**kwargs)
def get_values(self, row, istime=False, null=False): def get_values(self, row, istime=False, null=False):
d = row.to_dict(null=null) d = dict(row.__dict__)
d.pop('_sa_instance_state', None)
# d = row.to_dict(null=null)
# if 'tanggal' in d and d['tanggal']: # if 'tanggal' in d and d['tanggal']:
# d["tanggal"] = dmy(row.tanggal) # d["tanggal"] = dmy(row.tanggal)
values = {}
for f in d: for f in d:
if type(d[f]) is str: if type(d[f]) is str:
d[f] = d[f].strip() values[f] = d[f].strip()
return d else:
if d[f] != None:
values[f] = d[f]
return values
def get_item_table(self, parent=None, **kwargs): def get_item_table(self, parent=None, **kwargs):
if not self.form_list: if not self.form_list:
...@@ -806,18 +832,12 @@ class BaseView(object): ...@@ -806,18 +832,12 @@ class BaseView(object):
resources = form.get_widget_resources() resources = form.get_widget_resources()
if request.POST: if request.POST:
if 'save' in request.POST: if 'save' in request.POST:
# log.debug("Save Edit")
# log.debug(dict(request.POST.items()))
# log.debug(request.POST)
controls = request.POST.items() controls = request.POST.items()
log.debug(controls) log.debug(controls)
# log.debug(dict(controls))
# log.debug(list(controls))
try: try:
controls = form.validate(controls) controls = form.validate(controls)
except ValidationFailure as e: except ValidationFailure as e:
log.error(f"Edit Error: {str(e.error.msg)}") log.error(f"Edit Error: {str(e.error.msg)}")
# log.debug(f"Edit Data: {e.cstruct}")
form.set_appstruct(e.cstruct) form.set_appstruct(e.cstruct)
return self.returned_form(form, table, **kwargs) return self.returned_form(form, table, **kwargs)
......
...@@ -285,8 +285,9 @@ class DeTable(field.Field): ...@@ -285,8 +285,9 @@ class DeTable(field.Field):
return result; return result;
}""" }"""
if f.name == "id" and self.action: if f.name == "id" and self.action:
if not d.get("orderable"):
d["orderable"] = True
d["width"] = "30pt" d["width"] = "30pt"
d["orderable"] = False
d["className"] = "text-center" d["className"] = "text-center"
d["visible"] = True d["visible"] = True
d["render"] = """ d["render"] = """
...@@ -313,7 +314,8 @@ class DeTable(field.Field): ...@@ -313,7 +314,8 @@ class DeTable(field.Field):
and thousand["separator"] or ',' and thousand["separator"] or ','
decimal = thousand and "decimal" in thousand and thousand[ decimal = thousand and "decimal" in thousand and thousand[
"decimal"] or '.' "decimal"] or '.'
point = thousand and "point" in thousand and thousand["point"] or 0 point = thousand and thousand.get("point", 0) or 0
point = thousand and thousand.get("precision", point) or point
currency = thousand and "currency" in thousand and \ currency = thousand and "currency" in thousand and \
thousand["currency"] or "" thousand["currency"] or ""
if thousand or isinstance(f.typ, colander.Float) or \ if thousand or isinstance(f.typ, colander.Float) or \
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!