mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Global Cache Fix (#7393)
* Adjust situations in which cache is disabled - Prevent cache when running a number of housekeeping commands * Add 'spectacular' to list of excluded commands * Generate codes as list - Ensure consistent ordering (for CI) * Debug currency codes list * Bump API version
This commit is contained in:
		| @@ -1,14 +1,16 @@ | |||||||
| """InvenTree API version information.""" | """InvenTree API version information.""" | ||||||
|  |  | ||||||
| # InvenTree API version | # InvenTree API version | ||||||
| INVENTREE_API_VERSION = 203 | INVENTREE_API_VERSION = 204 | ||||||
|  |  | ||||||
| """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" | """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" | ||||||
|  |  | ||||||
| INVENTREE_API_TEXT = """ | INVENTREE_API_TEXT = """ | ||||||
|  | v204 - 2024-06-03 : https://github.com/inventree/InvenTree/pull/7393 | ||||||
|  |     - Fixes previous API update which resulted in inconsistent ordering of currency codes | ||||||
|  |  | ||||||
| v203 - 2024-06-03 : https://github.com/inventree/InvenTree/pull/7390 | v203 - 2024-06-03 : https://github.com/inventree/InvenTree/pull/7390 | ||||||
|     - Adjust default currency codes |     - Currency codes are now configurable as a run-time setting | ||||||
|  |  | ||||||
| v202 - 2024-05-27 : https://github.com/inventree/InvenTree/pull/7343 | v202 - 2024-05-27 : https://github.com/inventree/InvenTree/pull/7343 | ||||||
|     - Adjust "required" attribute of Part.category field to be optional |     - Adjust "required" attribute of Part.category field to be optional | ||||||
|   | |||||||
| @@ -45,13 +45,9 @@ def is_global_cache_enabled(): | |||||||
|         return False |         return False | ||||||
|  |  | ||||||
|     # The cache should not be used during certain operations |     # The cache should not be used during certain operations | ||||||
|     if any(( |     if not InvenTree.ready.canAppAccessDatabase( | ||||||
|         InvenTree.ready.isRunningBackup(), |         allow_test=False, allow_plugins=False, allow_shell=True | ||||||
|         InvenTree.ready.isRunningMigrations(), |     ): | ||||||
|         InvenTree.ready.isRebuildingData(), |  | ||||||
|         InvenTree.ready.isImportingData(), |  | ||||||
|         InvenTree.ready.isInTestMode(), |  | ||||||
|     )): |  | ||||||
|         logger.info('Global cache bypassed for this operation') |         logger.info('Global cache bypassed for this operation') | ||||||
|         return False |         return False | ||||||
|  |  | ||||||
|   | |||||||
| @@ -114,6 +114,7 @@ def canAppAccessDatabase( | |||||||
|         'wait_for_db', |         'wait_for_db', | ||||||
|         'makemessages', |         'makemessages', | ||||||
|         'compilemessages', |         'compilemessages', | ||||||
|  |         'spectactular', | ||||||
|     ] |     ] | ||||||
|  |  | ||||||
|     if not allow_shell: |     if not allow_shell: | ||||||
|   | |||||||
| @@ -68,20 +68,23 @@ def currency_codes() -> list: | |||||||
|  |  | ||||||
|     codes = codes.split(',') |     codes = codes.split(',') | ||||||
|  |  | ||||||
|     valid_codes = set() |     valid_codes = [] | ||||||
|  |  | ||||||
|     for code in codes: |     for code in codes: | ||||||
|         code = code.strip().upper() |         code = code.strip().upper() | ||||||
|  |  | ||||||
|  |         if code in valid_codes: | ||||||
|  |             continue | ||||||
|  |  | ||||||
|         if code in CURRENCIES: |         if code in CURRENCIES: | ||||||
|             valid_codes.add(code) |             valid_codes.append(code) | ||||||
|         else: |         else: | ||||||
|             logger.warning(f"Invalid currency code: '{code}'") |             logger.warning(f"Invalid currency code: '{code}'") | ||||||
|  |  | ||||||
|     if len(valid_codes) == 0: |     if len(valid_codes) == 0: | ||||||
|         valid_codes = set(currency_codes_default_list().split(',')) |         valid_codes = list(currency_codes_default_list().split(',')) | ||||||
|  |  | ||||||
|     return list(valid_codes) |     return valid_codes | ||||||
|  |  | ||||||
|  |  | ||||||
| def currency_code_mappings() -> list: | def currency_code_mappings() -> list: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user