Add code to speaker

Add unique identifier (code) to speakers within schedule JSON API
to allow speakers to be identified throughout the schedule.
This commit is contained in:
Joel Addison 2021-11-28 21:41:45 +10:00
parent 2d8ca5550f
commit 72b5c3ff55
2 changed files with 7 additions and 1 deletions

View file

@ -222,7 +222,8 @@ def make_speaker_dict(user, speaker):
'name': speaker.name,
'twitter': speaker.twitter_username,
'contact': speaker.email if has_contact_perm(user) else 'redacted',
'picture_url': speaker_photo(None, speaker, 120)
'picture_url': speaker_photo(None, speaker, 120),
'code': speaker.code,
}
def schedule_json(request):

View file

@ -157,3 +157,8 @@ class Speaker(models.Model):
for p in self.copresentations.all():
presentations.append(p)
return presentations
@property
def code(self):
""" A unique string that identifies this speaker. """
return f"{self.pk}"