diff --git a/docs/source/developer/setup.rst b/docs/source/developer/setup.rst index 0f8aac96..b07aedf6 100644 --- a/docs/source/developer/setup.rst +++ b/docs/source/developer/setup.rst @@ -261,7 +261,7 @@ Add and modify the following lines accordingly: # This command deletes users that have expired (and should have # been deactivated by deactivate_expired_users) for more than # 18 months (which is the default duration) - 30 04 * * * /bin/python /manage.py delete_old_users + 30 04 * * * /bin/python /manage.py delete_old_radiusbatch_users Be sure to replace ```` with the absolute path to the Python virtual environment. diff --git a/docs/source/user/management_commands.rst b/docs/source/user/management_commands.rst index 5a1837cb..dd4f9ddd 100644 --- a/docs/source/user/management_commands.rst +++ b/docs/source/user/management_commands.rst @@ -75,7 +75,7 @@ This command deactivates expired user accounts which were created temporarily ./manage.py deactivate_expired_users -``delete_old_users`` +``delete_old_radiusbatch_users`` -------------------- This command deletes users that have expired (and should have been deactivated by diff --git a/openwisp_radius/management/commands/base/delete_old_users.py b/openwisp_radius/management/commands/base/delete_old_radiusbatch_users.py similarity index 94% rename from openwisp_radius/management/commands/base/delete_old_users.py rename to openwisp_radius/management/commands/base/delete_old_radiusbatch_users.py index 92957b36..b3504e7f 100644 --- a/openwisp_radius/management/commands/base/delete_old_users.py +++ b/openwisp_radius/management/commands/base/delete_old_radiusbatch_users.py @@ -9,7 +9,7 @@ RadiusBatch = load_model('RadiusBatch') -class BaseDeleteOldUsersCommand(BaseCommand): +class BaseDeleteOldRadiusBatchUsersCommand(BaseCommand): help = 'Deactivating users added in batches which have expired' def add_arguments(self, parser): diff --git a/openwisp_radius/management/commands/delete_old_radiusbatch_users.py b/openwisp_radius/management/commands/delete_old_radiusbatch_users.py new file mode 100644 index 00000000..99bc3baf --- /dev/null +++ b/openwisp_radius/management/commands/delete_old_radiusbatch_users.py @@ -0,0 +1,5 @@ +from .base.delete_old_radiusbatch_users import BaseDeleteOldRadiusBatchUsersCommand + + +class Command(BaseDeleteOldRadiusBatchUsersCommand): + pass diff --git a/openwisp_radius/management/commands/delete_old_users.py b/openwisp_radius/management/commands/delete_old_users.py deleted file mode 100644 index 216b3a7b..00000000 --- a/openwisp_radius/management/commands/delete_old_users.py +++ /dev/null @@ -1,5 +0,0 @@ -from .base.delete_old_users import BaseDeleteOldUsersCommand - - -class Command(BaseDeleteOldUsersCommand): - pass diff --git a/openwisp_radius/tasks.py b/openwisp_radius/tasks.py index ab31a413..b4d3d1c8 100644 --- a/openwisp_radius/tasks.py +++ b/openwisp_radius/tasks.py @@ -42,8 +42,8 @@ def deactivate_expired_users(): @shared_task -def delete_old_users(older_than_months=12): - management.call_command('delete_old_users', older_than_months=older_than_months) +def delete_old_radiusbatch_users(older_than_months=12): + management.call_command('delete_old_radiusbatch_users', older_than_months=older_than_months) @shared_task diff --git a/openwisp_radius/tests/test_commands.py b/openwisp_radius/tests/test_commands.py index 7ef8fbd9..0ccb5274 100644 --- a/openwisp_radius/tests/test_commands.py +++ b/openwisp_radius/tests/test_commands.py @@ -153,7 +153,7 @@ def test_deactivate_expired_users_command(self): self.assertEqual(get_user_model().objects.filter(is_active=True).count(), 0) @capture_stdout() - def test_delete_old_users_command(self): + def test_delete_old_radiusbatch_users_command(self): path = self._get_path('static/test_batch.csv') options = dict( organization=self.default_org.slug, @@ -172,9 +172,9 @@ def test_delete_old_users_command(self): ) self._call_command('batch_add_users', **options) self.assertEqual(get_user_model().objects.all().count(), 6) - call_command('delete_old_users') + call_command('delete_old_radiusbatch_users') self.assertEqual(get_user_model().objects.all().count(), 3) - call_command('delete_old_users', older_than_months=12) + call_command('delete_old_radiusbatch_users', older_than_months=12) self.assertEqual(get_user_model().objects.all().count(), 0) @capture_stdout() diff --git a/openwisp_radius/tests/test_tasks.py b/openwisp_radius/tests/test_tasks.py index 5db762f3..eff454c5 100644 --- a/openwisp_radius/tests/test_tasks.py +++ b/openwisp_radius/tests/test_tasks.py @@ -67,10 +67,10 @@ def test_deactivate_expired_users(self): self.assertFalse(user.is_active) @capture_stdout() - def test_delete_old_users(self): + def test_delete_old_radiusbatch_users(self): self._get_expired_user_from_radius_batch() self.assertEqual(User.objects.all().count(), 1) - result = tasks.delete_old_users.delay(1) + result = tasks.delete_old_radiusbatch_users.delay(1) self.assertTrue(result.successful()) self.assertEqual(User.objects.all().count(), 0) diff --git a/tests/openwisp2/sample_radius/management/commands/delete_old_radiusbatch_users.py b/tests/openwisp2/sample_radius/management/commands/delete_old_radiusbatch_users.py new file mode 100644 index 00000000..3742b981 --- /dev/null +++ b/tests/openwisp2/sample_radius/management/commands/delete_old_radiusbatch_users.py @@ -0,0 +1,7 @@ +from openwisp_radius.management.commands.base.delete_old_users import ( + BaseDeleteOldRadiusBatchUsersCommand, +) + + +class Command(BaseDeleteOldRadiusBatchUsersCommand): + pass diff --git a/tests/openwisp2/sample_radius/management/commands/delete_old_users.py b/tests/openwisp2/sample_radius/management/commands/delete_old_users.py deleted file mode 100644 index b078d1a9..00000000 --- a/tests/openwisp2/sample_radius/management/commands/delete_old_users.py +++ /dev/null @@ -1,7 +0,0 @@ -from openwisp_radius.management.commands.base.delete_old_users import ( - BaseDeleteOldUsersCommand, -) - - -class Command(BaseDeleteOldUsersCommand): - pass diff --git a/tests/openwisp2/settings.py b/tests/openwisp2/settings.py index e0e42094..99d4a60a 100644 --- a/tests/openwisp2/settings.py +++ b/tests/openwisp2/settings.py @@ -239,8 +239,8 @@ 'args': None, 'relative': True, }, - 'delete_old_users': { - 'task': 'openwisp_radius.tasks.delete_old_users', + 'delete_old_radiusbatch_users': { + 'task': 'openwisp_radius.tasks.delete_old_radiusbatch_users', 'schedule': crontab(hour=0, minute=10), 'args': [365], 'relative': True,