Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)://<LMS_HOST>/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"
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion forum/api/commentables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions forum/backends/mysql/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion forum/management/commands/forum_create_mongodb_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
)
2 changes: 1 addition & 1 deletion forum/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
16 changes: 7 additions & 9 deletions forum/views/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_search_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views/test_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading