Avoid error when editing a department
just a temp hack, need to fix proper yet
This commit is contained in:
parent
e23998a88b
commit
f4cb1cb097
|
@ -24,7 +24,7 @@
|
||||||
Department Views
|
Department Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db.model import Department, Product
|
||||||
|
|
||||||
from webhelpers2.html import HTML
|
from webhelpers2.html import HTML
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class DepartmentView(MasterView):
|
||||||
"""
|
"""
|
||||||
Master view for the Department class.
|
Master view for the Department class.
|
||||||
"""
|
"""
|
||||||
model_class = model.Department
|
model_class = Department
|
||||||
touchable = True
|
touchable = True
|
||||||
has_versions = True
|
has_versions = True
|
||||||
results_downloadable = True
|
results_downloadable = True
|
||||||
|
@ -64,7 +64,7 @@ class DepartmentView(MasterView):
|
||||||
]
|
]
|
||||||
|
|
||||||
has_rows = True
|
has_rows = True
|
||||||
model_row_class = model.Product
|
model_row_class = Product
|
||||||
rows_title = "Products"
|
rows_title = "Products"
|
||||||
|
|
||||||
row_labels = {
|
row_labels = {
|
||||||
|
@ -111,6 +111,8 @@ class DepartmentView(MasterView):
|
||||||
|
|
||||||
# tax
|
# tax
|
||||||
f.set_renderer('tax', self.render_tax)
|
f.set_renderer('tax', self.render_tax)
|
||||||
|
# TODO: make this editable
|
||||||
|
f.set_readonly('tax')
|
||||||
|
|
||||||
def render_employees(self, department, field):
|
def render_employees(self, department, field):
|
||||||
route_prefix = self.get_route_prefix()
|
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;
|
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.
|
if there are then we do not allow delete and redirect the user.
|
||||||
"""
|
"""
|
||||||
|
model = self.model
|
||||||
count = self.Session.query(model.Product)\
|
count = self.Session.query(model.Product)\
|
||||||
.filter(model.Product.department == department)\
|
.filter(model.Product.department == department)\
|
||||||
.count()
|
.count()
|
||||||
|
@ -169,6 +172,7 @@ class DepartmentView(MasterView):
|
||||||
raise self.redirect(self.get_action_url('view', department))
|
raise self.redirect(self.get_action_url('view', department))
|
||||||
|
|
||||||
def get_row_data(self, department):
|
def get_row_data(self, department):
|
||||||
|
model = self.model
|
||||||
return self.Session.query(model.Product)\
|
return self.Session.query(model.Product)\
|
||||||
.filter(model.Product.department == department)
|
.filter(model.Product.department == department)
|
||||||
|
|
||||||
|
@ -198,6 +202,7 @@ class DepartmentView(MasterView):
|
||||||
"""
|
"""
|
||||||
View list of departments by vendor
|
View list of departments by vendor
|
||||||
"""
|
"""
|
||||||
|
model = self.model
|
||||||
data = self.Session.query(model.Department)\
|
data = self.Session.query(model.Department)\
|
||||||
.outerjoin(model.Product)\
|
.outerjoin(model.Product)\
|
||||||
.join(model.ProductCost)\
|
.join(model.ProductCost)\
|
||||||
|
|
Loading…
Reference in a new issue