Skip to content

Commit

Permalink
Fix BaseUserSerializer get_url typehint
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Sep 20, 2024
1 parent e720621 commit bc6f99a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/olympia/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ class Meta:
model = UserProfile
fields = ('id', 'name', 'url', 'username')

def get_url(self, obj):
def get_url(self, obj) -> str | None:
def is_adminish(user):
return user and acl.action_allowed_for(user, amo.permissions.USERS_EDIT)
return acl.action_allowed_for(user, amo.permissions.USERS_EDIT) if user else False

request = self.context.get('request', None)
current_user = getattr(request, 'user', None) if request else None
# Only return your own profile url, and for developers.
if obj == current_user or is_adminish(current_user) or obj.is_public:
return obj.get_absolute_url()
return None

# Used in subclasses.
def get_permissions(self, obj):
Expand Down

0 comments on commit bc6f99a

Please sign in to comment.