Show speakers in the modal. Also removed favorite action when anonymous.
This commit is contained in:
parent
d511df399d
commit
f96c8b6db5
|
@ -247,7 +247,7 @@ class EventProposal(UserSubmittedModel):
|
||||||
# loop through the speakerproposals linked to this eventproposal and associate any related speaker objects with this event
|
# loop through the speakerproposals linked to this eventproposal and associate any related speaker objects with this event
|
||||||
for sp in self.speakers.all():
|
for sp in self.speakers.all():
|
||||||
if sp.speaker:
|
if sp.speaker:
|
||||||
event.speaker_set.add(sp.speaker)
|
event.speakers.add(sp.speaker)
|
||||||
|
|
||||||
self.proposal_status = eventproposalmodel.PROPOSAL_APPROVED
|
self.proposal_status = eventproposalmodel.PROPOSAL_APPROVED
|
||||||
self.save()
|
self.save()
|
||||||
|
@ -376,8 +376,8 @@ class Event(CampRelatedModel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speakers_list(self):
|
def speakers_list(self):
|
||||||
if self.speaker_set.exists():
|
if self.speakers.exists():
|
||||||
return ", ".join(self.speaker_set.all().values_list('name', flat=True))
|
return ", ".join(self.speakers.all().values_list('name', flat=True))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
|
@ -463,9 +463,13 @@ class EventInstance(CampRelatedModel):
|
||||||
'to': self.when.lower.isoformat(),
|
'to': self.when.lower.isoformat(),
|
||||||
'url': str(self.event.get_absolute_url()),
|
'url': str(self.event.get_absolute_url()),
|
||||||
'id': self.id,
|
'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()
|
is_favorited = user.favorites.filter(event_instance=self).exists()
|
||||||
data['is_favorited'] = is_favorited
|
data['is_favorited'] = is_favorited
|
||||||
|
|
||||||
|
@ -525,6 +529,7 @@ class Speaker(CampRelatedModel):
|
||||||
Event,
|
Event,
|
||||||
blank=True,
|
blank=True,
|
||||||
help_text='The event(s) this speaker is anchoring',
|
help_text='The event(s) this speaker is anchoring',
|
||||||
|
related_name='speakers'
|
||||||
)
|
)
|
||||||
|
|
||||||
proposal = models.OneToOneField(
|
proposal = models.OneToOneField(
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<a href="{% url 'event_detail' camp_slug=camp.slug slug=event.slug %}">{{ event.title }}</a>
|
<a href="{% url 'event_detail' camp_slug=camp.slug slug=event.slug %}">{{ event.title }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for speaker in event.speaker_set.all %}
|
{% for speaker in event.speakers.all %}
|
||||||
<a href="{% url 'speaker_detail' camp_slug=camp.slug slug=speaker.slug %}">{{ speaker.name }}</a><br>
|
<a href="{% url 'speaker_detail' camp_slug=camp.slug slug=speaker.slug %}">{{ speaker.name }}</a><br>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
N/A
|
N/A
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{% if event.speaker_set.exists %}
|
{% if event.speakers.exists %}
|
||||||
<h4>Speakers</h4>
|
<h4>Speakers</h4>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
{% for speaker in event.speaker_set.all %}
|
{% for speaker in event.speakers.all %}
|
||||||
<h4><a href="{% url 'speaker_detail' camp_slug=camp.slug slug=speaker.slug %}" class="list-group-item">{{ speaker.name }}</a></h4>
|
<h4><a href="{% url 'speaker_detail' camp_slug=camp.slug slug=speaker.slug %}" class="list-group-item">{{ speaker.name }}</a></h4>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,7 +34,12 @@
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
<h4 class="modal-title"></h4>
|
<h4 class="modal-title"></h4>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal-body modal-body-content">
|
||||||
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<h4>Speaker(s):</h4>
|
||||||
|
<ul class="speakers">
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
|
||||||
|
@ -94,13 +99,29 @@
|
||||||
modal = modals[event_instance_id];
|
modal = modals[event_instance_id];
|
||||||
modal_title = modal.getElementsByClassName('modal-title')[0];
|
modal_title = modal.getElementsByClassName('modal-title')[0];
|
||||||
modal_title.innerHTML = payload['event_instance']['title']
|
modal_title.innerHTML = payload['event_instance']['title']
|
||||||
modal_body = modal.getElementsByClassName('modal-body')[0];
|
modal_body_content = modal.getElementsByClassName('modal-body-content')[0];
|
||||||
modal_body.innerHTML = payload['event_instance']['abstract'];
|
modal_body_content.innerHTML = payload['event_instance']['abstract'];
|
||||||
more_button = modal.getElementsByClassName('more-button')[0];
|
more_button = modal.getElementsByClassName('more-button')[0];
|
||||||
more_button.setAttribute('href', payload['event_instance']['url']);
|
more_button.setAttribute('href', payload['event_instance']['url']);
|
||||||
favorite_button = modal.getElementsByClassName('favorite-button')[0];
|
favorite_button = modal.getElementsByClassName('favorite-button')[0];
|
||||||
|
if(payload['event_instance']['is_favorited'] !== undefined) {
|
||||||
favorite_button.setAttribute('data-state', payload['event_instance']['is_favorited'])
|
favorite_button.setAttribute('data-state', payload['event_instance']['is_favorited'])
|
||||||
toggleFavoriteButton(favorite_button)
|
toggleFavoriteButton(favorite_button);
|
||||||
|
} else {
|
||||||
|
favorite_button.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
speakers_div = modal.getElementsByClassName('speakers')[0];
|
||||||
|
speakers = payload['event_instance']['speakers'];
|
||||||
|
for(speaker_id in speakers) {
|
||||||
|
var speaker = speakers[speaker_id];
|
||||||
|
var speaker_li = document.createElement('li');
|
||||||
|
var speaker_a = document.createElement('a');
|
||||||
|
speaker_a.setAttribute('href', speaker['url']);
|
||||||
|
speaker_a.appendChild(document.createTextNode(speaker['name']));
|
||||||
|
speaker_li.appendChild(speaker_a);
|
||||||
|
speakers_div.appendChild(speaker_li);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue