settings: Rename TOS_VERSION to TERMS_OF_SERVICE_VERSION.

The previous version was appropriate in a setting where it was only
used for Zulip Cloud, but it's definitely clearer to spell it out.
This commit is contained in:
Tim Abbott 2021-12-06 17:23:24 -08:00
parent 90aa45a316
commit 4cb189fc63
9 changed files with 22 additions and 16 deletions

View File

@ -745,7 +745,7 @@ def do_activate_mirror_dummy_user(
user_profile.is_mirror_dummy = False user_profile.is_mirror_dummy = False
user_profile.set_unusable_password() user_profile.set_unusable_password()
user_profile.date_joined = timezone_now() user_profile.date_joined = timezone_now()
user_profile.tos_version = settings.TOS_VERSION user_profile.tos_version = settings.TERMS_OF_SERVICE_VERSION
user_profile.save( user_profile.save(
update_fields=["date_joined", "password", "is_mirror_dummy", "tos_version"] update_fields=["date_joined", "password", "is_mirror_dummy", "tos_version"]
) )
@ -4438,7 +4438,7 @@ def do_change_tos_version(user_profile: UserProfile, tos_version: str) -> None:
realm=user_profile.realm, realm=user_profile.realm,
acting_user=user_profile, acting_user=user_profile,
modified_user=user_profile, modified_user=user_profile,
event_type=RealmAuditLog.USER_TOS_VERSION_CHANGED, event_type=RealmAuditLog.USER_TERMS_OF_SERVICE_VERSION_CHANGED,
event_time=event_time, event_time=event_time,
) )

View File

