mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Catch error when incorrect date format string is passed
This commit is contained in:
		| @@ -8,6 +8,7 @@ over and above the built-in Django tags. | |||||||
| from datetime import date, datetime | from datetime import date, datetime | ||||||
| import os | import os | ||||||
| import sys | import sys | ||||||
|  | import logging | ||||||
|  |  | ||||||
| from django.utils.html import format_html | from django.utils.html import format_html | ||||||
|  |  | ||||||
| @@ -31,6 +32,9 @@ from plugin.models import PluginSetting | |||||||
| register = template.Library() | register = template.Library() | ||||||
|  |  | ||||||
|  |  | ||||||
|  | logger = logging.getLogger('inventree') | ||||||
|  |  | ||||||
|  |  | ||||||
| @register.simple_tag() | @register.simple_tag() | ||||||
| def define(value, *args, **kwargs): | def define(value, *args, **kwargs): | ||||||
|     """ |     """ | ||||||
| @@ -65,7 +69,11 @@ def render_date(context, date_object): | |||||||
|             return None |             return None | ||||||
|  |  | ||||||
|         # If a string is passed, first convert it to a datetime |         # If a string is passed, first convert it to a datetime | ||||||
|  |         try: | ||||||
|             date_object = date.fromisoformat(date_object) |             date_object = date.fromisoformat(date_object) | ||||||
|  |         except ValueError: | ||||||
|  |             logger.warning(f"Tried to convert invalid date string: {date_object}") | ||||||
|  |             return None | ||||||
|  |  | ||||||
|     # We may have already pre-cached the date format by calling this already! |     # We may have already pre-cached the date format by calling this already! | ||||||
|     user_date_format = context.get('user_date_format', None) |     user_date_format = context.get('user_date_format', None) | ||||||
|   | |||||||
| @@ -59,15 +59,24 @@ def register_event(event, *args, **kwargs): | |||||||
|  |  | ||||||
|     logger.debug(f"Registering triggered event: '{event}'") |     logger.debug(f"Registering triggered event: '{event}'") | ||||||
|  |  | ||||||
|  |     print("register_event") | ||||||
|  |  | ||||||
|     # Determine if there are any plugins which are interested in responding |     # Determine if there are any plugins which are interested in responding | ||||||
|     if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_EVENTS'): |     if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_EVENTS'): | ||||||
|  |  | ||||||
|  |         print("checking plugins") | ||||||
|  |  | ||||||
|         with transaction.atomic(): |         with transaction.atomic(): | ||||||
|  |  | ||||||
|             for slug, plugin in registry.plugins.items(): |             for slug, plugin in registry.plugins.items(): | ||||||
|  |  | ||||||
|  |                 print("slug:", slug) | ||||||
|  |                 print("plugin:", plugin) | ||||||
|  |  | ||||||
|                 if plugin.mixin_enabled('events'): |                 if plugin.mixin_enabled('events'): | ||||||
|  |  | ||||||
|  |                     print("events are enabled for this plugin!") | ||||||
|  |  | ||||||
|                     config = plugin.plugin_config() |                     config = plugin.plugin_config() | ||||||
|  |  | ||||||
|                     if config and config.active: |                     if config and config.active: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user