diff --git a/registration/bin/delete_expired_users.py b/registration/bin/delete_expired_users.py deleted file mode 100644 index 87bd97f..0000000 --- a/registration/bin/delete_expired_users.py +++ /dev/null @@ -1,19 +0,0 @@ -""" -A script which removes expired/inactive user accounts from the -database. - -This is intended to be run as a cron job; for example, to have it run -at midnight each Sunday, you could add lines like the following to -your crontab:: - - DJANGO_SETTINGS_MODULE=yoursite.settings - 0 0 * * sun python /path/to/registration/bin/delete_expired_users.py - -See the method ``delete_expired_users`` of the ``RegistrationManager`` -class in ``registration/models.py`` for further documentation. - -""" - -if __name__ == '__main__': - from registration.models import RegistrationProfile - RegistrationProfile.objects.delete_expired_users() diff --git a/registration/cron.py b/registration/cron.py new file mode 100644 index 0000000..79a1187 --- /dev/null +++ b/registration/cron.py @@ -0,0 +1,20 @@ +import logging + +from registration.models import RegistrationProfile + +class RemoveExpiredProfiles(): + """ + Deletes expired profile requests + """ + + # run every 2 hours + run_every = 7200 + + @property + def _logger(self): + if not hasattr(self, '__logger'): + self.__logger = logging.getLogger(__name__) + return self.__logger + + def job(self): + RegistrationProfile.objects.delete_expired_users()