Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Call the preference combined_search_enabled

Claudece6b77d807d3
diff --git a/mwmbl/migrations/0042_mwmbluser_seed_search_enabled.py b/mwmbl/migrations/0042_mwmbluser_combined_search_enabled.py
similarity index 82%
rename from mwmbl/migrations/0042_mwmbluser_seed_search_enabled.py
rename to mwmbl/migrations/0042_mwmbluser_combined_search_enabled.py
index 97f15d3..8590425 100644
--- a/mwmbl/migrations/0042_mwmbluser_seed_search_enabled.py
+++ b/mwmbl/migrations/0042_mwmbluser_combined_search_enabled.py
@@ -6,17 +6,17 @@ class Migration(migrations.Migration):
("mwmbl", "0041_usagebucket_combined_search"),
]
- # Existing users get False, so nobody already registered has Seed Search switched on for them;
+ # Existing users get False, so nobody already registered has Combined Search switched on for them;
# the second step makes it on for accounts created from now on.
operations = [
migrations.AddField(
model_name="mwmbluser",
- name="seed_search_enabled",
+ name="combined_search_enabled",
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name="mwmbluser",
- name="seed_search_enabled",
+ name="combined_search_enabled",
field=models.BooleanField(default=True),
),
]
diff --git a/mwmbl/models.py b/mwmbl/models.py
index a09fdf3..7c24b32 100644
--- a/mwmbl/models.py
+++ b/mwmbl/models.py
@@ -12,7 +12,7 @@ from mwmbl.utils import bare_host
class MwmblUser(AbstractUser):
# On for new accounts. Accounts created before this field existed start off (see the migration).
- seed_search_enabled = models.BooleanField(default=True)
+ combined_search_enabled = models.BooleanField(default=True)
class UserCuration(models.Model):
diff --git a/mwmbl/platform/api.py b/mwmbl/platform/api.py
index 29dd7ff..5c8e37b 100644
--- a/mwmbl/platform/api.py
+++ b/mwmbl/platform/api.py
@@ -57,6 +57,7 @@ from mwmbl.platform.schemas import (
BulkDecisionRequest,
CheckoutRequest,
CheckoutResponse,
+ CombinedSearchPreference,
CombinedSearchUsageResponse,
ConfirmEmail,
CreateApiKeyRequest,
@@ -76,7 +77,6 @@ from mwmbl.platform.schemas import (
QueueItemSchema,
Registration,
ResetPasswordRequest,
- SeedSearchPreference,
SubmissionDetailSchema,
SubscriptionResponse,
UpdateDeviceRequest,
@@ -1369,28 +1369,29 @@ def get_combined_search_usage(request):
@router.get(
"/combined-search/preference",
auth=JWTAuth(),
- response=SeedSearchPreference,
- summary="Get Seed Search preference",
- description="Returns whether the user has Seed Search (Combined Search) switched on in the mwmbl.org "
- "interface. It does not affect calls to the Combined Search API.",
+ response=CombinedSearchPreference,
+ summary="Get Combined Search preference",
+ description="Returns whether the user has Combined Search switched on in the mwmbl.org interface. "
+ "It does not affect calls to the Combined Search API.",
tags=["Membership"],
)
-def get_seed_search_preference(request):
- return SeedSearchPreference(enabled=request.user.seed_search_enabled)
+def get_combined_search_preference(request):
+ return CombinedSearchPreference(enabled=request.user.combined_search_enabled)
@router.put(
"/combined-search/preference",
auth=JWTAuth(),
- response=SeedSearchPreference,
- summary="Set Seed Search preference",
- description="Switches Seed Search (Combined Search) on or off for the user in the mwmbl.org interface.",
+ response=CombinedSearchPreference,
+ summary="Set Combined Search preference",
+ description="Switches Combined Search on or off for the user in the mwmbl.org interface. "
+ "It does not affect calls to the Combined Search API.",
tags=["Membership"],
)
-def set_seed_search_preference(request, body: SeedSearchPreference):
- request.user.seed_search_enabled = body.enabled
- request.user.save(update_fields=["seed_search_enabled"])
- return SeedSearchPreference(enabled=request.user.seed_search_enabled)
+def set_combined_search_preference(request, body: CombinedSearchPreference):
+ request.user.combined_search_enabled = body.enabled
+ request.user.save(update_fields=["combined_search_enabled"])
+ return CombinedSearchPreference(enabled=request.user.combined_search_enabled)
@router.post(
diff --git a/mwmbl/platform/schemas.py b/mwmbl/platform/schemas.py
index f0f7b28..ffa1a8c 100644
--- a/mwmbl/platform/schemas.py
+++ b/mwmbl/platform/schemas.py
@@ -63,7 +63,7 @@ class CombinedSearchUsageResponse(Schema):
monthly_limit: int
-class SeedSearchPreference(Schema):
+class CombinedSearchPreference(Schema):
enabled: bool
diff --git a/test/test_seed_search_preference.py b/test/test_combined_search_preference.py
similarity index 83%
rename from test/test_seed_search_preference.py
rename to test/test_combined_search_preference.py
index cf7e1b2..ccc2ae9 100644
--- a/test/test_seed_search_preference.py
+++ b/test/test_combined_search_preference.py
@@ -31,11 +31,11 @@ def _set(client, auth, enabled):
@pytest.mark.django_db
-def test_a_newly_registered_user_has_seed_search_on(client):
+def test_a_newly_registered_user_has_combined_search_on(client):
body = {"email": "[email protected]", "password": "correctpassword", "username": "newbie"}
client.post(REGISTER_URL, data=json.dumps(body), content_type="application/json")
- assert User.objects.get(username="newbie").seed_search_enabled
+ assert User.objects.get(username="newbie").combined_search_enabled
@pytest.mark.django_db
@@ -47,22 +47,22 @@ def test_the_preference_endpoint_reports_the_users_setting(client, user, auth):
@pytest.mark.django_db
-def test_switching_seed_search_off_is_saved(client, user, auth):
+def test_switching_combined_search_off_is_saved(client, user, auth):
response = _set(client, auth, False)
user.refresh_from_db()
assert response.json() == {"enabled": False}
- assert not user.seed_search_enabled
+ assert not user.combined_search_enabled
assert client.get(PREFERENCE_URL, **auth).json() == {"enabled": False}
@pytest.mark.django_db
-def test_switching_seed_search_back_on_is_saved(client, user, auth):
+def test_switching_combined_search_back_on_is_saved(client, user, auth):
_set(client, auth, False)
_set(client, auth, True)
user.refresh_from_db()
- assert user.seed_search_enabled
+ assert user.combined_search_enabled
@pytest.mark.django_db