forked from doubaniux/boofilsic
-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
932b13c
commit c872af7
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
from loguru import logger | ||
from tqdm import tqdm | ||
|
||
from users.models import Preference, User | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Manage import tasks" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--reset", | ||
action="store_true", | ||
) | ||
|
||
def handle(self, *args, **options): | ||
if options["reset"]: | ||
count = 0 | ||
for user in tqdm(User.objects.all()): | ||
if user.preference.import_status.get("douban_pending"): | ||
user.preference.import_status["douban_pending"] = False | ||
user.preference.save(update_fields=["import_status"]) | ||
count += 1 | ||
self.stdout.write(self.style.SUCCESS(f"{count} users reset")) | ||
|