mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	handle modelnames / permissions with underscores
This commit is contained in:
		| @@ -234,7 +234,7 @@ class RuleSet(models.Model): | |||||||
|         given the app_model name, and the permission type. |         given the app_model name, and the permission type. | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
|         app, model = model.split('_') |         model, app = split_model(model) | ||||||
|  |  | ||||||
|         return "{app}.{perm}_{model}".format( |         return "{app}.{perm}_{model}".format( | ||||||
|             app=app, |             app=app, | ||||||
| @@ -277,6 +277,19 @@ class RuleSet(models.Model): | |||||||
|         return self.RULESET_MODELS.get(self.name, []) |         return self.RULESET_MODELS.get(self.name, []) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def split_model(model): | ||||||
|  |     """get modelname and app from modelstring""" | ||||||
|  |     app, *model = model.split('_') | ||||||
|  |  | ||||||
|  |     # handle models that have | ||||||
|  |     if len(model) > 1: | ||||||
|  |         model = '_'.join(model) | ||||||
|  |     else: | ||||||
|  |         model = model[0] | ||||||
|  |  | ||||||
|  |     return model, app | ||||||
|  |  | ||||||
|  |  | ||||||
| def update_group_roles(group, debug=False): | def update_group_roles(group, debug=False): | ||||||
|     """ |     """ | ||||||
|  |  | ||||||
| @@ -380,7 +393,7 @@ def update_group_roles(group, debug=False): | |||||||
|  |  | ||||||
|         (app, perm) = permission_string.split('.') |         (app, perm) = permission_string.split('.') | ||||||
|  |  | ||||||
|         (permission_name, model) = perm.split('_') |         (model, permission_name) = split_model(perm) | ||||||
|  |  | ||||||
|         try: |         try: | ||||||
|             content_type = ContentType.objects.get(app_label=app, model=model) |             content_type = ContentType.objects.get(app_label=app, model=model) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user