mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add a warning showing which databases tables are not covered by defined rulesets
This commit is contained in:
parent
6c2eb959a6
commit
1ded9e1fc0
@ -45,6 +45,7 @@ class RuleSet(models.Model):
|
||||
'auth_user',
|
||||
'auth_permission',
|
||||
'authtoken_token',
|
||||
'users_ruleset',
|
||||
],
|
||||
'part': [
|
||||
'part_part',
|
||||
|
@ -61,14 +61,30 @@ class RuleSetModelTest(TestCase):
|
||||
|
||||
errors = 0
|
||||
|
||||
assigned_models = []
|
||||
|
||||
# Now check that each defined model is a valid table name
|
||||
for key in RuleSet.RULESET_MODELS.keys():
|
||||
|
||||
models = RuleSet.RULESET_MODELS[key]
|
||||
|
||||
for m in models:
|
||||
|
||||
assigned_models.append(m)
|
||||
|
||||
if m not in available_tables:
|
||||
print("{n} is not a valid database table".format(n=m))
|
||||
errors += 1
|
||||
|
||||
self.assertEqual(errors, 0)
|
||||
|
||||
missing_models = []
|
||||
|
||||
for model in available_tables:
|
||||
if model not in assigned_models:
|
||||
missing_models.append(model)
|
||||
|
||||
if len(missing_models) > 0:
|
||||
print("WARNING: The following database models are not covered by the define RuleSet permissions:")
|
||||
for m in missing_models:
|
||||
print("-", m)
|
Loading…
Reference in New Issue
Block a user