delete_users --real-phones: every phone user except the demo logins
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,11 @@
|
||||
|
||||
python manage.py delete_users --phones 09121234567 09351234567
|
||||
python manage.py delete_users --ids 17 22 --yes
|
||||
python manage.py delete_users --real-phones # هر کاربرِ شمارهدار جز شمارههای دمو
|
||||
|
||||
`--real-phones` یعنی هر کاربری که شماره دارد و شمارهاش در TEST_LOGIN_PHONES (حسابهای دمو با کدِ
|
||||
ثابت) نیست. شمارهها از سرور بیرون نمیآیند؛ گزارش فقط چهار رقمِ اول و سه رقمِ آخر را نشان میدهد.
|
||||
مهمانها (بیشماره) با این گزینه انتخاب نمیشوند.
|
||||
|
||||
سفارشِ پرداختشده سندِ مالی است؛ کاربری که سفارشِ «paid» دارد بدونِ --include-paid پاک نمیشود.
|
||||
"""
|
||||
@@ -64,6 +69,8 @@ class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--phones', nargs='*', default=[])
|
||||
parser.add_argument('--ids', nargs='*', type=int, default=[])
|
||||
parser.add_argument('--real-phones', action='store_true',
|
||||
help='همهی کاربرهای شمارهدار جز شمارههای TEST_LOGIN_PHONES.')
|
||||
parser.add_argument('--yes', action='store_true', help='واقعاً پاک کن.')
|
||||
parser.add_argument('--include-paid', action='store_true',
|
||||
help='کاربرِ دارای سفارشِ پرداختشده را هم پاک کن.')
|
||||
@@ -71,6 +78,11 @@ class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
phones = [normalize_phone(p) or p for p in options['phones']]
|
||||
users = list(User.objects.filter(phone__in=phones)) + list(User.objects.filter(pk__in=options['ids']))
|
||||
if options['real_phones']:
|
||||
from django.conf import settings
|
||||
|
||||
users += list(User.objects.exclude(phone=None).exclude(phone='')
|
||||
.exclude(phone__in=list(settings.TEST_LOGIN_PHONES)))
|
||||
users = list({u.pk: u for u in users}.values())
|
||||
missing = set(phones) - {u.phone for u in users}
|
||||
if missing:
|
||||
|
||||
Reference in New Issue
Block a user