We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add payment_type or full payment to event admin API
### Motivation
`api/v2/admin/events/<eventPk>/registrations/` currently only gives the uuid of a payment, so to display in the admin screen how it was paid, the payment must be requested separately. Doing this for all of the registrations would be very inefficient (like 40 extra requests to load the event admin). If we simply add the payment_type or replace the payment uuid with a payment serializer, it will be much simpler.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `website/events/api/v2/serializers/event_registration.py`
Content:
```
1 from rest_framework import serializers
2 
3 from events.models import EventRegistration
4 from members.api.v2.serializers.member import MemberSerializer
5 
6 
7 class EventRegistrationSerializer(serializers.ModelSerializer):
8     """Serializer for event registrations."""
9 
10     def __init__(self, *args, **kwargs):
11         # Don't pass the 'fields' arg up to the superclass
12         fields = kwargs.pop("fields", {"pk", "member", "name"})
13 
14         # Instantiate the superclass normally
15         super().__init__(*args, **kwargs)
16 
17         allowed = set(fields)
18         existing = set(self.fields.keys())
19         for field_name in existing - allowed:
20             self.fields.pop(field_name)
21 
22     class Meta:
23         model = EventRegistration
24         fields = (
25             "pk",
26             "present",
27             "queue_position",
28             "date",
29             "payment",
30             "member",
31             "name",
32         )
33 
34     member = MemberSerializer(detailed=False, read_only=True)
35
```

