Verified Commit 62a99d46 authored by Agate's avatar Agate 💬

Serialize contributor avatar URL in API

parent ec8de74b
......@@ -16,6 +16,15 @@ class Contributor(models.Model):
def __str__(self):
return self.username
@property
def avatar_url(self):
paths = [("gitlab", "avatar_url"), ("opencollective", "image")]
for p, a in paths:
try:
return self.metadata[p][a]
except KeyError:
continue
CONTRIBUTION_TYPES = [
("dev", "Development"),
......
......@@ -6,7 +6,7 @@ from . import models
class ContributorSerizalizer(serializers.ModelSerializer):
class Meta:
model = models.Contributor
fields = ["id", "name", "username", "metadata"]
fields = ["id", "name", "username", "metadata", "avatar_url"]
class ContributionSerializer(serializers.ModelSerializer):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment