Skip to content
Merged
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
4 changes: 2 additions & 2 deletions drf_lint_baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"channels/serializers.py:136:24:ORM002",
"profiles/serializers.py:136:31:ORM002",
"profiles/serializers.py:196:16:ORM002",
"profiles/serializers.py:418:15:ORM001",
"profiles/serializers.py:419:27:ORM001"
"profiles/serializers.py:419:15:ORM001",
"profiles/serializers.py:420:27:ORM001"
]
6 changes: 6 additions & 0 deletions frontends/api/src/generated/v0/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontends/api/src/test-utils/factories/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const user: PartialFactory<User> = (overrides = {}): User => {
// @ts-expect-error API Response can include anonymous user
id: null,
username: "",
global_id: null,
}
}

Expand All @@ -44,6 +45,7 @@ const user: PartialFactory<User> = (overrides = {}): User => {
is_learning_path_editor: false,
username: faker.internet.username(),
is_authenticated: true,
global_id: faker.string.uuid(),
...overrides,
profile: profile(overrides?.profile ?? {}),
}
Expand Down
5 changes: 5 additions & 0 deletions openapi/specs/v0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5731,6 +5731,10 @@ components:
username:
type: string
readOnly: true
global_id:
type: string
readOnly: true
nullable: true
profile:
$ref: '#/components/schemas/Profile'
first_name:
Expand All @@ -5750,6 +5754,7 @@ components:
readOnly: true
required:
- first_name
- global_id
- id
- is_article_editor
- is_authenticated
Expand Down
3 changes: 2 additions & 1 deletion profiles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class Meta:
fields = (
"id",
"username",
"global_id",
Comment thread
sentry[bot] marked this conversation as resolved.
"profile",
"email",
"first_name",
Expand All @@ -391,7 +392,7 @@ class Meta:
"is_learning_path_editor",
"is_authenticated",
)
read_only_fields = ("id", "username", "is_authenticated")
read_only_fields = ("id", "username", "global_id", "is_authenticated")


class ProgramCertificateSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 2 additions & 0 deletions profiles/serializers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_serialize_user(user):
assert UserSerializer(user).data == {
"id": user.id,
"username": user.username,
"global_id": user.global_id,
"first_name": user.first_name,
"last_name": user.last_name,
"is_learning_path_editor": False,
Expand Down Expand Up @@ -90,6 +91,7 @@ def test_serialize_create_user(db, mocker):
assert UserSerializer(instance=user).data == {
"id": user.id,
"username": user.username,
"global_id": user.global_id,
"first_name": user.first_name,
"last_name": user.last_name,
"is_learning_path_editor": False,
Expand Down
5 changes: 5 additions & 0 deletions profiles/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_list_users(staff_client, staff_user):
{
"id": staff_user.id,
"username": staff_user.username,
"global_id": staff_user.global_id,
"first_name": staff_user.first_name,
"last_name": staff_user.last_name,
"is_learning_path_editor": True,
Expand Down Expand Up @@ -98,6 +99,7 @@ def test_get_user(staff_client, user):
assert resp.json() == {
"id": user.id,
"username": user.username,
"global_id": user.global_id,
"first_name": user.first_name,
"last_name": user.last_name,
"is_article_editor": True,
Comment thread
sentry[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -188,6 +190,7 @@ def test_patch_user(staff_client, user, email, email_optin, toc_optin):
assert resp.json() == {
"id": user.id,
"username": user.username,
"global_id": user.global_id,
"first_name": user.first_name,
"last_name": user.last_name,
"is_learning_path_editor": True,
Expand Down Expand Up @@ -390,6 +393,7 @@ def test_get_user_by_me(mocker, client, user, is_anonymous):
assert resp.json() == {
"id": None,
"username": "",
"global_id": None,
"is_learning_path_editor": False,
"is_article_editor": False,
"is_authenticated": False,
Expand All @@ -398,6 +402,7 @@ def test_get_user_by_me(mocker, client, user, is_anonymous):
assert resp.json() == {
"id": user.id,
"username": user.username,
"global_id": user.global_id,
"first_name": user.first_name,
"last_name": user.last_name,
"is_learning_path_editor": False,
Expand Down
Loading