Skip to content

Commit

Permalink
Add is_global_validator on user me endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem committed Jan 16, 2025
1 parent b44bd0f commit d41c7f5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,7 @@ class UserMeSerializer(UserSerializer):
is_per_admin_for_countries = serializers.SerializerMethodField()
user_countries_regions = serializers.SerializerMethodField()
limit_access_to_guest = serializers.BooleanField(read_only=True, source="profile.limit_access_to_guest")
is_global_validator = serializers.SerializerMethodField()

class Meta:
model = User
Expand All @@ -1745,6 +1746,7 @@ class Meta:
"is_per_admin_for_countries",
"user_countries_regions",
"limit_access_to_guest",
"is_global_validator",
)

@staticmethod
Expand Down Expand Up @@ -1808,6 +1810,10 @@ def get_user_countries_regions(user):
qs = UserCountry.objects.filter(user=user).distinct("country")
return UserCountrySerializer(qs, many=True).data

@staticmethod
def get_is_global_validator(user) -> bool:
return Permission.objects.filter(codename="local_unit_global_validator", group__user=user).exists()


class ActionSerializer(ModelSerializer):
class Meta:
Expand Down

0 comments on commit d41c7f5

Please sign in to comment.