Skip to content

Commit bc26508

Browse files
committed
Make the Farm retrieve APIs return the name of the Farm's owner
Field 'owner' was added to the Farm model in commit 2dd4338. The owner's name should be returned through the Farm retrieve APIs, instead of the owner's primary key. This was overlooked on a previous pull request. (#582)
1 parent 1a96f66 commit bc26508

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

promgen/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def to_representation(self, obj):
106106

107107

108108
class FarmSerializer(serializers.ModelSerializer):
109+
owner = serializers.ReadOnlyField(source="owner.username")
109110
url = WebLinkField()
110111

111112
class Meta:

promgen/tests/examples/rest.farm.1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"url": "http://promgen.example.com/farm/1",
44
"name": "test-farm",
55
"source": "promgen",
6-
"owner": null,
6+
"owner": "admin",
77
"hosts": [
88
{
99
"name": "host.example.com",

promgen/tests/examples/rest.farm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"url": "http://promgen.example.com/farm/1",
55
"name": "test-farm",
66
"source":"promgen",
7-
"owner": null
7+
"owner": "admin"
88
}
99
]

0 commit comments

Comments
 (0)