Use f-strings where we can

This commit is contained in:
blag 2022-12-26 22:26:07 -07:00
parent 6a6d3b7568
commit 1d951c0af9
No known key found for this signature in database
GPG key ID: 30870D32F59C5F40

View file

@ -51,11 +51,11 @@ class UserAgreementMiddleware(MiddlewareMixin):
# Skip if the user is allowed to skip - for instance, if the user is an
# admin or a staff member
if cache.get('django:tos:skip_tos_check:{0}'.format(str(user_id)), False, version=key_version):
if cache.get(f'django:tos:skip_tos_check:{user_id}', False, version=key_version):
return None
# Ping the cache for the user agreement
user_agreed = cache.get('django:tos:agreed:{0}'.format(str(user_id)), None, version=key_version)
user_agreed = cache.get(f'django:tos:agreed:{user_id}', None, version=key_version)
# If the cache is missing this user
if user_agreed is None:
@ -65,7 +65,7 @@ class UserAgreementMiddleware(MiddlewareMixin):
terms_of_service__active=True).exists()
# Set the value in the cache
cache.set('django:tos:agreed:{0}'.format(user_id), user_agreed, version=key_version)
cache.set(f'django:tos:agreed:{user_id}', user_agreed, version=key_version)
if not user_agreed:
# Confirm view uses these session keys. Non-middleware flow sets them in login view,