Merge pull request #3157 from normanjaeckel/FixDeletedReferenceProjector

Fixed bug when reference projector for list of speakers slide is dele…
This commit is contained in:
Emanuel Schütze 2017-03-28 10:06:12 +02:00 committed by GitHub
commit c4a4773074

View File

@ -81,20 +81,26 @@ class CurrentListOfSpeakersSlide(ProjectorElement):
def get_requirements(self, config_entry): def get_requirements(self, config_entry):
# The query mechanism on client needs the referenced projector. # The query mechanism on client needs the referenced projector.
reference_projector = Projector.objects.get( try:
pk=config['projector_currentListOfSpeakers_reference']) reference_projector = Projector.objects.get(
yield reference_projector pk=config['projector_currentListOfSpeakers_reference'])
except Projector.DoesNotExist:
# Reference projector was deleted so this projector element is empty.
# Skip yielding more requirements (items and speakers).
pass
else:
yield reference_projector
items = self.get_agenda_items(reference_projector) items = self.get_agenda_items(reference_projector)
for item in items: for item in items:
yield item yield item
for speaker in item.speakers.filter(end_time=None): for speaker in item.speakers.filter(end_time=None):
yield speaker.user yield speaker.user
query = (item.speakers.exclude(end_time=None) query = (item.speakers.exclude(end_time=None)
.order_by('-end_time')[:config['agenda_show_last_speakers']]) .order_by('-end_time')[:config['agenda_show_last_speakers']])
for speaker in query: for speaker in query:
# Yield last speakers # Yield last speakers
yield speaker.user yield speaker.user
def get_agenda_items(self, projector): def get_agenda_items(self, projector):
for element in projector.elements.values(): for element in projector.elements.values():
@ -106,21 +112,27 @@ class CurrentListOfSpeakersSlide(ProjectorElement):
output = super().get_collection_elements_required_for_this(collection_element, config_entry) output = super().get_collection_elements_required_for_this(collection_element, config_entry)
# Full update if agenda_item or referenced projector changes because # Full update if agenda_item or referenced projector changes because
# then we may have new candidates and therefor need new users. # then we may have new candidates and therefor need new users.
reference_projector = Projector.objects.get( try:
pk=config['projector_currentListOfSpeakers_reference']) reference_projector = Projector.objects.get(
is_reference_projector = collection_element == CollectionElement.from_values( pk=config['projector_currentListOfSpeakers_reference'])
reference_projector.get_collection_string(), except Projector.DoesNotExist:
reference_projector.pk) # Reference projector was deleted so this projector element is empty.
is_config = ( # Skip appending more stuff to output.
collection_element.collection_string == 'core/config' and pass
collection_element.information.get('changed_config') == 'projector_currentListOfSpeakers_reference')
if is_reference_projector or is_config:
output.extend(self.get_requirements_as_collection_elements(config_entry))
else: else:
items = self.get_agenda_items(reference_projector) is_reference_projector = collection_element == CollectionElement.from_values(
for item in items: reference_projector.get_collection_string(),
if collection_element == CollectionElement.from_values(item.get_collection_string(), item.pk): reference_projector.pk)
output.extend(self.get_requirements_as_collection_elements(config_entry)) is_config = (
break collection_element.collection_string == 'core/config' and
collection_element.information.get('changed_config') == 'projector_currentListOfSpeakers_reference')
if is_reference_projector or is_config:
output.extend(self.get_requirements_as_collection_elements(config_entry))
else:
items = self.get_agenda_items(reference_projector)
for item in items:
if collection_element == CollectionElement.from_values(item.get_collection_string(), item.pk):
output.extend(self.get_requirements_as_collection_elements(config_entry))
break
return output return output