This PR makes the endpoint /users/me/suggestions/{poll_name}/tocompare/ able to return recommended entities matching the logged user's preferred languages. This should close the milestone Video selector redesign.
The preferred languages are determined using the following procedure:
check the user's settings for the poll
if the setting hasn't been configured, check the HTTP header Accept-Language
if the languages en or fr are not present in the preferred languages, add en
The fallback language en is explicitly hardcoded in the back end. This might not be satisfactory if we want to make the back end generic. This trick ensures new users without entities in their rate-later list will always be suggested entities by the Auto button, even if there is no recommendations matching their preferred languages.
related issues #1834
Description
This PR makes the endpoint
/users/me/suggestions/{poll_name}/tocompare/
able to return recommended entities matching the logged user's preferred languages. This should close the milestone Video selector redesign.The preferred languages are determined using the following procedure:
Accept-Language
en
orfr
are not present in the preferred languages, adden
The fallback language
en
is explicitly hardcoded in the back end. This might not be satisfactory if we want to make the back end generic. This trick ensures new users without entities in their rate-later list will always be suggested entities by the Auto button, even if there is no recommendations matching their preferred languages.See also the behaviour of the tutorial: https://github.com/tournesol-app/tournesol/blob/4f67252a9a702b0e376d961577ad439b81a3d69d/frontend/src/utils/polls/videos.tsx#L54
to-do
model - User
get_recommendations_default_langs
take a poll name as argumentview - SuggestionsToCompare
get_recommendations_default_langs
en
tests
ClassicEntitySuggestionStrategy
Checklist