From 13b4408a974400d8882739de1dc6e18559b97cca Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 19:48:56 +0100 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=9A=A8(backend)=20fix=20CheckConstrai?= =?UTF-8?q?nt=20deprecation=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a deprecation warning from Django, which appears while running tests. 'check' argument is replaced by 'condition'. --- src/backend/core/migrations/0001_initial.py | 4 ++-- src/backend/core/models.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/core/migrations/0001_initial.py b/src/backend/core/migrations/0001_initial.py index 38bdb4f3e..053d632d0 100644 --- a/src/backend/core/migrations/0001_initial.py +++ b/src/backend/core/migrations/0001_initial.py @@ -145,7 +145,7 @@ class Migration(migrations.Migration): ), migrations.AddConstraint( model_name='documentaccess', - constraint=models.CheckConstraint(check=models.Q(models.Q(('team', ''), ('user__isnull', False)), models.Q(('team__gt', ''), ('user__isnull', True)), _connector='OR'), name='check_document_access_either_user_or_team', violation_error_message='Either user or team must be set, not both.'), + constraint=models.CheckConstraint(condition=models.Q(models.Q(('team', ''), ('user__isnull', False)), models.Q(('team__gt', ''), ('user__isnull', True)), _connector='OR'), name='check_document_access_either_user_or_team', violation_error_message='Either user or team must be set, not both.'), ), migrations.AddConstraint( model_name='invitation', @@ -161,6 +161,6 @@ class Migration(migrations.Migration): ), migrations.AddConstraint( model_name='templateaccess', - constraint=models.CheckConstraint(check=models.Q(models.Q(('team', ''), ('user__isnull', False)), models.Q(('team__gt', ''), ('user__isnull', True)), _connector='OR'), name='check_template_access_either_user_or_team', violation_error_message='Either user or team must be set, not both.'), + constraint=models.CheckConstraint(condition=models.Q(models.Q(('team', ''), ('user__isnull', False)), models.Q(('team__gt', ''), ('user__isnull', True)), _connector='OR'), name='check_template_access_either_user_or_team', violation_error_message='Either user or team must be set, not both.'), ), ] diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 3bc9f2e0b..24aee88f1 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -695,7 +695,7 @@ class Meta: violation_error_message=_("This team is already in this document."), ), models.CheckConstraint( - check=models.Q(user__isnull=False, team="") + condition=models.Q(user__isnull=False, team="") | models.Q(user__isnull=True, team__gt=""), name="check_document_access_either_user_or_team", violation_error_message=_("Either user or team must be set, not both."), @@ -884,7 +884,7 @@ class Meta: violation_error_message=_("This team is already in this template."), ), models.CheckConstraint( - check=models.Q(user__isnull=False, team="") + condition=models.Q(user__isnull=False, team="") | models.Q(user__isnull=True, team__gt=""), name="check_template_access_either_user_or_team", violation_error_message=_("Either user or team must be set, not both."), From 543c0d2487da55d0b69f192d6d82097db20291be Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 19:52:21 +0100 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=9A=A8(backend)=20fix=20Django=20depr?= =?UTF-8?q?ecation=20warning=20in=20Factory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _after_postgeneration method will stop saving the instance after postgeneration hooks in the next major release. Solved using Claude, feel free to challenge my fix. --- src/backend/core/factories.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/core/factories.py b/src/backend/core/factories.py index f1ce85909..d37a9265f 100644 --- a/src/backend/core/factories.py +++ b/src/backend/core/factories.py @@ -19,6 +19,7 @@ class UserFactory(factory.django.DjangoModelFactory): class Meta: model = models.User + skip_postgeneration_save = True sub = factory.Sequence(lambda n: f"user{n!s}") email = factory.Faker("email") @@ -36,6 +37,8 @@ def with_owned_document(self, create, extracted, **kwargs): if create and (extracted is True): UserDocumentAccessFactory(user=self, role="owner") + self.save() + @factory.post_generation def with_owned_template(self, create, extracted, **kwargs): """ @@ -45,6 +48,8 @@ def with_owned_template(self, create, extracted, **kwargs): if create and (extracted is True): UserTemplateAccessFactory(user=self, role="owner") + self.save() + class DocumentFactory(factory.django.DjangoModelFactory): """A factory to create documents""" From 9d1412124803eda080f4d1d62fb4be6025a26618 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 20:00:47 +0100 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=9A=A8(backend)=20fix=20Django=20Unor?= =?UTF-8?q?deredObjectListWarning=20on=20User?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found this solution googling on Stack Overflow. Without a default ordering on a model, Django raises a warning, that pagination may yield inconsistent results. Please feel free to challenge my fix. --- src/backend/core/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 24aee88f1..99c638986 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -199,6 +199,7 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin): class Meta: db_table = "impress_user" + ordering = ("-created_at",) verbose_name = _("user") verbose_name_plural = _("users") From e3c88431990c19178292ceeb1d1213f5f8f85fc4 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 20:09:46 +0100 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=9A=A8(backend)=20fix=20Django=20depr?= =?UTF-8?q?ecation=20warning=20for=20format=5Fhtml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolved RemovedInDjango60Warning by ensuring format_html() is called with required arguments, addressing compatibility with Django 6.0. /!\ Fix by
Claude, need real-world testing. Linterand tests pass. --- src/backend/core/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 99c638986..63f46ebbe 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -761,7 +761,7 @@ def generate_pdf(self, body_html, metadata): """ document_html = weasyprint.HTML( string=DjangoTemplate(self.code).render( - Context({"body": html.format_html(body_html), **metadata}) + Context({"body": html.format_html("{}", body_html), **metadata}) ) ) css = weasyprint.CSS( @@ -780,7 +780,7 @@ def generate_word(self, body_html, metadata): Generate and return a docx document wrapped around the current template """ template_string = DjangoTemplate(self.code).render( - Context({"body": html.format_html(body_html), **metadata}) + Context({"body": html.format_html("{}", body_html), **metadata}) ) html_string = f""" From d48d160b19a3bb39364ee23c467a2fce5991091d Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 20:11:21 +0100 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=8E=A8(backend)=20remove=20unused=20v?= =?UTF-8?q?ariable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit output seems to be redefined few lines after. Please feel free to challenge this change. --- src/backend/core/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 63f46ebbe..ccd22da1e 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -798,7 +798,6 @@ def generate_word(self, body_html, metadata): """ reference_docx = "core/static/reference.docx" - output = BytesIO() # Convert the HTML to a temporary docx file with tempfile.NamedTemporaryFile(suffix=".docx", prefix="docx_") as tmp_file: From a1101115509b682f9b353d0425fe92b726a78654 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 20:12:19 +0100 Subject: [PATCH 6/9] =?UTF-8?q?=E2=9C=8F=EF=B8=8F(typo)=20fix=20minor=20ty?= =?UTF-8?q?pos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found typos while working on the project using my IDE, fixed them. Sorry for the big commit. Not a big deal, can totally drop this commit. --- CHANGELOG.md | 4 ++-- docs/release.md | 2 +- src/backend/core/api/utils.py | 2 +- src/backend/core/api/viewsets.py | 16 ++++++++-------- src/backend/core/authentication/urls.py | 4 ++-- src/backend/core/models.py | 2 +- .../core/services/collaboration_services.py | 2 +- .../core/tests/authentication/test_backends.py | 2 +- .../documents/test_api_document_accesses.py | 2 +- .../documents/test_api_document_versions.py | 2 +- .../documents/test_api_documents_ai_transform.py | 2 +- .../documents/test_api_documents_ai_translate.py | 2 +- .../test_api_documents_attachment_upload.py | 4 ++-- .../documents/test_api_documents_media_auth.py | 2 +- .../templates/test_api_template_accesses.py | 2 +- src/backend/core/tests/test_models_documents.py | 8 ++++---- src/backend/core/tests/test_models_users.py | 4 ++-- .../core/tests/test_services_ai_services.py | 2 +- .../e2e/__tests__/app-impress/doc-editor.spec.ts | 2 +- .../app-impress/doc-table-content.spec.ts | 2 +- .../__tests__/app-impress/doc-visibility.spec.ts | 8 ++++---- .../impress/src/api/__tests__/fetchApi.test.tsx | 2 +- src/frontend/apps/impress/src/core/auth/Auth.tsx | 2 +- .../apps/impress/src/core/auth/useAuthStore.tsx | 4 ++-- .../features/docs/doc-editor/hook/useSaveDoc.tsx | 2 +- .../docs/doc-header/components/DocTitle.tsx | 2 +- .../src/features/docs/doc-header/utils.ts | 2 +- .../docs/doc-management/api/useUpdateDoc.tsx | 6 +++--- .../docs/doc-management/api/useUpdateDocLink.tsx | 6 +++--- .../doc-management/components/DocVisibility.tsx | 2 +- .../doc-table-content/components/Heading.tsx | 2 +- .../components/TableContent.tsx | 4 ++-- .../doc-versioning/components/ModalVersion.tsx | 2 +- .../src/features/service-worker/ApiPlugin.ts | 2 +- .../src/features/service-worker/DocsDB.ts | 2 +- 35 files changed, 58 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42509d5c5..b90a67a05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,7 +165,7 @@ and this project adheres to - 🛂(frontend) match email if no existing user matches the sub - 🐛(backend) gitlab oicd userinfo endpoint #232 -- 🛂(frontend) redirect to the OIDC when private doc and unauthentified #292 +- 🛂(frontend) redirect to the OIDC when private doc and unauthenticated #292 - ♻️(backend) getting list of document versions available for a user #258 - 🔧(backend) fix configuration to avoid different ssl warning #297 - 🐛(frontend) fix editor break line not working #302 @@ -294,7 +294,7 @@ and this project adheres to - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) -- ✏️(frontend) change all occurences of pad to doc (#99) +- ✏️(frontend) change all occurrences of pad to doc (#99) ## Fixed diff --git a/docs/release.md b/docs/release.md index 2364c10aa..10b442cb0 100644 --- a/docs/release.md +++ b/docs/release.md @@ -6,7 +6,7 @@ Whenever we are cooking a new release (e.g. `4.18.1`) we should follow a standar 2. Bump the release number for backend project, frontend projects, and Helm files: - for backend, update the version number by hand in `pyproject.toml`, - - for each projects (`src/frontend`, `src/frontend/apps/*`, `src/frontend/packages/*`, `src/mail`), run `yarn version --new-version --no-git-tag-version 4.18.1` in their directory. This will update their `package.json` for you, + - for each project (`src/frontend`, `src/frontend/apps/*`, `src/frontend/packages/*`, `src/mail`), run `yarn version --new-version --no-git-tag-version 4.18.1` in their directory. This will update their `package.json` for you, - for Helm, update Docker image tag in files located at `src/helm/env.d` for both `preprod` and `production` environments: ```yaml diff --git a/src/backend/core/api/utils.py b/src/backend/core/api/utils.py index 53ca09ebe..fd711bae8 100644 --- a/src/backend/core/api/utils.py +++ b/src/backend/core/api/utils.py @@ -13,7 +13,7 @@ def generate_s3_authorization_headers(key): """ - Generate authorization headers for an s3 object. + Generate authorization headers for a s3 object. These headers can be used as an alternative to signed urls with many benefits: - the urls of our files never expire and can be stored in our documents' content - we don't leak authorized urls that could be shared (file access can only be done diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py index b217194d9..e306b1bf3 100644 --- a/src/backend/core/api/viewsets.py +++ b/src/backend/core/api/viewsets.py @@ -621,7 +621,7 @@ def attachment_upload(self, request, *args, **kwargs): def _authorize_subrequest(self, request, pattern): """ - Shared method to authorize access based on the original URL of an Nginx subrequest + Shared method to authorize access based on the original URL of a Nginx subrequest and user permissions. Returns a dictionary of URL parameters if authorized. The original url is passed by nginx in the "HTTP_X_ORIGINAL_URL" header. @@ -629,7 +629,7 @@ def _authorize_subrequest(self, request, pattern): nginx.ingress.kubernetes.io/auth-url annotation to understand how the Nginx ingress is configured to do this. - Based on the original url and the logged in user, we must decide if we authorize Nginx + Based on the original url and the logged-in user, we must decide if we authorize Nginx to let this request go through (by returning a 200 code) or if we block it (by returning a 403 error). Note that we return 403 errors without any further details for security reasons. @@ -697,7 +697,7 @@ def _authorize_subrequest(self, request, pattern): @drf.decorators.action(detail=False, methods=["get"], url_path="media-auth") def media_auth(self, request, *args, **kwargs): """ - This view is used by an Nginx subrequest to control access to a document's + This view is used by a Nginx subrequest to control access to a document's attachment file. When we let the request go through, we compute authorization headers that will be added to @@ -718,7 +718,7 @@ def media_auth(self, request, *args, **kwargs): @drf.decorators.action(detail=False, methods=["get"], url_path="collaboration-auth") def collaboration_auth(self, request, *args, **kwargs): """ - This view is used by an Nginx subrequest to control access to a document's + This view is used by a Nginx subrequest to control access to a document's collaboration server. """ _, user_abilities, user_id = self._authorize_subrequest( @@ -834,7 +834,7 @@ class DocumentAccessViewSet( serializer_class = serializers.DocumentAccessSerializer def perform_create(self, serializer): - """Add a new access to the document and send an email to the new added user.""" + """Add new access to the document and email the new added user.""" access = serializer.save() language = self.request.headers.get("Content-Language", "en-us") @@ -846,7 +846,7 @@ def perform_create(self, serializer): ) def perform_update(self, serializer): - """Update an access to the document and notify the collaboration server.""" + """Update access to the document and notify the collaboration server.""" access = serializer.save() access_user_id = None @@ -859,7 +859,7 @@ def perform_update(self, serializer): ) def perform_destroy(self, instance): - """Delete an access to the document and notify the collaboration server.""" + """Delete access to the document and notify the collaboration server.""" instance.delete() # Notify collaboration server about the access removed @@ -1098,7 +1098,7 @@ def get_queryset(self): return queryset def perform_create(self, serializer): - """Save invitation to a document then send an email to the invited user.""" + """Save invitation to a document then email the invited user.""" invitation = serializer.save() language = self.request.headers.get("Content-Language", "en-us") diff --git a/src/backend/core/authentication/urls.py b/src/backend/core/authentication/urls.py index 2a66c83d8..a8b44cf98 100644 --- a/src/backend/core/authentication/urls.py +++ b/src/backend/core/authentication/urls.py @@ -2,7 +2,7 @@ from django.urls import path -from mozilla_django_oidc.urls import urlpatterns as mozzila_oidc_urls +from mozilla_django_oidc.urls import urlpatterns as mozilla_oidc_urls from .views import OIDCLogoutCallbackView, OIDCLogoutView @@ -14,5 +14,5 @@ OIDCLogoutCallbackView.as_view(), name="oidc_logout_callback", ), - *mozzila_oidc_urls, + *mozilla_oidc_urls, ] diff --git a/src/backend/core/models.py b/src/backend/core/models.py index ccd22da1e..580c8b087 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -155,7 +155,7 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin): email = models.EmailField(_("identity email address"), blank=True, null=True) # Unlike the "email" field which stores the email coming from the OIDC token, this field - # stores the email used by staff users to login to the admin site + # stores the email used by staff users to log in to the admin site admin_email = models.EmailField( _("admin email address"), unique=True, blank=True, null=True ) diff --git a/src/backend/core/services/collaboration_services.py b/src/backend/core/services/collaboration_services.py index 283a87428..dac16fa6d 100644 --- a/src/backend/core/services/collaboration_services.py +++ b/src/backend/core/services/collaboration_services.py @@ -17,7 +17,7 @@ def __init__(self): def reset_connections(self, room, user_id=None): """ Reset connections of a room in the collaboration server. - Reseting a connection means that the user will be disconnected and will + Resetting a connection means that the user will be disconnected and will have to reconnect to the collaboration server, with updated rights. """ endpoint = "reset-connections" diff --git a/src/backend/core/tests/authentication/test_backends.py b/src/backend/core/tests/authentication/test_backends.py index 8bf8b9f2d..d3722873c 100644 --- a/src/backend/core/tests/authentication/test_backends.py +++ b/src/backend/core/tests/authentication/test_backends.py @@ -341,7 +341,7 @@ def test_authentication_getter_existing_disabled_user_via_email( django_assert_num_queries, monkeypatch ): """ - If an existing user does not matches the sub but matches the email and is disabled, + If an existing user does not match the sub but matches the email and is disabled, an error should be raised and a user should not be created. """ diff --git a/src/backend/core/tests/documents/test_api_document_accesses.py b/src/backend/core/tests/documents/test_api_document_accesses.py index 5b1ea2835..5b1c91793 100644 --- a/src/backend/core/tests/documents/test_api_document_accesses.py +++ b/src/backend/core/tests/documents/test_api_document_accesses.py @@ -698,7 +698,7 @@ def test_api_document_accesses_delete_administrators_except_owners( mock_reset_connections, # pylint: disable=redefined-outer-name ): """ - Users who are administrators in a document should be allowed to delete an access + Users who are administrators in a document should be allowed to delete access from the document provided it is not ownership. """ user = factories.UserFactory() diff --git a/src/backend/core/tests/documents/test_api_document_versions.py b/src/backend/core/tests/documents/test_api_document_versions.py index e91012b29..c5adcbdc7 100644 --- a/src/backend/core/tests/documents/test_api_document_versions.py +++ b/src/backend/core/tests/documents/test_api_document_versions.py @@ -285,7 +285,7 @@ def test_api_document_versions_retrieve_authenticated_related(via, mock_user_tea assert response.status_code == 404 # Create a new version should not make it available to the user because - # only the current version is available to the user but it is excluded + # only the current version is available to the user, but it is excluded # from the list document.content = "new content 1" document.save() diff --git a/src/backend/core/tests/documents/test_api_documents_ai_transform.py b/src/backend/core/tests/documents/test_api_documents_ai_transform.py index 91e16e4a5..7d55cf47e 100644 --- a/src/backend/core/tests/documents/test_api_documents_ai_transform.py +++ b/src/backend/core/tests/documents/test_api_documents_ai_transform.py @@ -134,7 +134,7 @@ def test_api_documents_ai_transform_authenticated_forbidden(reach, role): @patch("openai.resources.chat.completions.Completions.create") def test_api_documents_ai_transform_authenticated_success(mock_create, reach, role): """ - Autenticated who are not related to a document should be able to request AI transform + Authenticated who are not related to a document should be able to request AI transform if the link reach and role permit it. """ user = factories.UserFactory() diff --git a/src/backend/core/tests/documents/test_api_documents_ai_translate.py b/src/backend/core/tests/documents/test_api_documents_ai_translate.py index 21547e7aa..1b81762de 100644 --- a/src/backend/core/tests/documents/test_api_documents_ai_translate.py +++ b/src/backend/core/tests/documents/test_api_documents_ai_translate.py @@ -154,7 +154,7 @@ def test_api_documents_ai_translate_authenticated_forbidden(reach, role): @patch("openai.resources.chat.completions.Completions.create") def test_api_documents_ai_translate_authenticated_success(mock_create, reach, role): """ - Autenticated who are not related to a document should be able to request AI translate + Authenticated who are not related to a document should be able to request AI translate if the link reach and role permit it. """ user = factories.UserFactory() diff --git a/src/backend/core/tests/documents/test_api_documents_attachment_upload.py b/src/backend/core/tests/documents/test_api_documents_attachment_upload.py index 1288f8ca6..fb9c7c391 100644 --- a/src/backend/core/tests/documents/test_api_documents_attachment_upload.py +++ b/src/backend/core/tests/documents/test_api_documents_attachment_upload.py @@ -111,7 +111,7 @@ def test_api_documents_attachment_upload_authenticated_forbidden(reach, role): ) def test_api_documents_attachment_upload_authenticated_success(reach, role): """ - Autenticated who are not related to a document should be able to upload a file + Authenticated who are not related to a document should be able to upload a file if the link reach and role permit it. """ user = factories.UserFactory() @@ -225,7 +225,7 @@ def test_api_documents_attachment_upload_invalid(client): def test_api_documents_attachment_upload_size_limit_exceeded(settings): - """The uploaded file should not exceeed the maximum size in settings.""" + """The uploaded file should not exceed the maximum size in settings.""" settings.DOCUMENT_IMAGE_MAX_SIZE = 1048576 # 1 MB for test user = factories.UserFactory() diff --git a/src/backend/core/tests/documents/test_api_documents_media_auth.py b/src/backend/core/tests/documents/test_api_documents_media_auth.py index 28fd370c0..e87df9a81 100644 --- a/src/backend/core/tests/documents/test_api_documents_media_auth.py +++ b/src/backend/core/tests/documents/test_api_documents_media_auth.py @@ -160,7 +160,7 @@ def test_api_documents_media_auth_authenticated_restricted(): @pytest.mark.parametrize("via", VIA) def test_api_documents_media_auth_related(via, mock_user_teams): """ - Users who have a specific access to a document, whatever the role, should be able to + Users who have specific access to a document, whatever the role, should be able to retrieve related attachments. """ user = factories.UserFactory() diff --git a/src/backend/core/tests/templates/test_api_template_accesses.py b/src/backend/core/tests/templates/test_api_template_accesses.py index cd08abfbf..6325522ab 100644 --- a/src/backend/core/tests/templates/test_api_template_accesses.py +++ b/src/backend/core/tests/templates/test_api_template_accesses.py @@ -647,7 +647,7 @@ def test_api_template_accesses_delete_administrators_except_owners( via, mock_user_teams ): """ - Users who are administrators in a template should be allowed to delete an access + Users who are administrators in a template should be allowed to delete access from the template provided it is not ownership. """ user = factories.UserFactory() diff --git a/src/backend/core/tests/test_models_documents.py b/src/backend/core/tests/test_models_documents.py index 5fe0d4fda..7c5b33835 100644 --- a/src/backend/core/tests/test_models_documents.py +++ b/src/backend/core/tests/test_models_documents.py @@ -84,7 +84,7 @@ def test_models_documents_file_key(): def test_models_documents_get_abilities_forbidden(is_authenticated, reach, role): """ Check abilities returned for a document giving insufficient roles to link holders - i.e anonymous users or authenticated users who have no specific role on the document. + i.e. anonymous users or authenticated users who have no specific role on the document. """ document = factories.DocumentFactory(link_reach=reach, link_role=role) user = factories.UserFactory() if is_authenticated else AnonymousUser() @@ -121,7 +121,7 @@ def test_models_documents_get_abilities_forbidden(is_authenticated, reach, role) def test_models_documents_get_abilities_reader(is_authenticated, reach): """ Check abilities returned for a document giving reader role to link holders - i.e anonymous users or authenticated users who have no specific role on the document. + i.e. anonymous users or authenticated users who have no specific role on the document. """ document = factories.DocumentFactory(link_reach=reach, link_role="reader") user = factories.UserFactory() if is_authenticated else AnonymousUser() @@ -158,7 +158,7 @@ def test_models_documents_get_abilities_reader(is_authenticated, reach): def test_models_documents_get_abilities_editor(is_authenticated, reach): """ Check abilities returned for a document giving editor role to link holders - i.e anonymous users or authenticated users who have no specific role on the document. + i.e. anonymous users or authenticated users who have no specific role on the document. """ document = factories.DocumentFactory(link_reach=reach, link_role="editor") user = factories.UserFactory() if is_authenticated else AnonymousUser() @@ -449,7 +449,7 @@ def test_models_documents__email_invitation__success(): def test_models_documents__email_invitation__success_fr(): """ - The email invitation is sent successfully in french. + The email invitation is sent successfully in French. """ document = factories.DocumentFactory() diff --git a/src/backend/core/tests/test_models_users.py b/src/backend/core/tests/test_models_users.py index edea5bb9f..cd30f22ac 100644 --- a/src/backend/core/tests/test_models_users.py +++ b/src/backend/core/tests/test_models_users.py @@ -27,7 +27,7 @@ def test_models_users_id_unique(): def test_models_users_send_mail_main_existing(): - """The "email_user' method should send mail to the user's email address.""" + """The 'email_user' method should send mail to the user's email address.""" user = factories.UserFactory() with mock.patch("django.core.mail.send_mail") as mock_send: @@ -37,7 +37,7 @@ def test_models_users_send_mail_main_existing(): def test_models_users_send_mail_main_missing(): - """The "email_user' method should fail if the user has no email address.""" + """The 'email_user' method should fail if the user has no email address.""" user = factories.UserFactory(email=None) with pytest.raises(ValueError) as excinfo: diff --git a/src/backend/core/tests/test_services_ai_services.py b/src/backend/core/tests/test_services_ai_services.py index c1620b2a6..32ebabeba 100644 --- a/src/backend/core/tests/test_services_ai_services.py +++ b/src/backend/core/tests/test_services_ai_services.py @@ -1,5 +1,5 @@ """ -Test ai API endpoints in the impress core app. +Test AI API endpoints in the impress core app. """ import json diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts index 221b08005..13592afb8 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts @@ -120,7 +120,7 @@ test.describe('Doc Editor', () => { name: 'Visibility', }); - // When the visibility is changed, the ws should closed the connection (backend signal) + // When the visibility is changed, the ws should close the connection (backend signal) const wsClosePromise = webSocket.waitForEvent('close'); await selectVisibility.click(); diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-table-content.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-table-content.spec.ts index 55c4a932e..48e458834 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-table-content.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-table-content.spec.ts @@ -96,7 +96,7 @@ test.describe('Doc Table Content', () => { await expect(superW).toHaveAttribute('aria-selected', 'true'); }); - test('it checks that table contents panel is opened automaticaly if more that 2 headings', async ({ + test('it checks that table contents panel is opened automatically if more that 2 headings', async ({ page, browserName, }) => { diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts index ede359b6c..9d45f27c1 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts @@ -71,7 +71,7 @@ test.describe('Doc Visibility', () => { test.describe('Doc Visibility: Restricted', () => { test.use({ storageState: { cookies: [], origins: [] } }); - test('A doc is not accessible when not authentified.', async ({ + test('A doc is not accessible when not authenticated.', async ({ page, browserName, }) => { @@ -102,7 +102,7 @@ test.describe('Doc Visibility: Restricted', () => { await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible(); }); - test('A doc is not accessible when authentified but not member.', async ({ + test('A doc is not accessible when authenticated but not member.', async ({ page, browserName, }) => { @@ -319,7 +319,7 @@ test.describe('Doc Visibility: Public', () => { test.describe('Doc Visibility: Authenticated', () => { test.use({ storageState: { cookies: [], origins: [] } }); - test('A doc is not accessible when unauthentified.', async ({ + test('A doc is not accessible when unauthenticated.', async ({ page, browserName, }) => { @@ -328,7 +328,7 @@ test.describe('Doc Visibility: Authenticated', () => { const [docTitle] = await createDoc( page, - 'Authenticated unauthentified', + 'Authenticated unauthenticated', browserName, 1, ); diff --git a/src/frontend/apps/impress/src/api/__tests__/fetchApi.test.tsx b/src/frontend/apps/impress/src/api/__tests__/fetchApi.test.tsx index 05dc0b130..d89eb3a5b 100644 --- a/src/frontend/apps/impress/src/api/__tests__/fetchApi.test.tsx +++ b/src/frontend/apps/impress/src/api/__tests__/fetchApi.test.tsx @@ -29,7 +29,7 @@ describe('fetchAPI', () => { }); }); - it('check the versionning', () => { + it('check the versioning', () => { fetchMock.mock('http://test.jest/api/v2.0/some/url', 200); void fetchAPI('some/url', {}, '2.0'); diff --git a/src/frontend/apps/impress/src/core/auth/Auth.tsx b/src/frontend/apps/impress/src/core/auth/Auth.tsx index bcfa6a535..f9e9dfbfa 100644 --- a/src/frontend/apps/impress/src/core/auth/Auth.tsx +++ b/src/frontend/apps/impress/src/core/auth/Auth.tsx @@ -33,7 +33,7 @@ export const Auth = ({ children }: PropsWithChildren) => { setPathAllowed(!regexpUrlsAuth.some((regexp) => !!asPath.match(regexp))); }, [asPath]); - // We force to login except on allowed paths + // We force to log in except on allowed paths useEffect(() => { if (!initiated || authenticated || pathAllowed) { return; diff --git a/src/frontend/apps/impress/src/core/auth/useAuthStore.tsx b/src/frontend/apps/impress/src/core/auth/useAuthStore.tsx index 63e285b27..b13c90a5a 100644 --- a/src/frontend/apps/impress/src/core/auth/useAuthStore.tsx +++ b/src/frontend/apps/impress/src/core/auth/useAuthStore.tsx @@ -46,8 +46,8 @@ export const useAuthStore = create((set, get) => ({ terminateCrispSession(); window.location.replace(`${baseApiUrl()}logout/`); }, - // If we try to access a specific page and we are not authenticated - // we store the path in the local storage to redirect to it after login + // If we try to access a specific page, and we are not authenticated + // we store the path in the local storage to redirect to it after log in setAuthUrl() { if (window.location.pathname !== '/') { localStorage.setItem(PATH_AUTH_LOCAL_STORAGE, window.location.pathname); diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx index ca1ed0054..f8efae93c 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx @@ -10,7 +10,7 @@ import { toBase64 } from '../utils'; const useSaveDoc = (docId: string, doc: Y.Doc, canSave: boolean) => { const { mutate: updateDoc } = useUpdateDoc({ - listInvalideQueries: [KEY_LIST_DOC_VERSIONS], + listInvalidQueries: [KEY_LIST_DOC_VERSIONS], }); const [initialDoc, setInitialDoc] = useState( toBase64(Y.encodeStateAsUpdate(doc)), diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx index 6c6a9dcf9..84221dfdc 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx @@ -57,7 +57,7 @@ const DocTitleInput = ({ doc }: DocTitleProps) => { const { broadcast } = useBroadcastStore(); const { mutate: updateDoc } = useUpdateDoc({ - listInvalideQueries: [KEY_LIST_DOC], + listInvalidQueries: [KEY_LIST_DOC], onSuccess(data) { if (data.title !== untitledDocument) { toast(t('Document title updated successfully'), VariantType.SUCCESS); diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/utils.ts b/src/frontend/apps/impress/src/features/docs/doc-header/utils.ts index de15b30ef..cfd4def69 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/utils.ts +++ b/src/frontend/apps/impress/src/features/docs/doc-header/utils.ts @@ -94,7 +94,7 @@ const convertToImg = (html: string) => { const doc = parser.parseFromString(html, 'text/html'); const divs = doc.querySelectorAll('div[data-content-type="image"]'); - // Loop through each div and replace it with a img + // Loop through each div and replace it with an img divs.forEach((div) => { const img = document.createElement('img'); diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDoc.tsx b/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDoc.tsx index b944f50a5..4b3a60715 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDoc.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDoc.tsx @@ -26,18 +26,18 @@ export const updateDoc = async ({ interface UpdateDocProps { onSuccess?: (data: Doc) => void; - listInvalideQueries?: string[]; + listInvalidQueries?: string[]; } export function useUpdateDoc({ onSuccess, - listInvalideQueries, + listInvalidQueries, }: UpdateDocProps = {}) { const queryClient = useQueryClient(); return useMutation({ mutationFn: updateDoc, onSuccess: (data) => { - listInvalideQueries?.forEach((queryKey) => { + listInvalidQueries?.forEach((queryKey) => { void queryClient.resetQueries({ queryKey: [queryKey], }); diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDocLink.tsx b/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDocLink.tsx index 377820487..f431d7ed3 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDocLink.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-management/api/useUpdateDocLink.tsx @@ -30,12 +30,12 @@ export const updateDocLink = async ({ interface UpdateDocLinkProps { onSuccess?: (data: Doc) => void; - listInvalideQueries?: string[]; + listInvalidQueries?: string[]; } export function useUpdateDocLink({ onSuccess, - listInvalideQueries, + listInvalidQueries, }: UpdateDocLinkProps = {}) { const queryClient = useQueryClient(); const { broadcast } = useBroadcastStore(); @@ -43,7 +43,7 @@ export function useUpdateDocLink({ return useMutation({ mutationFn: updateDocLink, onSuccess: (data, variable) => { - listInvalideQueries?.forEach((queryKey) => { + listInvalidQueries?.forEach((queryKey) => { void queryClient.resetQueries({ queryKey: [queryKey], }); diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/components/DocVisibility.tsx b/src/frontend/apps/impress/src/features/docs/doc-management/components/DocVisibility.tsx index fb0da9497..f5b8ccfa3 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/components/DocVisibility.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-management/components/DocVisibility.tsx @@ -31,7 +31,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { }, ); }, - listInvalideQueries: [KEY_LIST_DOC, KEY_DOC], + listInvalidQueries: [KEY_LIST_DOC, KEY_DOC], }); const transLinkReach = { diff --git a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx index 5e92efa5c..6918fff24 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx @@ -41,7 +41,7 @@ export const Heading = ({ onMouseOver={() => setIsHover(true)} onMouseLeave={() => setIsHover(false)} onClick={() => { - // With mobile the focus open the keyboard and the scroll is not working + // With mobile the focus open the keyboard and the scroll are not working if (!isMobile) { editor.focus(); } diff --git a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx index 559b268b0..f4ef0ab03 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx @@ -86,7 +86,7 @@ export const TableContent = () => { /> { - // With mobile the focus open the keyboard and the scroll is not working + // With mobile the focus open the keyboard and the scroll are not working if (!isMobile) { editor.focus(); } @@ -104,7 +104,7 @@ export const TableContent = () => { { - // With mobile the focus open the keyboard and the scroll is not working + // With mobile the focus open the keyboard and the scroll are not working if (!isMobile) { editor.focus(); } diff --git a/src/frontend/apps/impress/src/features/docs/doc-versioning/components/ModalVersion.tsx b/src/frontend/apps/impress/src/features/docs/doc-versioning/components/ModalVersion.tsx index 8ffba2db3..27006c8c7 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-versioning/components/ModalVersion.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-versioning/components/ModalVersion.tsx @@ -42,7 +42,7 @@ export const ModalVersion = ({ const { push } = useRouter(); const { providers } = useDocStore(); const { mutate: updateDoc } = useUpdateDoc({ - listInvalideQueries: [KEY_LIST_DOC_VERSIONS], + listInvalidQueries: [KEY_LIST_DOC_VERSIONS], onSuccess: () => { const onDisplaySuccess = () => { toast(t('Version restored successfully'), VariantType.SUCCESS); diff --git a/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts b/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts index 2195c00bb..ccd8f85d4 100644 --- a/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts +++ b/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts @@ -112,7 +112,7 @@ export class ApiPlugin implements WorkboxPlugin { }; /** - * When we get an network error. + * When we get a network error. */ handlerDidError: WorkboxPlugin['handlerDidError'] = async ({ request }) => { if (!this.isFetchDidFailed) { diff --git a/src/frontend/apps/impress/src/features/service-worker/DocsDB.ts b/src/frontend/apps/impress/src/features/service-worker/DocsDB.ts index 4d0e85f1a..510ab6bfb 100644 --- a/src/frontend/apps/impress/src/features/service-worker/DocsDB.ts +++ b/src/frontend/apps/impress/src/features/service-worker/DocsDB.ts @@ -34,7 +34,7 @@ interface IDocsDB extends DBSchema { type TableName = 'doc-list' | 'doc-item' | 'doc-mutation'; /** - * IndexDB version must be a integer + * IndexDB version must be an integer * @returns */ const getCurrentVersion = () => { From d18de5bc2000f96efe0f1a2ef55a0f98ffc2d205 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 20:27:29 +0100 Subject: [PATCH 7/9] =?UTF-8?q?=F0=9F=8E=A8(backend)=20remove=20redundant?= =?UTF-8?q?=20parentheses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These parentheses seem useless to me, remove them. --- src/backend/demo/management/commands/createsuperuser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/demo/management/commands/createsuperuser.py b/src/backend/demo/management/commands/createsuperuser.py index 9c5ab786a..d6ddbf6a6 100644 --- a/src/backend/demo/management/commands/createsuperuser.py +++ b/src/backend/demo/management/commands/createsuperuser.py @@ -15,7 +15,7 @@ def add_arguments(self, parser): """Define required arguments "email" and "password".""" parser.add_argument( "--email", - help=("Email for the user."), + help="Email for the user.", ) parser.add_argument( "--password", From 92f95688812bce69568e5d805a123ac94143d267 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 20:27:41 +0100 Subject: [PATCH 8/9] =?UTF-8?q?=F0=9F=8E=A8(backend)=20removed=20unused=20?= =?UTF-8?q?imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Please challenge this commit. I feel these imports aren't used in this migration file. --- src/backend/core/migrations/0001_initial.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backend/core/migrations/0001_initial.py b/src/backend/core/migrations/0001_initial.py index 053d632d0..65d307614 100644 --- a/src/backend/core/migrations/0001_initial.py +++ b/src/backend/core/migrations/0001_initial.py @@ -1,7 +1,5 @@ # Generated by Django 5.0.3 on 2024-05-28 20:29 -import django.contrib.auth.models -import django.core.validators import django.db.models.deletion import timezone_field.fields import uuid From cd820f524d33704df2471264c429c3c8e10ba6d3 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Dec 2024 22:35:48 +0100 Subject: [PATCH 9/9] =?UTF-8?q?=F0=9F=94=A7(backend)=20fix=20sentry=20depr?= =?UTF-8?q?ecated=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `sentry_sdk.configure_scope` is deprecated and will be removed in the next major version. (commit taken from people by @qbey) --- src/backend/impress/settings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index 86be1e558..67e563c25 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -619,8 +619,9 @@ def post_setup(cls): release=get_release(), integrations=[DjangoIntegration()], ) - with sentry_sdk.configure_scope() as scope: - scope.set_extra("application", "backend") + # Add the application name to the Sentry scope + scope = sentry_sdk.get_global_scope() + scope.set_tag("application", "backend") class Build(Base):