mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
Delete disabled users who never created an invoice
This commit is contained in:
parent
e574284936
commit
02040bfae9
1 changed files with 3 additions and 2 deletions
|
@ -17,6 +17,7 @@
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from cotisations.models import Facture
|
from cotisations.models import Facture
|
||||||
|
@ -27,13 +28,13 @@ from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Delete non members users (not yet active)."
|
help = "Delete non members users (not yet active or disabled too long ago without an invoice)."
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
"""First deleting invalid invoices, and then deleting the users"""
|
"""First deleting invalid invoices, and then deleting the users"""
|
||||||
days = OptionalUser.get_cached_value("delete_notyetactive")
|
days = OptionalUser.get_cached_value("delete_notyetactive")
|
||||||
users_to_delete = (
|
users_to_delete = (
|
||||||
User.objects.filter(state=User.STATE_NOT_YET_ACTIVE)
|
User.objects.filter(Q(state=User.STATE_NOT_YET_ACTIVE) | Q(state=User.STATE_DISABLED))
|
||||||
.filter(registered__lte=timezone.now() - timedelta(days=days))
|
.filter(registered__lte=timezone.now() - timedelta(days=days))
|
||||||
.exclude(facture__valid=True)
|
.exclude(facture__valid=True)
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|
Loading…
Reference in a new issue