From f96c8b6db5b7aab78e965c6a4798463f3bdd0fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Mon, 17 Apr 2017 20:29:59 +0200 Subject: [PATCH] Show speakers in the modal. Also removed favorite action when anonymous. --- src/program/models.py | 13 ++++++--- src/program/templates/event_list.html | 2 +- .../templates/schedule_event_detail.html | 4 +-- src/program/templates/schedule_overview.html | 29 ++++++++++++++++--- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/program/models.py b/src/program/models.py index d64892e3..33f98139 100644 --- a/src/program/models.py +++ b/src/program/models.py @@ -247,7 +247,7 @@ class EventProposal(UserSubmittedModel): # loop through the speakerproposals linked to this eventproposal and associate any related speaker objects with this event for sp in self.speakers.all(): if sp.speaker: - event.speaker_set.add(sp.speaker) + event.speakers.add(sp.speaker) self.proposal_status = eventproposalmodel.PROPOSAL_APPROVED self.save() @@ -376,8 +376,8 @@ class Event(CampRelatedModel): @property def speakers_list(self): - if self.speaker_set.exists(): - return ", ".join(self.speaker_set.all().values_list('name', flat=True)) + if self.speakers.exists(): + return ", ".join(self.speakers.all().values_list('name', flat=True)) return False def get_absolute_url(self): @@ -463,9 +463,13 @@ class EventInstance(CampRelatedModel): 'to': self.when.lower.isoformat(), 'url': str(self.event.get_absolute_url()), 'id': self.id, + 'speakers': [ + { 'name': speaker.name + , 'url': str(speaker.get_absolute_url()) + } for speaker in self.event.speakers.all()] } - if user: + if user and user.is_authenticated: is_favorited = user.favorites.filter(event_instance=self).exists() data['is_favorited'] = is_favorited @@ -525,6 +529,7 @@ class Speaker(CampRelatedModel): Event, blank=True, help_text='The event(s) this speaker is anchoring', + related_name='speakers' ) proposal = models.OneToOneField( diff --git a/src/program/templates/event_list.html b/src/program/templates/event_list.html index 216aa945..c3ffac7a 100644 --- a/src/program/templates/event_list.html +++ b/src/program/templates/event_list.html @@ -28,7 +28,7 @@ {{ event.title }} - {% for speaker in event.speaker_set.all %} + {% for speaker in event.speakers.all %} {{ speaker.name }}
{% empty %} N/A diff --git a/src/program/templates/schedule_event_detail.html b/src/program/templates/schedule_event_detail.html index c53a6028..61b95a70 100644 --- a/src/program/templates/schedule_event_detail.html +++ b/src/program/templates/schedule_event_detail.html @@ -22,10 +22,10 @@
- {% if event.speaker_set.exists %} + {% if event.speakers.exists %}

Speakers

- {% for speaker in event.speaker_set.all %} + {% for speaker in event.speakers.all %}

{{ speaker.name }}

{% endfor %}
diff --git a/src/program/templates/schedule_overview.html b/src/program/templates/schedule_overview.html index 23f8cc7e..f95f3ece 100644 --- a/src/program/templates/schedule_overview.html +++ b/src/program/templates/schedule_overview.html @@ -34,7 +34,12 @@ +