Expose version history for all supported tables

mostly for sake of products, but various..
This commit is contained in:
Lance Edgar 2017-07-15 02:46:39 -05:00
parent 5be3671a77
commit bea28e97e9
14 changed files with 31 additions and 6 deletions

View file

@ -36,6 +36,8 @@ class BrandsView(MasterView):
Master view for the Brand class.
"""
model_class = model.Brand
has_versions = True
grid_columns = [
'name',
]

View file

@ -38,6 +38,7 @@ class CategoriesView(MasterView):
model_class = model.Category
model_title_plural = "Categories"
route_prefix = 'categories'
has_versions = True
grid_columns = [
'code',

View file

@ -39,6 +39,7 @@ class DepartmentsView(MasterView):
Master view for the Department class.
"""
model_class = model.Department
has_versions = True
grid_columns = [
'number',

View file

@ -38,6 +38,7 @@ class DepositLinksView(MasterView):
"""
model_class = model.DepositLink
url_prefix = '/deposit-links'
has_versions = True
grid_columns = [
'code',

View file

@ -158,6 +158,8 @@ class EmployeesView(MasterView):
(model.Person, 'uuid', 'person_uuid'),
(model.EmployeePhoneNumber, 'parent_uuid'),
(model.EmployeeEmailAddress, 'parent_uuid'),
(model.EmployeeStore, 'employee_uuid'),
(model.EmployeeDepartment, 'employee_uuid'),
]

View file

@ -38,7 +38,9 @@ class FamiliesView(MasterView):
model_class = model.Family
model_title_plural = "Families"
route_prefix = 'families'
has_versions = True
grid_key = 'families'
grid_columns = [
'code',
'name',

View file

@ -42,6 +42,8 @@ class ProfilesView(MasterView):
model_class = model.LabelProfile
model_title = "Label Profile"
url_prefix = '/labels/profiles'
has_versions = True
grid_columns = [
'ordinal',
'code',

View file

@ -77,6 +77,7 @@ class ProductsView(MasterView):
"""
model_class = model.Product
supports_mobile = True
has_versions = True
grid_columns = [
'upc',
@ -89,12 +90,6 @@ class ProductsView(MasterView):
'current_price',
]
# child_version_classes = [
# (model.ProductCode, 'product_uuid'),
# (model.ProductCost, 'product_uuid'),
# (model.ProductPrice, 'product_uuid'),
# ]
# These aliases enable the grid queries to filter products which may be
# purchased from *any* vendor, and yet sort by only the "preferred" vendor
# (since that's what shows up in the grid column).
@ -366,6 +361,13 @@ class ProductsView(MasterView):
'instance_title': self.get_instance_title(instance),
'form': form})
def get_version_child_classes(self):
return [
(model.ProductCode, 'product_uuid'),
(model.ProductCost, 'product_uuid'),
(model.ProductPrice, 'product_uuid'),
]
def image(self):
"""
View which renders the product's image as a response.

View file

@ -37,6 +37,7 @@ class ReportCodesView(MasterView):
"""
model_class = model.ReportCode
model_title = "Report Code"
has_versions = True
grid_columns = [
'code',

View file

@ -44,6 +44,7 @@ class RolesView(PrincipalMasterView):
Master view for the Role model.
"""
model_class = model.Role
has_versions = True
grid_columns = [
'name',

View file

@ -106,6 +106,7 @@ class WorkedShiftsView(MasterView):
"""
model_class = model.WorkedShift
url_prefix = '/shifts/worked'
has_versions = True
grid_columns = [
'employee',

View file

@ -37,6 +37,7 @@ class SubdepartmentsView(MasterView):
Master view for the Subdepartment class.
"""
model_class = model.Subdepartment
has_versions = True
grid_columns = [
'number',

View file

@ -38,6 +38,7 @@ class TaxesView(MasterView):
model_class = model.Tax
model_title_plural = "Taxes"
route_prefix = 'taxes'
has_versions = True
grid_columns = [
'code',

View file

@ -128,6 +128,8 @@ class UsersView(PrincipalMasterView):
Master view for the User model.
"""
model_class = model.User
has_versions = True
mergeable = True
merge_additive_fields = [
'sent_message_count',
@ -212,6 +214,11 @@ class UsersView(PrincipalMasterView):
return user.username != 'chuck'
return True
def get_version_child_classes(self):
return [
(model.UserRole, 'user_uuid'),
]
def find_principals_with_permission(self, session, permission):
# TODO: this should search Permission table instead, and work backward to User?
all_users = session.query(model.User)\