Skip to content

Commit

Permalink
MPP-3119: add waffle_flag_by_fxa_uid command
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Sep 30, 2024
1 parent 7011fe3 commit add4afd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions privaterelay/management/commands/waffle_flag_by_fxa_uid.py
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)

0 comments on commit add4afd

Please sign in to comment.