diff --git a/Makefile b/Makefile index ed97a608..8494c477 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ build_dummy_translations: extract_translations dummy_translations compile_transl validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations install_transifex_client: ## Install the Transifex client - # Instaling client will skip CHANGELOG and LICENSE files from git changes + # Installing client will skip CHANGELOG and LICENSE files from git changes # so remind the user to commit the change first before installing client. git diff -s --exit-code HEAD || { echo "Please commit changes first."; exit 1; } curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash diff --git a/README.rst b/README.rst index 071e1dd4..a9920f87 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,9 @@ When developing this application, it is recommended to clone this repository loc git clone git@github.com:openedx/forum.git tutor mounts add ./forum/ -Check that the forum repository is properly bind-mounted both at build- and run-time by running ``tutor mounts list``. It should output the following:: +Check that the forum repository is properly bind-mounted both at build- and run-time by running ``tutor mounts list``. It should output the following: + +.. code-block:: yml - name: /home/path/to/forum build_mounts: @@ -67,9 +69,11 @@ In edx-platform, forum v2 is not enabled by default and edx-platform will keep c Note that Tutor enables this flag for all forum plugin users, such that you don't have to run this command yourself. If you wish to migrate your courses one by one to the new forum v2 app, you may create the corresponding "Waffle flag course override" objects in your LMS administration panel, at: ``http(s):///admin/waffle_utils/waffleflagcourseoverridemodel/``. -⚠️⚠️⚠️ Even if the forum v2 toggle is not enabled, edx-platform will make a call to the forum v2 API in some edge cases. That's because edx-platform needs to determine whether it should use forum v2 or cs_comments_service, based on the value of some course waffle flag. In order to access the course wafffle flag, we need to determine the course ID of the current HTTP request. In some requests, the course ID is not available: only the thread ID or the comment ID is. Thus, edx-platform needs to fetch the course ID that is associated to the thread or comment. That information is stored either in MySQL or in MongoDB. Thus, edx-platform needs to call the forum v2 API. +⚠️⚠️⚠️ Even if the forum v2 toggle is not enabled, edx-platform will make a call to the forum v2 API in some edge cases. That's because edx-platform needs to determine whether it should use forum v2 or cs_comments_service, based on the value of some course waffle flag. In order to access the course waffle flag, we need to determine the course ID of the current HTTP request. In some requests, the course ID is not available: only the thread ID or the comment ID is. Thus, edx-platform needs to fetch the course ID that is associated to the thread or comment. That information is stored either in MySQL or in MongoDB. Thus, edx-platform needs to call the forum v2 API. + +As a consequence, **the forum v2 app needs to have accurate MongoDB configuration settings even if you don't use forum v2**. In a Tutor installation, these settings are set to the right values. In other environments, the following Django settings must be set: -As a consequence, **the forum v2 app needs to have accurate MongoDB configuration settings even if you don't use forum v2**. In a Tutor installation, these settings are set to the right values. In other environments, the following Django settings must be set:: +.. code-block:: python # Name of the MongoDB database in which forum data is stored FORUM_MONGODB_DATABASE = "cs_comments_service" @@ -82,7 +86,7 @@ As a consequence, **the forum v2 app needs to have accurate MongoDB configuratio MySQL backend toggle -------------------- -To preserve the legacy behaviour of storing data in MongoDB, the forum v2 app makes it possible to keep using MongoDB as a data backend. However, it is strongly recommended to switch to the MySQL storage backend by toggling the ``forum_v2.enable_mysql_backend`` course waffle flag:: +To preserve the legacy behavior of storing data in MongoDB, the forum v2 app makes it possible to keep using MongoDB as a data backend. However, it is strongly recommended to switch to the MySQL storage backend by toggling the ``forum_v2.enable_mysql_backend`` course waffle flag:: ./manage.py lms waffle_flag --create --everyone forum_v2.enable_mysql_backend @@ -136,7 +140,7 @@ To create or update MongoDB indexes, execute the following command:: ./manage.py lms forum_create_mongodb_indexes -Search Indicies +Search Indices --------------- Based on your search backend i.e Elasticsearch or Meilisearch, the commands will populate search indexes. diff --git a/forum/api/commentables.py b/forum/api/commentables.py index 8161367c..6cec1db2 100644 --- a/forum/api/commentables.py +++ b/forum/api/commentables.py @@ -16,7 +16,7 @@ def get_commentables_stats(course_id: str) -> dict[str, int]: Response: The threads count for the given course_id based on thread_type. e.g. - reponse = {'course': {'discussion': 1, 'question': 1}} + response = {'course': {'discussion': 1, 'question': 1}} """ backend = get_backend(course_id)() return backend.get_commentables_counts_based_on_type(course_id) diff --git a/forum/backends/mysql/api.py b/forum/backends/mysql/api.py index b115119b..3311bdd6 100644 --- a/forum/backends/mysql/api.py +++ b/forum/backends/mysql/api.py @@ -984,13 +984,13 @@ def validate_object(model: str, obj_id: str) -> Any: raise exception if object does not exists. return object """ - modelss = { + models = { "CommentThread": CommentThread, "Comment": Comment, } try: - instance = modelss[model].objects.get(pk=int(obj_id)) + instance = models[model].objects.get(pk=int(obj_id)) except ObjectDoesNotExist as exc: raise ObjectDoesNotExist from exc diff --git a/forum/management/commands/forum_create_mongodb_indexes.py b/forum/management/commands/forum_create_mongodb_indexes.py index efa28814..b8195248 100644 --- a/forum/management/commands/forum_create_mongodb_indexes.py +++ b/forum/management/commands/forum_create_mongodb_indexes.py @@ -20,5 +20,5 @@ def handle(self, *args: list[str], **kwargs: dict[str, str]) -> None: """ BaseContents().create_indexes() self.stdout.write( - self.style.SUCCESS("Created/Updated Mongodb indexes successfuly.") + self.style.SUCCESS("Created/Updated Mongodb indexes successfully.") ) diff --git a/forum/utils.py b/forum/utils.py index 15778672..1fa0d8e4 100644 --- a/forum/utils.py +++ b/forum/utils.py @@ -93,7 +93,7 @@ def get_str_value_from_collection(collection: dict[str, Any], key: str) -> str: try: value = str(collection[key]) except (TypeError, ValueError, KeyError) as exception: - raise ValueError("Invalud Value") from exception + raise ValueError("Invalid Value") from exception return value diff --git a/forum/views/subscriptions.py b/forum/views/subscriptions.py index 629aa4a9..23e1668e 100644 --- a/forum/views/subscriptions.py +++ b/forum/views/subscriptions.py @@ -43,10 +43,10 @@ def post(self, request: Request, user_id: str) -> Response: """ request_data = request.data try: - serilized_data = create_subscription(user_id, request_data["source_id"]) + serialized_data = create_subscription(user_id, request_data["source_id"]) except ForumV2RequestError as e: return Response(data={"error": str(e)}, status=status.HTTP_400_BAD_REQUEST) - return Response(data=serilized_data, status=status.HTTP_200_OK) + return Response(data=serialized_data, status=status.HTTP_200_OK) def delete(self, request: Request, user_id: str) -> Response: """ @@ -64,10 +64,10 @@ def delete(self, request: Request, user_id: str) -> Response: """ try: params = request.query_params - serilized_data = delete_subscription(user_id, params["source_id"]) + serialized_data = delete_subscription(user_id, params["source_id"]) except ForumV2RequestError as e: return Response(data={"error": str(e)}, status=status.HTTP_400_BAD_REQUEST) - return Response(data=serilized_data, status=status.HTTP_200_OK) + return Response(data=serialized_data, status=status.HTTP_200_OK) class UserSubscriptionAPIView(APIView): @@ -96,14 +96,12 @@ def get(self, request: Request, user_id: str) -> Response: params: dict[str, Any] = request.GET.dict() course_id = params.pop("course_id") try: - serilized_data = get_user_subscriptions( - user_id, - course_id, - **params, + serialized_data = get_user_subscriptions( + user_id, params["course_id"], params ) except ForumV2RequestError as e: return Response(data={"error": str(e)}, status=status.HTTP_400_BAD_REQUEST) - return Response(data=serilized_data, status=status.HTTP_200_OK) + return Response(data=serialized_data, status=status.HTTP_200_OK) class ThreadSubscriptionAPIView(APIView): diff --git a/tests/e2e/test_search_es.py b/tests/e2e/test_search_es.py index f1265663..3221e8a9 100644 --- a/tests/e2e/test_search_es.py +++ b/tests/e2e/test_search_es.py @@ -741,7 +741,7 @@ def test_spelling_correction_with_mush_clause( ) -> None: """ Test the spelling correction feature & mush clause in the search. - Verifies the even if the text matches with the threds it should also consider other + Verifies the even if the text matches with the threads it should also consider other params in the search i.e course_id """ backend = patched_get_backend() diff --git a/tests/test_views/test_search.py b/tests/test_views/test_search.py index af0eb9d9..5d46a12f 100644 --- a/tests/test_views/test_search.py +++ b/tests/test_views/test_search.py @@ -693,7 +693,7 @@ def test_spelling_correction_with_mush_clause( ) -> None: """ Test the spelling correction feature & mush clause in the search. - Verifies the even if the text matches with the threds it should also consider other + Verifies the even if the text matches with the threads it should also consider other params in the search i.e course_id """ backend = patched_get_backend() diff --git a/tests/test_views/test_threads.py b/tests/test_views/test_threads.py index ca28d864..23e09f35 100644 --- a/tests/test_views/test_threads.py +++ b/tests/test_views/test_threads.py @@ -74,7 +74,7 @@ def create_comments_in_a_thread(backend: Any, thread_id: str) -> tuple[str, str] def test_update_thread(api_client: APIClient, patched_get_backend: Any) -> None: - """Test updaing a thread.""" + """Test updating a thread.""" backend = patched_get_backend user_id, thread_id = setup_models(backend=backend) response = api_client.put_json(