mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Merge branch 'inventree:master' into webhooks
This commit is contained in:
		| @@ -161,7 +161,7 @@ class GlobalSettingsDetail(generics.RetrieveUpdateAPIView): | ||||
|     permission_classes = [ | ||||
|         GlobalSettingsPermissions, | ||||
|     ] | ||||
|      | ||||
|  | ||||
|  | ||||
| class UserSettingsList(SettingsList): | ||||
|     """ | ||||
| @@ -212,7 +212,7 @@ class UserSettingsDetail(generics.RetrieveUpdateAPIView): | ||||
|  | ||||
|     queryset = common.models.InvenTreeUserSetting.objects.all() | ||||
|     serializer_class = common.serializers.UserSettingsSerializer | ||||
|      | ||||
|  | ||||
|     permission_classes = [ | ||||
|         UserSettingsPermissions, | ||||
|     ] | ||||
|   | ||||
| @@ -12,7 +12,7 @@ class CommonConfig(AppConfig): | ||||
|     name = 'common' | ||||
|  | ||||
|     def ready(self): | ||||
|          | ||||
|  | ||||
|         self.clear_restart_flag() | ||||
|  | ||||
|     def clear_restart_flag(self): | ||||
| @@ -22,7 +22,7 @@ class CommonConfig(AppConfig): | ||||
|  | ||||
|         try: | ||||
|             import common.models | ||||
|              | ||||
|  | ||||
|             if common.models.InvenTreeSetting.get_setting('SERVER_RESTART_REQUIRED'): | ||||
|                 logger.info("Clearing SERVER_RESTART_REQUIRED flag") | ||||
|                 common.models.InvenTreeSetting.set_setting('SERVER_RESTART_REQUIRED', False, None) | ||||
|   | ||||
| @@ -116,7 +116,9 @@ class BaseInvenTreeSetting(models.Model): | ||||
|         for key, value in settings.items(): | ||||
|             validator = cls.get_setting_validator(key) | ||||
|  | ||||
|             if cls.validator_is_bool(validator): | ||||
|             if cls.is_protected(key): | ||||
|                 value = '***' | ||||
|             elif cls.validator_is_bool(validator): | ||||
|                 value = InvenTree.helpers.str2bool(value) | ||||
|             elif cls.validator_is_int(validator): | ||||
|                 try: | ||||
| @@ -493,7 +495,7 @@ class BaseInvenTreeSetting(models.Model): | ||||
|  | ||||
|         elif self.is_int(): | ||||
|             return 'integer' | ||||
|          | ||||
|  | ||||
|         else: | ||||
|             return 'string' | ||||
|  | ||||
| @@ -546,6 +548,19 @@ class BaseInvenTreeSetting(models.Model): | ||||
|  | ||||
|         return value | ||||
|  | ||||
|     @classmethod | ||||
|     def is_protected(cls, key): | ||||
|         """ | ||||
|         Check if the setting value is protected | ||||
|         """ | ||||
|  | ||||
|         key = str(key).strip().upper() | ||||
|  | ||||
|         if key in cls.GLOBAL_SETTINGS: | ||||
|             return cls.GLOBAL_SETTINGS[key].get('protected', False) | ||||
|         else: | ||||
|             return False | ||||
|  | ||||
|  | ||||
| def settings_group_options(): | ||||
|     """build up group tuple for settings based on gour choices""" | ||||
|   | ||||
| @@ -45,6 +45,18 @@ class SettingsSerializer(InvenTreeModelSerializer): | ||||
|  | ||||
|         return results | ||||
|  | ||||
|     def get_value(self, obj): | ||||
|         """ | ||||
|         Make sure protected values are not returned | ||||
|         """ | ||||
|         result = obj.value | ||||
|  | ||||
|         # never return protected values | ||||
|         if obj.is_protected: | ||||
|             result = '***' | ||||
|  | ||||
|         return result | ||||
|  | ||||
|  | ||||
| class GlobalSettingsSerializer(SettingsSerializer): | ||||
|     """ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user