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. Master view for the Brand class.
""" """
model_class = model.Brand model_class = model.Brand
has_versions = True
grid_columns = [ grid_columns = [
'name', 'name',
] ]

View file

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

View file

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

View file

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

View file

@ -158,6 +158,8 @@ class EmployeesView(MasterView):
(model.Person, 'uuid', 'person_uuid'), (model.Person, 'uuid', 'person_uuid'),
(model.EmployeePhoneNumber, 'parent_uuid'), (model.EmployeePhoneNumber, 'parent_uuid'),
(model.EmployeeEmailAddress, '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_class = model.Family
model_title_plural = "Families" model_title_plural = "Families"
route_prefix = 'families' route_prefix = 'families'
has_versions = True
grid_key = 'families' grid_key = 'families'
grid_columns = [ grid_columns = [
'code', 'code',
'name', 'name',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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