diff --git a/.github/workflows/django-translations.yml b/.github/workflows/django-translations.yml index cb0d5502..d56a4d31 100644 --- a/.github/workflows/django-translations.yml +++ b/.github/workflows/django-translations.yml @@ -35,8 +35,8 @@ jobs: - name: Make and compile messages run: | cd backend - django-admin makemessages --all --ignore=env - django-admin compilemessages --ignore=env + django-admin makemessages --all + django-admin compilemessages - name: Commit translation changes uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/backend/authentication/serializers.py b/backend/authentication/serializers.py index 0f92f9a6..01f61fd4 100644 --- a/backend/authentication/serializers.py +++ b/backend/authentication/serializers.py @@ -48,13 +48,13 @@ def validate(self, data): raise auth_serializers.ValidationError( { "email": _( - f"{data['email']} has no entry in the lobby, you must contact an admin to gain access to the platform" - ), + "{data} has no entry in the lobby, you must contact an admin to gain access to the platform" + ).format(email=data["email"]) } ) # check if the verification code is valid if lobby_instance.verification_code != data["verification_code"]: - raise auth_serializers.ValidationError({"verification_code": _(f"invalid verification code")}) + raise auth_serializers.ValidationError({"verification_code": _("invalid verification code")}) # add role to the validated data data["role"] = lobby_instance.role_id # check if passwords match diff --git a/backend/config/secrets.py b/backend/config/secrets.py deleted file mode 100644 index 3fc70165..00000000 --- a/backend/config/secrets.py +++ /dev/null @@ -1,5 +0,0 @@ -# SECURITY WARNING: keep the secret key used in production secret! -DJANGO_SECRET_KEY = 'xfgu-8@@@59y(hl+y+@ypcpm5kqs0!y-v&o&b)@xa(*io52(+g' - -SECRET_EMAIL_USER = 'drtrottoir.host@gmail.com' -SECRET_EMAIL_USER_PSWD = 'mjgpnqvadvuaufnh' \ No newline at end of file diff --git a/backend/config/settings.py b/backend/config/settings.py index 6c7e3c84..5b45b98b 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -87,7 +87,7 @@ SPECTACULAR_SETTINGS = { "TITLE": "Dr-Trottoir API", "DESCRIPTION": "This is the documentation for the Dr-Trottoir API. You can access this API directly by using port " - "2002.", + "2002.", "VERSION": "1.0.0", "SERVE_INCLUDE_SCHEMA": False, # OTHER SETTINGS @@ -139,13 +139,13 @@ "config.middleware.CommonMiddlewareAppendSlashWithoutRedirect", "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", + "language.DefaultLanguageMiddleware", + "django.middleware.locale.LocaleMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", - # "django.middleware.clickjacking.XFrameOptionsMiddleware", "csp.middleware.CSPMiddleware", - "django.middleware.locale.LocaleMiddleware", ] LOCALE_PATHS = [ diff --git a/backend/locale/en/LC_MESSAGES/django.po b/backend/locale/en/LC_MESSAGES/django.po index 410317e1..d11a011c 100644 --- a/backend/locale/en/LC_MESSAGES/django.po +++ b/backend/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-19 22:50+0000\n" +"POT-Creation-Date: 2023-05-20 13:56+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,9 +23,10 @@ msgid "a user is already registered with this e-mail address" msgstr "" #: authentication/serializers.py:51 +#, python-brace-format msgid "" -"{data['email']} has no entry in the lobby, you must contact an admin to gain " -"access to the platform" +"{data} has no entry in the lobby, you must contact an admin to gain access " +"to the platform" msgstr "" #: authentication/serializers.py:57 diff --git a/backend/locale/nl/LC_MESSAGES/django.mo b/backend/locale/nl/LC_MESSAGES/django.mo index 8ca635c8..2408089b 100644 Binary files a/backend/locale/nl/LC_MESSAGES/django.mo and b/backend/locale/nl/LC_MESSAGES/django.mo differ diff --git a/backend/locale/nl/LC_MESSAGES/django.po b/backend/locale/nl/LC_MESSAGES/django.po index 35dd5748..b96906a1 100644 --- a/backend/locale/nl/LC_MESSAGES/django.po +++ b/backend/locale/nl/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-19 22:50+0000\n" +"POT-Creation-Date: 2023-05-20 13:56+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,12 +23,13 @@ msgid "a user is already registered with this e-mail address" msgstr "een gebruiker is al geregistreerd met dit e-mailadres" #: authentication/serializers.py:51 +#, python-brace-format msgid "" -"{data['email']} has no entry in the lobby, you must contact an admin to gain " -"access to the platform" +"{data} has no entry in the lobby, you must contact an admin to gain access " +"to the platform" msgstr "" -"{data['email']} zit niet in de lobby, u moet contact opnemen met een " -"beheerder om toegang te krijgen tot het platform" +"{data} zit niet in de lobby, u moet contact opnemen met een beheerder om " +"toegang te krijgen tot het platform" #: authentication/serializers.py:57 msgid "invalid verification code" @@ -406,125 +407,3 @@ msgid "" msgstr "" "de startdatum van de periode waarnaar je wilt kopiëren moet, op zijn minst, " "in de week direct volgend na de einddatum van de originele periode liggen" - -#~ msgid "Enter a valid value." -#~ msgstr "Vul een geldige waarde in" - -#~ msgid "Enter a valid URL." -#~ msgstr "Vul een geldige URL in" - -#~ msgid "Enter a valid integer." -#~ msgstr "Vul een geldig getal in" - -#~ msgid "Enter a valid email address." -#~ msgstr "Vul een geldig e-mailadres in" - -#, fuzzy -#~| msgid "Enter a valid email address." -#~ msgid "Enter a valid IPv4 address." -#~ msgstr "Vul een geldig e-mailadres in" - -#, fuzzy -#~| msgid "Enter a valid email address." -#~ msgid "Enter a valid IPv6 address." -#~ msgstr "Vul een geldig e-mailadres in" - -#, fuzzy -#~| msgid "Enter a valid email address." -#~ msgid "Enter a valid IPv4 or IPv6 address." -#~ msgstr "Vul een geldig e-mailadres in" - -#~ msgid "Enter a number." -#~ msgstr "Vul een nummer in" - -#, fuzzy, python-format -#~| msgid "A building with this address already exists." -#~ msgid "%(model_name)s with this %(field_labels)s already exists." -#~ msgstr "Er bestaat al een gebouw met dit adres." - -#~ msgid "This field cannot be null." -#~ msgstr "Dit veld mag niet null zijn" - -#~ msgid "This field cannot be blank." -#~ msgstr "dit veld mag niet leeg zijn" - -#, fuzzy, python-format -#~| msgid "The name for this template already exists." -#~ msgid "%(model_name)s with this %(field_label)s already exists." -#~ msgstr "De naam van deze template bestaat al." - -#, fuzzy -#~| msgid "Enter a number." -#~ msgid "Decimal number" -#~ msgstr "Vul een nummer in" - -#, fuzzy -#~| msgid "Enter a valid email address." -#~ msgid "Email address" -#~ msgstr "Vul een geldig e-mailadres in" - -#, fuzzy -#~| msgid "Email is required" -#~ msgid "This field is required." -#~ msgstr "E-mail is vereist" - -#, fuzzy -#~| msgid "Enter a number." -#~ msgid "Enter a whole number." -#~ msgstr "Vul een nummer in" - -#, fuzzy -#~| msgid "Enter a valid value." -#~ msgid "Enter a valid date." -#~ msgstr "Vul een geldige waarde in" - -#, fuzzy -#~| msgid "Enter a valid integer." -#~ msgid "Enter a valid time." -#~ msgstr "Vul een geldig getal in" - -#, fuzzy -#~| msgid "Enter a valid integer." -#~ msgid "Enter a valid date/time." -#~ msgstr "Vul een geldig getal in" - -#, fuzzy -#~| msgid "Enter a valid integer." -#~ msgid "Enter a valid duration." -#~ msgstr "Vul een geldig getal in" - -#, fuzzy -#~| msgid "Enter a valid value." -#~ msgid "Enter a list of values." -#~ msgstr "Vul een geldige waarde in" - -#, fuzzy -#~| msgid "Enter a valid value." -#~ msgid "Enter a complete value." -#~ msgstr "Vul een geldige waarde in" - -#, fuzzy -#~| msgid "Enter a valid URL." -#~ msgid "Enter a valid UUID." -#~ msgstr "Vul een geldige URL in" - -#, fuzzy -#~| msgid "Enter a valid URL." -#~ msgid "Enter a valid JSON." -#~ msgstr "Vul een geldige URL in" - -#, fuzzy, python-format -#~| msgid "Enter a valid value." -#~ msgid "“%(pk)s” is not a valid value." -#~ msgstr "Vul een geldige waarde in" - -#, fuzzy -#~| msgid "Enter a valid email address." -#~ msgid "This is not a valid IPv6 address." -#~ msgstr "Vul een geldig e-mailadres in" - -#~ msgid "No bus" -#~ msgstr "Geen bus" - -#~ msgid "successfully copied the garbage collections" -#~ msgstr "de vuilnisophalingen zijn succesvol gekopieerd" diff --git a/backend/requirements.txt b/backend/requirements.txt index a6096d89..18b87c7d 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -22,6 +22,7 @@ dj-rest-auth==3.0.0 django-allauth==0.54.0 django-cors-headers==4.0.0 django-csp==3.7 +django-default-language==0.0.1 django-nose==1.4.7 django-phonenumber-field==7.1.0 django-random-id-model==0.1.1 diff --git a/backend/util/request_response_util.py b/backend/util/request_response_util.py index 08c5431a..e9b8ede2 100644 --- a/backend/util/request_response_util.py +++ b/backend/util/request_response_util.py @@ -14,10 +14,10 @@ def get_id_param(request, name, required=False): param = request.GET.get(name, None) if param: if not param.isdigit(): - raise BadRequest(_(f"The query parameter {name} should be an integer")) + raise BadRequest(_("The query parameter {name} should be an integer").format(name=name)) else: if required: - raise BadRequest(_(f"The query parameter {name} is required")) + raise BadRequest(_("The query parameter {name} is required").format(name=name)) return param diff --git a/docker-compose.yml b/docker-compose.yml index ce75a1ff..f409a184 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -82,7 +82,7 @@ services: context: ./frontend dockerfile: Dockerfile environment: - WATCHPACK_POLLING: true + WATCHPACK_POLLING: "true" command: sh -c 'if [ "${ENVIRONMENT}" = "production" ]; then npm start; else npm run dev; fi' expose: - 3000 diff --git a/frontend/__tests__/logout.test.tsx b/frontend/__tests__/logout.test.tsx index 16fcd773..cf54aee9 100644 --- a/frontend/__tests__/logout.test.tsx +++ b/frontend/__tests__/logout.test.tsx @@ -22,13 +22,13 @@ describe("Logout", () => { it("renders without crashing", () => { render(); - expect(screen.getByText("Log out")).toBeInTheDocument(); + expect(screen.getByText("Log uit")).toBeInTheDocument(); }); it("opens modal on logout click", () => { render(); - fireEvent.click(screen.getByText("Log out")); - expect(screen.getByText("Are you sure you want to log out?")).toBeInTheDocument(); + fireEvent.click(screen.getByText("Log uit")); + expect(screen.getByText("Zeker dat je wil uitloggen?")).toBeInTheDocument(); }); it("calls logout and router push on modal logout click", async () => { @@ -37,8 +37,8 @@ describe("Logout", () => { push: pushMock, }); render(); - fireEvent.click(screen.getByText("Log out")); // open the modal - fireEvent.click(screen.getByText("Log out", { selector: "button" })); // click on the logout button in the modal + fireEvent.click(screen.getByText("Log uit")); // open the modal + fireEvent.click(screen.getByText("Log uit", { selector: "button" })); // click on the logout button in the modal expect(logout).toHaveBeenCalled(); // Use waitFor for asynchronous assertions diff --git a/frontend/__tests__/student/fileList.test.tsx b/frontend/__tests__/student/fileList.test.tsx index 8fa1b801..b4834fd1 100644 --- a/frontend/__tests__/student/fileList.test.tsx +++ b/frontend/__tests__/student/fileList.test.tsx @@ -26,7 +26,10 @@ describe("FileList", () => { const file = new File(["hello"], "hello.png", { type: "image/png" }); render(); - const input = screen.getByTestId("upload-label"); + const uploadButton = screen.getByText("Upload foto's"); + fireEvent.click(uploadButton); + + const input = screen.getByTestId("photos"); await userEvent.upload(input, file); await waitFor(() => expect(mockSetFiles).toHaveBeenCalled()); diff --git a/frontend/components/admin/editEmailModal.tsx b/frontend/components/admin/editEmailModal.tsx index f383aad8..5661ad41 100644 --- a/frontend/components/admin/editEmailModal.tsx +++ b/frontend/components/admin/editEmailModal.tsx @@ -103,8 +103,8 @@ export default function ({
-
- +
+