From 1a5c58540d7da4931e2dc4e1a7d29fa7bf36c76a Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Thu, 12 Dec 2024 09:24:06 +0000 Subject: [PATCH] CKAN core requires tmezone naive datetimes --- .../dataset_subscriptions/actions/twilio_notifications.py | 7 +++++-- ckanext/dataset_subscriptions/actions/user.py | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ckanext/dataset_subscriptions/actions/twilio_notifications.py b/ckanext/dataset_subscriptions/actions/twilio_notifications.py index a6105ca..d1997c0 100644 --- a/ckanext/dataset_subscriptions/actions/twilio_notifications.py +++ b/ckanext/dataset_subscriptions/actions/twilio_notifications.py @@ -18,7 +18,10 @@ def send_twilio_notifications(context, data_dict): message_sids = [] toolkit.check_access('send_email_notifications', context, data_dict) - users = toolkit.get_action('user_list')({'ignore_auth': True}, {'all_fields': True}) + users = toolkit.get_action('user_list')( + {'ignore_auth': True}, + {'all_fields': True, 'include_plugin_extras': True} + ) for user in users: if _twilio_notifications_enabled(user): recent_activities = _get_recent_activity_list(user, context) @@ -52,7 +55,7 @@ def _twilio_notifications_enabled(user_dict): def _twilio_notification_time_delta_utc(): since_hours = toolkit.config.get('ckanext.dataset_subscriptions.sms_notifications_hours_since', 1) since_delta = timedelta(hours=int(since_hours)) - since_datetime = (datetime.now(timezone.utc) - since_delta) + since_datetime = (datetime.utcnow() - since_delta) return since_datetime diff --git a/ckanext/dataset_subscriptions/actions/user.py b/ckanext/dataset_subscriptions/actions/user.py index f4a6b1f..5234cd7 100644 --- a/ckanext/dataset_subscriptions/actions/user.py +++ b/ckanext/dataset_subscriptions/actions/user.py @@ -78,11 +78,11 @@ def user_update(original_action, context, data_dict): @toolkit.side_effect_free def user_list(original_action, context, data_dict): user_list = original_action(context, data_dict) - include_plugin_extras = all_fields = toolkit.asbool(data_dict.get('include_plugin_extras', False)) + include_plugin_extras = toolkit.asbool(data_dict.get('include_plugin_extras', False)) all_fields = toolkit.asbool(data_dict.get('all_fields', True)) if all_fields and include_plugin_extras: - for user in user_list: - user = toolkit.get_action('user_show')(context, {'id': user['name']}) + for index, user in enumerate(user_list): + user_list[index] = toolkit.get_action('user_show')(context, {'id': user['name']}) return user_list