all: implement black as code formatter
This commit is contained in:
@ -17,30 +17,40 @@ LOGGER = get_logger()
|
||||
class Command(BaseCommand):
|
||||
"""Create Nonce used to recover access"""
|
||||
|
||||
help = _('Create a Key which can be used to restore access to passbook.')
|
||||
help = _("Create a Key which can be used to restore access to passbook.")
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('duration', default=1, action='store',
|
||||
help='How long the token is valid for (in years).')
|
||||
parser.add_argument('user', action='store',
|
||||
help='Which user the Token gives access to.')
|
||||
parser.add_argument(
|
||||
"duration",
|
||||
default=1,
|
||||
action="store",
|
||||
help="How long the token is valid for (in years).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"user", action="store", help="Which user the Token gives access to."
|
||||
)
|
||||
|
||||
def get_url(self, nonce: Nonce) -> str:
|
||||
"""Get full recovery link"""
|
||||
path = reverse('passbook_recovery:use-nonce', kwargs={'uuid': str(nonce.uuid)})
|
||||
path = reverse("passbook_recovery:use-nonce", kwargs={"uuid": str(nonce.uuid)})
|
||||
return f"https://{CONFIG.y('domain')}{path}"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""Create Nonce used to recover access"""
|
||||
duration = int(options.get('duration', 1))
|
||||
duration = int(options.get("duration", 1))
|
||||
delta = timedelta(days=duration * 365.2425)
|
||||
_now = now()
|
||||
expiry = _now + delta
|
||||
user = User.objects.get(username=options.get('user'))
|
||||
user = User.objects.get(username=options.get("user"))
|
||||
nonce = Nonce.objects.create(
|
||||
expires=expiry,
|
||||
user=user,
|
||||
description=f'Recovery Nonce generated by {getuser()} on {_now}')
|
||||
self.stdout.write((f"Store this link safely, as it will allow"
|
||||
f" anyone to access passbook as {user}."))
|
||||
description=f"Recovery Nonce generated by {getuser()} on {_now}",
|
||||
)
|
||||
self.stdout.write(
|
||||
(
|
||||
f"Store this link safely, as it will allow"
|
||||
f" anyone to access passbook as {user}."
|
||||
)
|
||||
)
|
||||
self.stdout.write(self.get_url(nonce))
|
||||
|
Reference in New Issue
Block a user