Skip to content

Commit

Permalink
[change] Changed the command to delete_old_radiusbatch_users #496
Browse files Browse the repository at this point in the history
[change] Changed delete_old_users command to delete_old_radiusbatch_users to help users understand the purpose of the command more clearly.

Closes #496
  • Loading branch information
praptisharma28 committed Dec 26, 2023
1 parent 90786b1 commit a88be38
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/source/developer/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * * <virtualenv_path>/bin/python <full/path/to>/manage.py delete_old_users
30 04 * * * <virtualenv_path>/bin/python <full/path/to>/manage.py delete_old_radiusbatch_users
Be sure to replace ``<virtualenv_path>`` with the absolute path to the Python
virtual environment.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user/management_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .base.delete_old_radiusbatch_users import BaseDeleteOldRadiusBatchUsersCommand


class Command(BaseDeleteOldRadiusBatchUsersCommand):
pass
5 changes: 0 additions & 5 deletions openwisp_radius/management/commands/delete_old_users.py

This file was deleted.

4 changes: 2 additions & 2 deletions openwisp_radius/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions openwisp_radius/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions openwisp_radius/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from openwisp_radius.management.commands.base.delete_old_users import (
BaseDeleteOldRadiusBatchUsersCommand,
)


class Command(BaseDeleteOldRadiusBatchUsersCommand):
pass

This file was deleted.

4 changes: 2 additions & 2 deletions tests/openwisp2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a88be38

Please sign in to comment.