mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Format auth_type in a consistent way in the UI
On the ‘find user’ page it says ‘sms_auth’ instead of ‘Text message code’. This commit fixes that, and adds a handy formatter so it’s easier to do the right thing in the future.
This commit is contained in:
@@ -528,3 +528,16 @@ def format_yes_no(value, yes='Yes', no='No', none='No'):
|
||||
|
||||
def square_metres_to_square_miles(area):
|
||||
return area * 3.86e-7
|
||||
|
||||
|
||||
def format_auth_type(auth_type, with_indefinite_article=False):
|
||||
indefinite_article, auth_type = {
|
||||
'email_auth': ('an', 'Email link'),
|
||||
'sms_auth': ('a', 'Text message code'),
|
||||
'webauthn_auth': ('a', 'Security key'),
|
||||
}.get(auth_type, ('a', auth_type))
|
||||
|
||||
if with_indefinite_article:
|
||||
return f'{indefinite_article} {auth_type.lower()}'
|
||||
|
||||
return auth_type
|
||||
|
||||
Reference in New Issue
Block a user