Skip to content

Commit

Permalink
add org/prj to Records API
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Oct 14, 2024
1 parent 48d01cb commit a6b6d2f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/aurora/api/serializers/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
class RecordSerializer(serializers.ModelSerializer):
registration_url = serializers.SerializerMethodField()
registrar = serializers.CharField()
project = serializers.SerializerMethodField()
organization = serializers.SerializerMethodField()
project_slug = serializers.SerializerMethodField()
organization_slug = serializers.SerializerMethodField()

class Meta:
model = Record
Expand All @@ -23,6 +27,18 @@ def get_registration_url(self, obj):
req = self.context["request"]
return req.build_absolute_uri(reverse("api:registration-detail", kwargs={"pk": obj.registration_id}))

def get_project(self, obj: Record):
return obj.registration.project.pk

def get_organization(self, obj):
return obj.registration.project.organization.pk

def get_project_slug(self, obj: Record):
return obj.registration.project.slug

def get_organization_slug(self, obj):
return obj.registration.project.organization.slug


class DataTableRecordSerializer(serializers.ModelSerializer):
def __init__(self, instance=None, data=empty, **kwargs):
Expand Down

0 comments on commit a6b6d2f

Please sign in to comment.