Implemented need_full_update check. Fixed #2396.
This commit is contained in:
parent
53ac7c2348
commit
dc404d21f6
@ -59,3 +59,8 @@ class ListOfSpeakersSlide(ProjectorElement):
|
|||||||
for speaker in query:
|
for speaker in query:
|
||||||
# Yield last speakers
|
# Yield last speakers
|
||||||
yield speaker.user
|
yield speaker.user
|
||||||
|
|
||||||
|
def need_full_update_for_this(self, collection_element):
|
||||||
|
# Full update if item changes because then we may have new speakers
|
||||||
|
# and therefor need new users.
|
||||||
|
return collection_element.collection_string == Item.get_collection_string()
|
||||||
|
@ -23,7 +23,16 @@ class AssignmentSlide(ProjectorElement):
|
|||||||
yield assignment
|
yield assignment
|
||||||
yield assignment.agenda_item
|
yield assignment.agenda_item
|
||||||
for user in assignment.related_users.all():
|
for user in assignment.related_users.all():
|
||||||
|
# Yield user instances of current candidates (i. e. future
|
||||||
|
# poll participants) and elected persons (i. e. former poll
|
||||||
|
# participants).
|
||||||
yield user
|
yield user
|
||||||
for poll in assignment.polls.all().prefetch_related('options'):
|
for poll in assignment.polls.all().prefetch_related('options'):
|
||||||
|
# Yield user instances of the participants of all polls.
|
||||||
for option in poll.options.all():
|
for option in poll.options.all():
|
||||||
yield option.candidate
|
yield option.candidate
|
||||||
|
|
||||||
|
def need_full_update_for_this(self, collection_element):
|
||||||
|
# Full update if assignment changes because then we may have new
|
||||||
|
# candidates and therefor need new users.
|
||||||
|
return collection_element.collection_string == Assignment.get_collection_string()
|
||||||
|
@ -128,8 +128,8 @@ class Projector(RESTModelMixin, models.Model):
|
|||||||
Returns True if this collection element is shown on this projector.
|
Returns True if this collection element is shown on this projector.
|
||||||
"""
|
"""
|
||||||
for requirement in self.get_all_requirements():
|
for requirement in self.get_all_requirements():
|
||||||
if (requirement.get_collection_string() == collection_element['collection_string'] and
|
if (requirement.get_collection_string() == collection_element.collection_string and
|
||||||
requirement.pk == collection_element['id']):
|
requirement.pk == collection_element.id):
|
||||||
result = True
|
result = True
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@ -147,9 +147,26 @@ class Projector(RESTModelMixin, models.Model):
|
|||||||
result.append(projector)
|
result.append(projector)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def need_full_update_for(self, collection_element):
|
def need_full_update_for_this(self, collection_element):
|
||||||
# TODO: Implement this for all ProjectorElements (also for config values!)
|
"""
|
||||||
return True
|
Returns True if this projector needs to be updated with all
|
||||||
|
instances as defined in get_all_requirements() because one active
|
||||||
|
projector element requires this.
|
||||||
|
"""
|
||||||
|
# Get all elements from all apps.
|
||||||
|
elements = {}
|
||||||
|
for element in ProjectorElement.get_all():
|
||||||
|
elements[element.name] = element
|
||||||
|
|
||||||
|
for key, value in self.config.items():
|
||||||
|
element = elements.get(value['name'])
|
||||||
|
if element is not None and element.need_full_update_for_this(collection_element):
|
||||||
|
result = True
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
result = False
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Tag(RESTModelMixin, models.Model):
|
class Tag(RESTModelMixin, models.Model):
|
||||||
|
@ -25,3 +25,11 @@ class MotionSlide(ProjectorElement):
|
|||||||
yield motion.state.workflow
|
yield motion.state.workflow
|
||||||
yield from motion.submitters.all()
|
yield from motion.submitters.all()
|
||||||
yield from motion.supporters.all()
|
yield from motion.supporters.all()
|
||||||
|
|
||||||
|
def need_full_update_for_this(self, collection_element):
|
||||||
|
# Full update if motion changes because then we may have new
|
||||||
|
# submitters or supporters and therefor need new users.
|
||||||
|
#
|
||||||
|
# Add some logic here if we support live changing of workflows later.
|
||||||
|
#
|
||||||
|
return collection_element.collection_string == Motion.get_collection_string()
|
||||||
|
@ -135,12 +135,12 @@ def send_data(message):
|
|||||||
send_all = False
|
send_all = False
|
||||||
else:
|
else:
|
||||||
# Other elements are only send to the projector they are currently shown
|
# Other elements are only send to the projector they are currently shown
|
||||||
projectors = Projector.get_projectors_that_show_this(message)
|
projectors = Projector.get_projectors_that_show_this(collection_element)
|
||||||
send_all = None # The decission is done later
|
send_all = None # The decission is done later
|
||||||
|
|
||||||
for projector in projectors:
|
for projector in projectors:
|
||||||
if send_all is None:
|
if send_all is None:
|
||||||
send_all = projector.need_full_update_for(message)
|
send_all = projector.need_full_update_for_this(collection_element)
|
||||||
if send_all:
|
if send_all:
|
||||||
output = get_projector_element_data(projector)
|
output = get_projector_element_data(projector)
|
||||||
else:
|
else:
|
||||||
|
@ -72,3 +72,12 @@ class ProjectorElement(object, metaclass=SignalConnectMetaClass):
|
|||||||
element. The config_entry has to be given.
|
element. The config_entry has to be given.
|
||||||
"""
|
"""
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
def need_full_update_for_this(self, collection_element):
|
||||||
|
"""
|
||||||
|
Returns True if this projector element needs to be updated with all
|
||||||
|
instances as defined in get_requirements(). The given
|
||||||
|
collection_element contains information about the changed instance.
|
||||||
|
Default is False.
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user