* expose submitter_id for entries * .
This commit is contained in:
Родитель
b429cceb85
Коммит
4c122dacbe
|
@ -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',
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче