Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3b80b02
Merge remote-tracking branch 'upstream/main' into 1291_map_to_events_…
nicki182 May 31, 2025
243b25f
chore: created new components and refactor
nicki182 Jun 7, 2025
d3378d2
chore: created new components and refactor
nicki182 Jun 7, 2025
ca1b226
Merge remote-tracking branch 'origin/1291_map_to_events_page' into 12…
nicki182 Jun 7, 2025
5ba2682
fix: cluster and pointers are showing
nicki182 Jun 7, 2025
078c897
chore: refacor sidebar and change folder structure
nicki182 Jun 7, 2025
ecea5bf
chore: form view selector refactor
nicki182 Jun 8, 2025
dbb0f8e
fix: change selector when clicked new option
nicki182 Jun 9, 2025
1db0806
chore: added new views with selector
nicki182 Jun 9, 2025
89937a0
fix: default view type when first load
nicki182 Jun 9, 2025
18865fa
Minor edits to contributing guide to add i18n-check usage guide
andrewtavis Jun 19, 2025
67bf9c4
Minor change to docs header and don't include formatting in dependenc…
andrewtavis Jun 20, 2025
75e7ed5
chore: created new components and refactor
nicki182 Jun 7, 2025
4869def
fix: cluster and pointers are showing
nicki182 Jun 7, 2025
1ddb5e9
chore: refacor sidebar and change folder structure
nicki182 Jun 7, 2025
50874f1
chore: form view selector refactor
nicki182 Jun 8, 2025
64cb5c1
fix: change selector when clicked new option
nicki182 Jun 9, 2025
59c65b2
fix: default view type when first load
nicki182 Jun 9, 2025
7ee5df6
fix: fix bug to view tootil in poiter and view default in events fix
nicki182 Jun 20, 2025
961c984
Merge remote-tracking branch 'refs/remotes/origin/1291_map_to_events_…
nicki182 Jun 20, 2025
6708081
fix: add missing header
nicki182 Jun 21, 2025
94420d8
fix: eliminated unnesary foldder and files
nicki182 Jun 21, 2025
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
22 changes: 12 additions & 10 deletions .github/workflows/check_dependency_updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,18 @@ jobs:
working-directory: ./backend
continue-on-error: true
run: |
echo -e "\n### Ruff Format Results" >> ../reports.md
echo "\`\`\`" >> ../reports.md
ruff format . 2>&1 | tee -a ../reports.md || true
echo "\`\`\`" >> ../reports.md
# Note: Don't check formatting.
# echo -e "\n### Ruff Format Results" >> ../reports.md
# echo "\`\`\`" >> ../reports.md
# ruff format . 2>&1 | tee -a ../reports.md || true
# echo "\`\`\`" >> ../reports.md

echo -e "\n### Ruff Lint Results" >> ../reports.md
echo "\`\`\`" >> ../reports.md
ruff check . 2>&1 | tee -a ../reports.md || true
echo "\`\`\`" >> ../reports.md

echo -e "\n### Mypy Results" >> ../reports.md
echo -e "\n### mypy Results" >> ../reports.md
echo "\`\`\`" >> ../reports.md
mypy . --config-file pyproject.toml 2>&1 | tee -a ../reports.md || true
echo "\`\`\`" >> ../reports.md
Expand All @@ -191,11 +192,12 @@ jobs:
working-directory: ./frontend
continue-on-error: true
run: |
echo "compare_versions.js" >> ../.prettierignore
echo -e "\n### Prettier Results" >> ../reports.md
echo "\`\`\`" >> ../reports.md
yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore 2>&1 | tee -a ../reports.md || true
echo "\`\`\`" >> ../reports.md
# Note: Don't check formatting.
# echo "compare_versions.js" >> ../.prettierignore
# echo -e "\n### Prettier Results" >> ../reports.md
# echo "\`\`\`" >> ../reports.md
# yarn prettier . --check --config ../.prettierrc --ignore-path ../.prettierignore 2>&1 | tee -a ../reports.md || true
# echo "\`\`\`" >> ../reports.md

echo -e "\n### ESLint Results" >> ../reports.md
echo "\`\`\`" >> ../reports.md
Expand Down
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ If you have questions or would like to communicate with the team, please [join u
- [Localization](#localization-)
- [Documentation](#documentation-)
- [Accessibility](#accessibility-)
- [Internationalization](#internationalization-)
- [Design](#design-)
- [Troubleshooting](#troubleshooting-)

Expand Down Expand Up @@ -677,6 +678,28 @@ Tab focusing sadly doesn't work out of the box for many browsers. Chrome works g

Once the above steps are finished you should be able to use tab to navigate web pages :)

<a id="internationalization-"></a>

## Internationalization [`⇧`](#contents)

activist uses [i18n-check](https://github.com/activist-org/i18n-check) to validate our internationalization key-value pairs. The basic commands to check the i18n keys and values are:

```bash
# Note: You need to have installed the backend/requirements-dev.txt file in your virtual environment.
i18n-check -a # run all checks
i18n-check -ki # run key identifiers check
i18n-check -ik # run invalid keys check
i18n-check -uk # run unused keys check
i18n-check -nsk # run non-source keys check
i18n-check -rk # run repeat keys check
i18n-check -rv # run repeat values check
i18n-check -nk # run nested keys check
```

You can also run individual checks. Please see the [documentation for i18n-check](https://i18n-check.readthedocs.io/en/latest/) to learn more.

If you do need to edit the directories and files skipped by certain checks, then these edits can be made in the [.i18n-check.yaml](./.i18n-check.yaml) file. If you're having issues using `i18n-check`, please feel free to contact the team for support!

<a id="design-"></a>

## Design [`⇧`](#contents)
Expand Down
4 changes: 0 additions & 4 deletions backend/authentication/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ def verification_partner(


class UserFlagFactory(factory.django.DjangoModelFactory):
"""
Factory to create an instance of UserFlag model.
"""

class Meta:
model = UserFlag

Expand Down
6 changes: 3 additions & 3 deletions backend/authentication/tests/flag/test_user_flag_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_user_flag_create():
)

error_response = client.post(
path="/v1/auth/user_flag",
path="/v1/auth/user_flag/",
data={"user": flagged_user.id, "created_by": user.id},
)

Expand All @@ -32,7 +32,7 @@ def test_user_flag_create():
assert error_response_body["detail"] == "You are not allowed flag this user."

login = client.post(
path="/v1/auth/sign_in",
path="/v1/auth/sign_in/",
data={"username": test_username, "password": test_password},
)

Expand All @@ -44,7 +44,7 @@ def test_user_flag_create():
client.credentials(HTTP_AUTHORIZATION=f"Token {token}")

response = client.post(
path="/v1/auth/user_flag",
path="/v1/auth/user_flag/",
data={"user": flagged_user.id, "created_by": user.id},
)

Expand Down
4 changes: 2 additions & 2 deletions backend/authentication/tests/flag/test_user_flag_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_user_flag_delete():

# Login to get token.
login = client.post(
path="/v1/auth/sign_in",
path="/v1/auth/sign_in/",
data={"username": test_username, "password": test_pass},
)

Expand All @@ -35,6 +35,6 @@ def test_user_flag_delete():
token = login_body["token"]

client.credentials(HTTP_AUTHORIZATION=f"Token {token}")
response = client.delete(path=f"/v1/auth/user_flag/{flagged_user.id}")
response = client.delete(path=f"/v1/auth/user_flag/{flagged_user.id}/")

assert response.status_code == 204
2 changes: 1 addition & 1 deletion backend/authentication/tests/flag/test_user_flag_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def test_user_flag_list():
"""
client = APIClient()

response = client.get(path="/v1/auth/user_flag")
response = client.get(path="/v1/auth/user_flag/")

assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def test_user_flag_retrieve():

flagged_user = UserFlagFactory()

response = client.get(path=f"/v1/auth/user_flag/{flagged_user.id}")
response = client.get(path=f"/v1/auth/user_flag/{flagged_user.id}/")

assert response.status_code == 200
64 changes: 28 additions & 36 deletions backend/authentication/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import pytest
from django.core import mail
from django.test import Client
from faker import Faker
from rest_framework.test import APIClient

from authentication.factories import (
SupportEntityTypeFactory,
Expand Down Expand Up @@ -40,7 +40,7 @@ def test_str_methods() -> None:
assert str(user) == user.username


def test_sign_up(client: APIClient) -> None:
def test_sign_up(client: Client) -> None:
"""
Test the sign-up function.

Expand Down Expand Up @@ -72,7 +72,7 @@ def test_sign_up(client: APIClient) -> None:

# 1. Password strength fails.
response = client.post(
path="/v1/auth/sign_up",
path="/v1/auth/sign_up/",
data={
"username": username,
"password": weak_password,
Expand All @@ -86,7 +86,7 @@ def test_sign_up(client: APIClient) -> None:

# 2. Password confirmation fails.
response = client.post(
path="/v1/auth/sign_up",
path="/v1/auth/sign_up/",
data={
"username": username,
"password": strong_password,
Expand All @@ -100,7 +100,7 @@ def test_sign_up(client: APIClient) -> None:

# 3. User is created successfully.
response = client.post(
path="/v1/auth/sign_up",
path="/v1/auth/sign_up/",
data={
"username": username,
"password": strong_password,
Expand All @@ -121,7 +121,7 @@ def test_sign_up(client: APIClient) -> None:

# 4. User already exists.
response = client.post(
path="/v1/auth/sign_up",
path="/v1/auth/sign_up/",
data={
"username": username,
"password": strong_password,
Expand All @@ -135,7 +135,7 @@ def test_sign_up(client: APIClient) -> None:

# 5. User is created without an email.
response = client.post(
path="/v1/auth/sign_up",
path="/v1/auth/sign_up/",
data={
"username": second_username,
"password": strong_password,
Expand All @@ -152,7 +152,7 @@ def test_sign_up(client: APIClient) -> None:
assert user.verification_code is None


def test_sign_in(client: APIClient) -> None:
def test_sign_in(client: Client) -> None:
"""
Test sign in view.

Expand All @@ -164,15 +164,15 @@ def test_sign_in(client: APIClient) -> None:

Parameters
----------
client : APIClient
client : Client
An authenticated client.
"""
plaintext_password = "Activist@123!?"
user = UserFactory(plaintext_password=plaintext_password)

# 1. User that signed up with email, that has not confirmed their email.
response = client.post(
path="/v1/auth/sign_in",
path="/v1/auth/sign_in/",
data={"username": user.username, "password": plaintext_password},
)
assert response.status_code == 400
Expand All @@ -181,33 +181,33 @@ def test_sign_in(client: APIClient) -> None:
user.is_confirmed = True
user.save()
response = client.post(
path="/v1/auth/sign_in",
path="/v1/auth/sign_in/",
data={"email": user.email, "password": plaintext_password},
)
assert response.status_code == 200
# Sign in via username.
response = client.post(
path="/v1/auth/sign_in",
path="/v1/auth/sign_in/",
data={"username": user.username, "password": plaintext_password},
)
assert response.status_code == 200

# 3. User exists but password is incorrect.
response = client.post(
path="/v1/auth/sign_in",
path="/v1/auth/sign_in/",
data={"email": user.email, "password": "Strong_But_Incorrect?!123"},
)
assert response.status_code == 400

# 4. User does not exists and tries to sign in.
response = client.post(
path="/v1/auth/sign_in",
path="/v1/auth/sign_in/",
data={"email": "[email protected]", "password": "Password@123!?"},
)
assert response.status_code == 400


def test_pwreset(client: APIClient) -> None:
def test_pwreset(client: Client) -> None:
"""
Test password reset view.

Expand All @@ -219,7 +219,7 @@ def test_pwreset(client: APIClient) -> None:

Parameters
----------
client : APIClient
client : Client
An authenticated client.
"""

Expand All @@ -230,23 +230,23 @@ def test_pwreset(client: APIClient) -> None:
# 1. User exists and password reset is successful.
user = UserFactory(plaintext_password=old_password)
response = client.get(
path="/v1/auth/pwreset",
path="/v1/auth/pwreset/",
data={"email": user.email},
)
assert response.status_code == 200
assert len(mail.outbox) == 1

# 2. Password reset with invalid email.
response = client.get(
path="/v1/auth/pwreset", data={"email": "[email protected]"}
path="/v1/auth/pwreset/", data={"email": "[email protected]"}
)
assert response.status_code == 404

# 3. Password reset is performed successfully.
user.verification_code = uuid.uuid4()
user.save()
response = client.post(
path=f"/v1/auth/pwreset?code={user.verification_code}",
path=f"/v1/auth/pwreset/?code={user.verification_code}",
data={"password": new_password},
)
assert response.status_code == 200
Expand All @@ -255,7 +255,7 @@ def test_pwreset(client: APIClient) -> None:

# 4. Password reset with invalid verification code.
response = client.post(
path="/v1/auth/pwreset/invalid_code",
path="/v1/auth/pwreset/invalid_code/",
data={"password": new_password},
)
assert response.status_code == 404
Expand Down Expand Up @@ -323,35 +323,27 @@ def test_create_user_and_superuser():
)


def test_delete_user() -> None:
def test_delete_user(client: Client) -> None:
"""
Test the deletion of existing user records from the database.

Parameters
----------
client : APIClient
client : Client
An authenticated client.
"""
client = APIClient()
test_username = "test_user_123"
test_pass = "Activist@123!?"
user = UserFactory(username=test_username, plaintext_password=test_pass)
user.is_confirmed = True
user.save()

# User Login
login = client.post(
path="/v1/auth/sign_in",
data={"username": test_username, "password": test_pass},
response = client.post(
path="/v1/auth/sign_in/",
data={"username": user.username, "password": user.password},
)

assert login.status_code == 200

login_body = login.json()
token = login_body["token"]

# User deletes themselves.
client.credentials(HTTP_AUTHORIZATION=f"Token {token}")
response = client.delete(path="/v1/auth/delete")
if response.status_code == 200:
delete_response = client.delete(path="/v1/auth/delete/", data={"pk": user.id})

assert response.status_code == 204
assert delete_response.status_code == 200
10 changes: 5 additions & 5 deletions backend/authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

app_name = "authentication"

router = DefaultRouter(trailing_slash=False)
router = DefaultRouter()

router.register(
prefix=r"user_flag", viewset=views.UserFlagViewSets, basename="user-flag"
)

urlpatterns = [
path("", include(router.urls)),
path(route="sign_up", view=views.SignUpView.as_view(), name="sign_up"),
path(route="delete", view=views.DeleteUserView.as_view(), name="delete"),
path(route="sign_in", view=views.SignInView.as_view(), name="sign_in"),
path(route="pwreset", view=views.PasswordResetView.as_view(), name="pwreset"),
path(route="sign_up/", view=views.SignUpView.as_view(), name="sign_up"),
path(route="delete/", view=views.DeleteUserView.as_view(), name="delete"),
path(route="sign_in/", view=views.SignInView.as_view(), name="sign_in"),
path(route="pwreset/", view=views.PasswordResetView.as_view(), name="pwreset"),
]
Loading
Loading