From e392a5d1edd6d03bc1909d7acb6e2f0e040b6b29 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Thu, 14 May 2026 16:03:01 +0530 Subject: [PATCH 1/4] [chores] Added support for user expiration reminders #608 - Added celery beat schedule for expiration reminder emails - Added support for openwisp_users expiration tasks - Added configurable reminder email schedule variable Closes #608 --- defaults/main.yml | 6 +++++- docs/user/role-variables.rst | 3 ++- templates/openwisp2/settings.py | 17 ++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 249bdc91..580fe010 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,6 +17,9 @@ openwisp2_radius_version: "openwisp-radius @ https://github.com/openwisp/openwis openwisp2_django_version: "django~=5.2.0" openwisp2_extra_python_packages: - bpython + # TODO: Remove before merging + - "openwisp-radius[openvpn_status] @ https://github.com/openwisp/openwisp-radius/tarball/issues/706-user-expiration" + - "openwisp-users @ https://github.com/openwisp/openwisp-users/tarball/issues/499-user-expiration" openwisp2_extra_django_apps: [] openwisp2_extra_django_settings: {} openwisp2_extra_django_settings_instructions: [] @@ -212,7 +215,8 @@ freeradius_eap_openwisp_site_template_src: freeradius/eap/openwisp_site.j2 freeradius_eap_inner_tunnel_template_src: freeradius/eap/inner_tunnel.j2 freeradius_eap_template_src: freeradius/eap/eap.j2 cron_delete_old_notifications: "'hour': 0, 'minute': 0" -cron_deactivate_expired_users: "'hour': 0, 'minute': 5" +cron_expiration_reminder_email: "'hour': 0, 'minute': 3" +cron_deactivate_expired_users: "'hour': 0, 'minute': 1" cron_delete_old_radiusbatch_users: "'hour': 0, 'minute': 10" cron_cleanup_stale_radacct: "'hour': 0, 'minute': 20" cron_delete_old_postauth: "'hour': 0, 'minute': 30" diff --git a/docs/user/role-variables.rst b/docs/user/role-variables.rst index 7141b00b..c840d8f8 100644 --- a/docs/user/role-variables.rst +++ b/docs/user/role-variables.rst @@ -447,7 +447,8 @@ take a look at `the default values of these variables # Defaults to "templates/freeradius/eap/eap.j2" shipped in the role. freeradius_eap_template_src: custom_eap.j2 cron_delete_old_notifications: "'hour': 0, 'minute': 0" - cron_deactivate_expired_users: "'hour': 0, 'minute': 5" + cron_expiration_reminder_email: "'hour': 0, 'minute': 3" + cron_deactivate_expired_users: "'hour': 0, 'minute': 1" cron_delete_old_radiusbatch_users: "'hour': 0, 'minute': 10" cron_cleanup_stale_radacct: "'hour': 0, 'minute': 20" cron_delete_old_postauth: "'hour': 0, 'minute': 30" diff --git a/templates/openwisp2/settings.py b/templates/openwisp2/settings.py index 68852fea..610a301b 100644 --- a/templates/openwisp2/settings.py +++ b/templates/openwisp2/settings.py @@ -245,7 +245,6 @@ CELERY_BROKER_TRANSPORT_OPTIONS = { "max_retries": {{ openwisp2_celery_broker_max_tries }}, } - CELERY_BEAT_SCHEDULE = { {% if openwisp2_users_user_password_expiration or openwisp2_users_staff_user_password_expiration %} "password_expiry_email": { @@ -253,6 +252,15 @@ "schedule": crontab(**{ {{ cron_password_expiration_email }} }), }, {% endif %} + "deactivate_expired_users": { + "task": "openwisp_users.tasks.deactivate_expired_users", + "schedule": crontab(**{ {{ cron_deactivate_expired_users }} }), + "args": None, + }, + "expiration_reminder_email": { + "task": "openwisp_users.tasks.expiration_reminder_email", + "schedule": crontab(**{ {{ cron_expiration_reminder_email }} }), + }, {% if openwisp2_notifications_delete_old_notifications %} "delete_old_notifications": { "task": "openwisp_notifications.tasks.delete_old_notifications", @@ -267,12 +275,6 @@ }, {% endif %} {% if openwisp2_radius and openwisp2_radius_periodic_tasks %} - "deactivate_expired_users": { - "task": "openwisp_radius.tasks.deactivate_expired_users", - "schedule": crontab(**{ {{ cron_deactivate_expired_users }} }), - "args": None, - "relative": True, - }, "delete_old_radiusbatch_users": { "task": "openwisp_radius.tasks.delete_old_radiusbatch_users", "schedule": crontab(**{ {{ cron_delete_old_radiusbatch_users }} }), @@ -415,6 +417,7 @@ LANGUAGE_CODE = "{{ openwisp2_language_code }}" TIME_ZONE = "{{ openwisp2_time_zone }}" +CELERY_TIMEZONE = TIME_ZONE {% if openwisp2_internationalization %} USE_I18N = True {% endif %} From 0c944bef3297430019701060b189eb8f01a41814 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Wed, 27 May 2026 13:29:37 +0530 Subject: [PATCH 2/4] [chores] Removed extra deps --- defaults/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 580fe010..6d52ee16 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,9 +17,6 @@ openwisp2_radius_version: "openwisp-radius @ https://github.com/openwisp/openwis openwisp2_django_version: "django~=5.2.0" openwisp2_extra_python_packages: - bpython - # TODO: Remove before merging - - "openwisp-radius[openvpn_status] @ https://github.com/openwisp/openwisp-radius/tarball/issues/706-user-expiration" - - "openwisp-users @ https://github.com/openwisp/openwisp-users/tarball/issues/499-user-expiration" openwisp2_extra_django_apps: [] openwisp2_extra_django_settings: {} openwisp2_extra_django_settings_instructions: [] From 8204f0cf88bb4216eb40f7081a2be58a72c7f0f7 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Wed, 27 May 2026 13:44:53 +0530 Subject: [PATCH 3/4] [chores] Removed blank line changes --- templates/openwisp2/settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/openwisp2/settings.py b/templates/openwisp2/settings.py index 610a301b..3191bc40 100644 --- a/templates/openwisp2/settings.py +++ b/templates/openwisp2/settings.py @@ -245,6 +245,7 @@ CELERY_BROKER_TRANSPORT_OPTIONS = { "max_retries": {{ openwisp2_celery_broker_max_tries }}, } + CELERY_BEAT_SCHEDULE = { {% if openwisp2_users_user_password_expiration or openwisp2_users_staff_user_password_expiration %} "password_expiry_email": { @@ -418,6 +419,7 @@ LANGUAGE_CODE = "{{ openwisp2_language_code }}" TIME_ZONE = "{{ openwisp2_time_zone }}" CELERY_TIMEZONE = TIME_ZONE + {% if openwisp2_internationalization %} USE_I18N = True {% endif %} From 8a620545cf05bf02ad0413304363cd504f43bd5e Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Thu, 28 May 2026 17:58:05 -0300 Subject: [PATCH 4/4] [chores] Minor improvements --- defaults/main.yml | 2 +- templates/openwisp2/settings.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6d52ee16..dd1cfe3a 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -212,8 +212,8 @@ freeradius_eap_openwisp_site_template_src: freeradius/eap/openwisp_site.j2 freeradius_eap_inner_tunnel_template_src: freeradius/eap/inner_tunnel.j2 freeradius_eap_template_src: freeradius/eap/eap.j2 cron_delete_old_notifications: "'hour': 0, 'minute': 0" -cron_expiration_reminder_email: "'hour': 0, 'minute': 3" cron_deactivate_expired_users: "'hour': 0, 'minute': 1" +cron_expiration_reminder_email: "'hour': 0, 'minute': 3" cron_delete_old_radiusbatch_users: "'hour': 0, 'minute': 10" cron_cleanup_stale_radacct: "'hour': 0, 'minute': 20" cron_delete_old_postauth: "'hour': 0, 'minute': 30" diff --git a/templates/openwisp2/settings.py b/templates/openwisp2/settings.py index 3191bc40..10a75abd 100644 --- a/templates/openwisp2/settings.py +++ b/templates/openwisp2/settings.py @@ -256,7 +256,6 @@ "deactivate_expired_users": { "task": "openwisp_users.tasks.deactivate_expired_users", "schedule": crontab(**{ {{ cron_deactivate_expired_users }} }), - "args": None, }, "expiration_reminder_email": { "task": "openwisp_users.tasks.expiration_reminder_email",