1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
from __future__ import unicode_literals |
3
|
|
|
""" |
4
|
|
|
A management command which deletes expired or rejected accounts (e.g., |
5
|
|
|
accounts which signed up but never activated) from the database. |
6
|
|
|
|
7
|
|
|
Calls ``RegistrationProfile.objects.delete_expired_users()`` and |
8
|
|
|
``RegistrationProfile.objects.delete_rejected_users()``, which |
9
|
|
|
contains the actual logic for determining which accounts are deleted. |
10
|
|
|
|
11
|
|
|
This is a modification of django-registration_ ``cleanupregistration.py`` |
12
|
|
|
The original code is written by James Bennett |
13
|
|
|
|
14
|
|
|
.. _django-registration: https://bitbucket.org/ubernostrum/django-registration |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
Original License:: |
18
|
|
|
|
19
|
|
|
Copyright (c) 2007-2011, James Bennett |
20
|
|
|
All rights reserved. |
21
|
|
|
|
22
|
|
|
Redistribution and use in source and binary forms, with or without |
23
|
|
|
modification, are permitted provided that the following conditions are |
24
|
|
|
met: |
25
|
|
|
|
26
|
|
|
* Redistributions of source code must retain the above copyright |
27
|
|
|
notice, this list of conditions and the following disclaimer. |
28
|
|
|
* Redistributions in binary form must reproduce the above |
29
|
|
|
copyright notice, this list of conditions and the following |
30
|
|
|
disclaimer in the documentation and/or other materials provided |
31
|
|
|
with the distribution. |
32
|
|
|
* Neither the name of the author nor the names of other |
33
|
|
|
contributors may be used to endorse or promote products derived |
34
|
|
|
from this software without specific prior written permission. |
35
|
|
|
|
36
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
37
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
38
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
39
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
40
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
41
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
42
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
43
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
44
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
45
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
46
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
47
|
|
|
""" |
48
|
|
|
__author__ = 'Alisue <[email protected]>' |
49
|
|
|
from registration.models import RegistrationProfile |
50
|
|
|
try: |
51
|
|
|
from django.core.management import BaseCommand |
52
|
|
|
|
53
|
|
|
class Command(BaseCommand): |
54
|
|
|
help = "Delete expired/rejected user registrations from the database" |
55
|
|
|
|
56
|
|
|
def handle(self, **options): |
57
|
|
|
RegistrationProfile.objects.delete_expired_users() |
58
|
|
|
RegistrationProfile.objects.delete_rejected_users() |
59
|
|
|
except ImportError: |
60
|
|
|
from django.core.management import NoArgsCommand |
61
|
|
|
|
62
|
|
|
class Command(NoArgsCommand): |
63
|
|
|
help = "Delete expired/rejected user registrations from the database" |
64
|
|
|
|
65
|
|
|
def handle_noargs(self, **options): |
66
|
|
|
RegistrationProfile.objects.delete_expired_users() |
67
|
|
|
RegistrationProfile.objects.delete_rejected_users() |
68
|
|
|
|