@ -106,7 +106,7 @@ class Command(ZulipBaseCommand):
raise error raise error
# Only email users who've agreed to the terms of service. # Only email users who've agreed to the terms of service.
if settings.TOS_VERSION is not None: if settings.TERMS_OF_SERVICE_VERSION is not None:
# We need to do a new query because the `get_users` path # We need to do a new query because the `get_users` path
# passes us a list rather than a QuerySet. # passes us a list rather than a QuerySet.
users = ( users = (

View File

@ -3846,7 +3846,7 @@ class AbstractRealmAuditLog(models.Model):
USER_AVATAR_SOURCE_CHANGED = 123 USER_AVATAR_SOURCE_CHANGED = 123
USER_FULL_NAME_CHANGED = 124 USER_FULL_NAME_CHANGED = 124
USER_EMAIL_CHANGED = 125 USER_EMAIL_CHANGED = 125
USER_TOS_VERSION_CHANGED = 126 USER_TERMS_OF_SERVICE_VERSION_CHANGED = 126
USER_API_KEY_CHANGED = 127 USER_API_KEY_CHANGED = 127
USER_BOT_OWNER_CHANGED = 128 USER_BOT_OWNER_CHANGED = 128
USER_DEFAULT_SENDING_STREAM_CHANGED = 129 USER_DEFAULT_SENDING_STREAM_CHANGED = 129

View File

@ -221,7 +221,7 @@ class TestRealmAuditLog(ZulipTestCase):
do_change_tos_version(user, tos_version) do_change_tos_version(user, tos_version)
self.assertEqual( self.assertEqual(
RealmAuditLog.objects.filter( RealmAuditLog.objects.filter(
event_type=RealmAuditLog.USER_TOS_VERSION_CHANGED, event_time__gte=now event_type=RealmAuditLog.USER_TERMS_OF_SERVICE_VERSION_CHANGED, event_time__gte=now
).count(), ).count(),
1, 1,
) )

View File

@ -457,7 +457,9 @@ class HomeTest(ZulipTestCase):
user.tos_version = user_tos_version user.tos_version = user_tos_version
user.save() user.save()
with self.settings(TERMS_OF_SERVICE="whatever"), self.settings(TOS_VERSION="99.99"): with self.settings(TERMS_OF_SERVICE="whatever"), self.settings(
TERMS_OF_SERVICE_VERSION="99.99"
):
result = self.client_get("/", dict(stream="Denmark")) result = self.client_get("/", dict(stream="Denmark"))
@ -495,7 +497,7 @@ class HomeTest(ZulipTestCase):
user.save() user.save()
with self.settings(FIRST_TIME_TOS_TEMPLATE="hello.html"), self.settings( with self.settings(FIRST_TIME_TOS_TEMPLATE="hello.html"), self.settings(
TOS_VERSION="99.99" TERMS_OF_SERVICE_VERSION="99.99"
): ):
result = self.client_post("/accounts/accept_terms/") result = self.client_post("/accounts/accept_terms/")
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)

View File

@ -29,10 +29,10 @@ def need_accept_tos(user_profile: Optional[UserProfile]) -> bool:
if settings.TERMS_OF_SERVICE is None: # nocoverage if settings.TERMS_OF_SERVICE is None: # nocoverage
return False return False
if settings.TOS_VERSION is None: if settings.TERMS_OF_SERVICE_VERSION is None:
return False return False
return int(settings.TOS_VERSION.split(".")[0]) > user_profile.major_tos_version() return int(settings.TERMS_OF_SERVICE_VERSION.split(".")[0]) > user_profile.major_tos_version()
@zulip_login_required @zulip_login_required
@ -42,7 +42,7 @@ def accounts_accept_terms(request: HttpRequest) -> HttpResponse:
if request.method == "POST": if request.method == "POST":
form = ToSForm(request.POST) form = ToSForm(request.POST)
if form.is_valid(): if form.is_valid():
do_change_tos_version(request.user, settings.TOS_VERSION) do_change_tos_version(request.user, settings.TERMS_OF_SERVICE_VERSION)
return redirect(home) return redirect(home)
else: else:
form = ToSForm() form = ToSForm()

View File

@ -446,7 +446,7 @@ def accounts_register(
full_name, full_name,
prereg_user=prereg_user, prereg_user=prereg_user,
role=role, role=role,
tos_version=settings.TOS_VERSION, tos_version=settings.TERMS_OF_SERVICE_VERSION,
timezone=timezone, timezone=timezone,
default_stream_groups=default_stream_groups, default_stream_groups=default_stream_groups,
source_profile=source_profile, source_profile=source_profile,

View File

@ -465,7 +465,7 @@ class Command(BaseCommand):
email = fname.lower() + "@zulip.com" email = fname.lower() + "@zulip.com"
names.append((full_name, email)) names.append((full_name, email))
create_users(zulip_realm, names, tos_version=settings.TOS_VERSION) create_users(zulip_realm, names, tos_version=settings.TERMS_OF_SERVICE_VERSION)
iago = get_user_by_delivery_email("iago@zulip.com", zulip_realm) iago = get_user_by_delivery_email("iago@zulip.com", zulip_realm)
do_change_user_role(iago, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None) do_change_user_role(iago, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
@ -787,13 +787,17 @@ class Command(BaseCommand):
("Athena Consulting Exchange User (MIT)", "starnine@mit.edu"), ("Athena Consulting Exchange User (MIT)", "starnine@mit.edu"),
("Esp Classroom (MIT)", "espuser@mit.edu"), ("Esp Classroom (MIT)", "espuser@mit.edu"),
] ]
create_users(mit_realm, testsuite_mit_users, tos_version=settings.TOS_VERSION) create_users(
mit_realm, testsuite_mit_users, tos_version=settings.TERMS_OF_SERVICE_VERSION
)
testsuite_lear_users = [ testsuite_lear_users = [
("King Lear", "king@lear.org"), ("King Lear", "king@lear.org"),
("Cordelia, Lear's daughter", "cordelia@zulip.com"), ("Cordelia, Lear's daughter", "cordelia@zulip.com"),
] ]
create_users(lear_realm, testsuite_lear_users, tos_version=settings.TOS_VERSION) create_users(
lear_realm, testsuite_lear_users, tos_version=settings.TERMS_OF_SERVICE_VERSION
)
if not options["test_suite"]: if not options["test_suite"]:
# To keep the messages.json fixtures file for the test # To keep the messages.json fixtures file for the test

View File

@ -358,8 +358,8 @@ REALM_CREATION_LINK_VALIDITY_DAYS = 7
# Version number for ToS. Change this if you want to force every # Version number for ToS. Change this if you want to force every
# user to click through to re-accept terms of service before using # user to click through to re-accept terms of service before using
# Zulip again on the web. # Zulip again on the web.
TOS_VERSION: Optional[str] = None TERMS_OF_SERVICE_VERSION: Optional[str] = None
# Template to use when bumping TOS_VERSION to explain situation. # Template to use when bumping TERMS_OF_SERVICE_VERSION to explain situation.
FIRST_TIME_TOS_TEMPLATE: Optional[str] = None FIRST_TIME_TOS_TEMPLATE: Optional[str] = None
# Hostname used for Zulip's statsd logging integration. # Hostname used for Zulip's statsd logging integration.