-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MPP-3119: add waffle_flag_by_fxa_uid command
- Loading branch information
1 parent
7011fe3
commit add4afd
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
privaterelay/management/commands/waffle_flag_by_fxa_uid.py
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,25 @@ | ||
from typing import Any | ||
|
||
from django.core.management.base import CommandParser | ||
|
||
from allauth.socialaccount.models import SocialAccount | ||
from waffle.management.commands.waffle_flag import Command as FlagCommand | ||
|
||
|
||
class Command(FlagCommand): | ||
def add_arguments(self, parser: CommandParser) -> None: | ||
parser.add_argument( | ||
"--fxa", | ||
action="append", | ||
default=list(), | ||
help="Turn on the flag for listed FXA uids.", | ||
) | ||
return super().add_arguments(parser) | ||
|
||
def handle(self, *args: Any, **options: Any) -> None: | ||
if "fxa" in options: | ||
uids: list[str] = options.get("fxa", []) | ||
for uid in uids: | ||
social_account = SocialAccount.objects.get(uid=uid, provider="fxa") | ||
options["user"].append(social_account.user.email) | ||
return super().handle(*args, **options) |