feat: Refactor delete query handling in BaseView and comment out checkbox logic in DeTable

1 parent 0b5800c0
......@@ -1121,8 +1121,8 @@ class BaseView(object):
q = self.query_id()
if self.allow_check:
rcount = q.count()
if rcount > 1:
q=self.query_delete()
rcount=q.count()
try:
q.delete(synchronize_session='fetch')
self.db_session.flush()
......@@ -1165,13 +1165,18 @@ class BaseView(object):
kwargs["table"] = table
return self.returned_form(form, **kwargs)
def query_id(self, id_=None):
id_ = id_ or self.req.matchdict['id']
if id_=='all':
def query_delete(self):
id_ = self.req.matchdict['id']
if id_ == 'all':
ids_ = [int(i) for i in self.req.params.get("ids").split(",")]
return self.table.query().filter(self.table.id.in_(ids_))
return self.table.query_id(id_)
def query_id(self, id_=None):
id_ = id_ or self.req.matchdict['id']
return self.table.query_id(id_)
# if self.req.user:
# if hasattr(self.table, 'company_id') and self.req.user.company_id:
# q = q.filter_by(company_id=self.req.user.company_id)
......
......@@ -225,11 +225,11 @@ class DeTable(field.Field):
"""
header_buttons.insert(0, button)
edit_buttons = []
if allow_check:
button = f"""
<input type="checkbox" class="{tableid}checkAll form-control"> All</input>
"""
edit_buttons.append(button)
# if allow_check:
# button = f"""
# <input type="checkbox" class="{tableid}checkAll form-control"> All</input>
# """
# edit_buttons.append(button)
self.buttons = "','".join(header_buttons).replace('\n', ""). \
replace(';', ';\n')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!