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)\