Fix #193 - expose submitter_profile_id for entries (#205)

* expose submitter_id for entries

* .
This commit is contained in:
Mike Kamermans 2017-09-13 13:20:48 -07:00 коммит произвёл Gideon Thomas
Родитель b429cceb85
Коммит 4c122dacbe
1 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -89,6 +89,19 @@ class EntrySerializer(serializers.ModelSerializer):
"""
return instance.published_by.name
# "virtual" property so that we can link to the correct profile
submitter_profile_id = serializers.SerializerMethodField()
def get_submitter_profile_id(self, instance):
"""
Get the id for the user who published this entry
"""
profiles = instance.published_by.profile.all()
if len(profiles) > 0:
profile = profiles[0]
return profile.id
return False
bookmark_count = serializers.SerializerMethodField()
def get_bookmark_count(self, instance):
@ -120,4 +133,6 @@ class EntrySerializer(serializers.ModelSerializer):
Meta class. Because
"""
model = Entry
exclude = ('internal_notes', 'published_by',)
exclude = (
'internal_notes',
)