Skip to content

Commit 300432c

Browse files
authored
Merge pull request #245 from pneumaticapp/backend/accounts/47721__api_key
⚙️ 47721 backend [ accounts ] New API endpoint: get all account users
2 parents e136f48 + 08eb42e commit 300432c

4 files changed

Lines changed: 571 additions & 3 deletions

File tree

backend/src/accounts/filters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Meta:
9494
groups = ListFilter(
9595
field_name='user_groups',
9696
lookup_expr='in',
97+
distinct=True,
9798
)
9899

99100

backend/src/accounts/serializers/api_key.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.contrib.auth import get_user_model
2+
from django.core.exceptions import ObjectDoesNotExist
23
from rest_framework import serializers
34

45
from src.accounts.models import (
@@ -16,3 +17,27 @@ class Meta:
1617
'name',
1718
'key',
1819
)
20+
21+
22+
class UserAPIKeySerializer(serializers.ModelSerializer):
23+
24+
class Meta:
25+
model = UserModel
26+
fields = (
27+
'first_name',
28+
'last_name',
29+
'email',
30+
'is_admin',
31+
'is_account_owner',
32+
'api_key',
33+
'type',
34+
'status',
35+
)
36+
37+
api_key = serializers.SerializerMethodField()
38+
39+
def get_api_key(self, obj) -> str:
40+
try:
41+
return obj.apikey.key
42+
except ObjectDoesNotExist:
43+
return None

0 commit comments

Comments
 (0)