Path: `website/events/api/v2/admin/serializers/event_registration.py`
Content:
```
1 from rest_framework import serializers
2 
3 from events.models import EventRegistration
4 from members.api.v2.serializers.member import MemberSerializer
5 from members.models import Member
6 
7 
8 class EventRegistrationAdminSerializer(serializers.ModelSerializer):
9     """Serializer for event registrations."""
10 
11     class Meta:
12         model = EventRegistration
13         fields = (
14             "pk",
15             "present",
16             "queue_position",
17             "date",
18             "date_cancelled",
19             "payment",
20             "member",
21             "name",
22         )
23         read_only_fields = ("payment",)
24 
25     def to_internal_value(self, data):
26         self.fields["member"] = serializers.PrimaryKeyRelatedField(
27             queryset=Member.objects.all()
28         )
29         return super().to_internal_value(data)
30 
31     def to_representation(self, instance):
32         self.fields["member"] = MemberSerializer(detailed=False, read_only=True)
33         return super().to_representation(instance)
34
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/website/events/api/v2/admin/serializers/event_registration.py b/website/events/api/v2/admin/serializers/event_registration.py
--- a/website/events/api/v2/admin/serializers/event_registration.py
+++ b/website/events/api/v2/admin/serializers/event_registration.py
@@ -3,6 +3,7 @@
 from events.models import EventRegistration
 from members.api.v2.serializers.member import MemberSerializer
 from members.models import Member
+from payments.api.v2.serializers import PaymentSerializer
 
 
 class EventRegistrationAdminSerializer(serializers.ModelSerializer):
@@ -22,6 +23,8 @@
         )
         read_only_fields = ("payment",)
 
+    payment = PaymentSerializer()
+
     def to_internal_value(self, data):
         self.fields["member"] = serializers.PrimaryKeyRelatedField(
             queryset=Member.objects.all()
diff --git a/website/events/api/v2/serializers/event_registration.py b/website/events/api/v2/serializers/event_registration.py
--- a/website/events/api/v2/serializers/event_registration.py
+++ b/website/events/api/v2/serializers/event_registration.py
@@ -2,6 +2,7 @@
 
 from events.models import EventRegistration
 from members.api.v2.serializers.member import MemberSerializer
+from payments.api.v2.serializers import PaymentSerializer
 
 
 class EventRegistrationSerializer(serializers.ModelSerializer):
@@ -31,4 +32,5 @@
             "name",
         )
 
+    payment = PaymentSerializer()
     member = MemberSerializer(detailed=False, read_only=True)

{"golden_diff": "diff --git a/website/events/api/v2/admin/serializers/event_registration.py b/website/events/api/v2/admin/serializers/event_registration.py\n--- a/website/events/api/v2/admin/serializers/event_registration.py\n+++ b/website/events/api/v2/admin/serializers/event_registration.py\n@@ -3,6 +3,7 @@\n from events.models import EventRegistration\n from members.api.v2.serializers.member import MemberSerializer\n from members.models import Member\n+from payments.api.v2.serializers import PaymentSerializer\n \n \n class EventRegistrationAdminSerializer(serializers.ModelSerializer):\n@@ -22,6 +23,8 @@\n         )\n         read_only_fields = (\"payment\",)\n \n+    payment = PaymentSerializer()\n+\n     def to_internal_value(self, data):\n         self.fields[\"member\"] = serializers.PrimaryKeyRelatedField(\n             queryset=Member.objects.all()\ndiff --git a/website/events/api/v2/serializers/event_registration.py b/website/events/api/v2/serializers/event_registration.py\n--- a/website/events/api/v2/serializers/event_registration.py\n+++ b/website/events/api/v2/serializers/event_registration.py\n@@ -2,6 +2,7 @@\n \n from events.models import EventRegistration\n from members.api.v2.serializers.member import MemberSerializer\n+from payments.api.v2.serializers import PaymentSerializer\n \n \n class EventRegistrationSerializer(serializers.ModelSerializer):\n@@ -31,4 +32,5 @@\n             \"name\",\n         )\n \n+    payment = PaymentSerializer()\n     member = MemberSerializer(detailed=False, read_only=True)\n", "issue": "Add payment_type or full payment to event admin API\n### Motivation\r\n`api/v2/admin/events/<eventPk>/registrations/` currently only gives the uuid of a payment, so to display in the admin screen how it was paid, the payment must be requested separately. Doing this for all of the registrations would be very inefficient (like 40 extra requests to load the event admin). If we simply add the payment_type or replace the payment uuid with a payment serializer, it will be much simpler.\r\n\n", "before_files": [{"content": "from rest_framework import serializers\n\nfrom events.models import EventRegistration\nfrom members.api.v2.serializers.member import MemberSerializer\n\n\nclass EventRegistrationSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer for event registrations.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        # Don't pass the 'fields' arg up to the superclass\n        fields = kwargs.pop(\"fields\", {\"pk\", \"member\", \"name\"})\n\n        # Instantiate the superclass normally\n        super().__init__(*args, **kwargs)\n\n        allowed = set(fields)\n        existing = set(self.fields.keys())\n        for field_name in existing - allowed:\n            self.fields.pop(field_name)\n\n    class Meta:\n        model = EventRegistration\n        fields = (\n            \"pk\",\n            \"present\",\n            \"queue_position\",\n            \"date\",\n            \"payment\",\n            \"member\",\n            \"name\",\n        )\n\n    member = MemberSerializer(detailed=False, read_only=True)\n", "path": "website/events/api/v2/serializers/event_registration.py"}, {"content": "from rest_framework import serializers\n\nfrom events.models import EventRegistration\nfrom members.api.v2.serializers.member import MemberSerializer\nfrom members.models import Member\n\n\nclass EventRegistrationAdminSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer for event registrations.\"\"\"\n\n    class Meta:\n        model = EventRegistration\n        fields = (\n            \"pk\",\n            \"present\",\n            \"queue_position\",\n            \"date\",\n            \"date_cancelled\",\n            \"payment\",\n            \"member\",\n            \"name\",\n        )\n        read_only_fields = (\"payment\",)\n\n    def to_internal_value(self, data):\n        self.fields[\"member\"] = serializers.PrimaryKeyRelatedField(\n            queryset=Member.objects.all()\n        )\n        return super().to_internal_value(data)\n\n    def to_representation(self, instance):\n        self.fields[\"member\"] = MemberSerializer(detailed=False, read_only=True)\n        return super().to_representation(instance)\n", "path": "website/events/api/v2/admin/serializers/event_registration.py"}], "after_files": [{"content": "from rest_framework import serializers\n\nfrom events.models import EventRegistration\nfrom members.api.v2.serializers.member import MemberSerializer\nfrom payments.api.v2.serializers import PaymentSerializer\n\n\nclass EventRegistrationSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer for event registrations.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        # Don't pass the 'fields' arg up to the superclass\n        fields = kwargs.pop(\"fields\", {\"pk\", \"member\", \"name\"})\n\n        # Instantiate the superclass normally\n        super().__init__(*args, **kwargs)\n\n        allowed = set(fields)\n        existing = set(self.fields.keys())\n        for field_name in existing - allowed:\n            self.fields.pop(field_name)\n\n    class Meta:\n        model = EventRegistration\n        fields = (\n            \"pk\",\n            \"present\",\n            \"queue_position\",\n            \"date\",\n            \"payment\",\n            \"member\",\n            \"name\",\n        )\n\n    payment = PaymentSerializer()\n    member = MemberSerializer(detailed=False, read_only=True)\n", "path": "website/events/api/v2/serializers/event_registration.py"}, {"content": "from rest_framework import serializers\n\nfrom events.models import EventRegistration\nfrom members.api.v2.serializers.member import MemberSerializer\nfrom members.models import Member\nfrom payments.api.v2.serializers import PaymentSerializer\n\n\nclass EventRegistrationAdminSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer for event registrations.\"\"\"\n\n    class Meta:\n        model = EventRegistration\n        fields = (\n            \"pk\",\n            \"present\",\n            \"queue_position\",\n            \"date\",\n            \"date_cancelled\",\n            \"payment\",\n            \"member\",\n            \"name\",\n        )\n        read_only_fields = (\"payment\",)\n\n    payment = PaymentSerializer()\n\n    def to_internal_value(self, data):\n        self.fields[\"member\"] = serializers.PrimaryKeyRelatedField(\n            queryset=Member.objects.all()\n        )\n        return super().to_internal_value(data)\n\n    def to_representation(self, instance):\n        self.fields[\"member\"] = MemberSerializer(detailed=False, read_only=True)\n        return super().to_representation(instance)\n", "path": "website/events/api/v2/admin/serializers/event_registration.py"}]}