From f4cb1cb0976dbc6093f74ecb57f319ccf1e137c6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 29 Nov 2023 15:03:08 -0600 Subject: [PATCH] Avoid error when editing a department just a temp hack, need to fix proper yet --- tailbone/views/departments.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tailbone/views/departments.py b/tailbone/views/departments.py index 8115c5c3..3d462b16 100644 --- a/tailbone/views/departments.py +++ b/tailbone/views/departments.py @@ -24,7 +24,7 @@ Department Views """ -from rattail.db import model +from rattail.db.model import Department, Product from webhelpers2.html import HTML @@ -35,7 +35,7 @@ class DepartmentView(MasterView): """ Master view for the Department class. """ - model_class = model.Department + model_class = Department touchable = True has_versions = True results_downloadable = True @@ -64,7 +64,7 @@ class DepartmentView(MasterView): ] has_rows = True - model_row_class = model.Product + model_row_class = Product rows_title = "Products" row_labels = { @@ -111,6 +111,8 @@ class DepartmentView(MasterView): # tax f.set_renderer('tax', self.render_tax) + # TODO: make this editable + f.set_readonly('tax') def render_employees(self, department, field): route_prefix = self.get_route_prefix() @@ -160,6 +162,7 @@ class DepartmentView(MasterView): Check to see if there are any products which belong to the department; if there are then we do not allow delete and redirect the user. """ + model = self.model count = self.Session.query(model.Product)\ .filter(model.Product.department == department)\ .count() @@ -169,6 +172,7 @@ class DepartmentView(MasterView): raise self.redirect(self.get_action_url('view', department)) def get_row_data(self, department): + model = self.model return self.Session.query(model.Product)\ .filter(model.Product.department == department) @@ -198,6 +202,7 @@ class DepartmentView(MasterView): """ View list of departments by vendor """ + model = self.model data = self.Session.query(model.Department)\ .outerjoin(model.Product)\ .join(model.ProductCost)\