Supported server side setup of new agenda items (type and parent).

This commit is contained in:
Norman Jäckel 2017-08-03 15:49:14 +02:00
parent b5157cd418
commit 4a78298f94
6 changed files with 37 additions and 7 deletions

View File

@ -12,6 +12,7 @@ Agenda:
- Fixed wrong sorting of last speakers [#3193].
- Fixed issue when sorting a new inserted speaker [#3210].
- New permission for managing lists of speakers [#3366].
- Fixed multiple request on creation of agenda related items [#3341].
Motions:
- New export dialog [#3185].

View File

@ -14,16 +14,25 @@ def listen_to_related_object_post_save(sender, instance, created, **kwargs):
Receiver function to create agenda items. It is connected to the signal
django.db.models.signals.post_save during app loading.
Do not run caching and autoupdate if the instance as an attribute
skip_autoupdate (regardless of its truthy or falsy conent).
The agenda_item_update_information container may have fields like type,
parent or skip_autoupdate.
Do not run caching and autoupdate if the instance as a key
skip_autoupdate in the agenda_item_update_information container.
"""
if hasattr(instance, 'get_agenda_title'):
if created:
attrs = {}
if instance.agenda_item_update_information.get('type'):
attrs['type'] = instance.agenda_item_update_information.get('type')
if instance.agenda_item_update_information.get('parent'):
attrs['parent'] = instance.agenda_item_update_information.get('parent')
Item.objects.create(content_object=instance, **attrs)
# If the object is created, the related_object has to be sent again.
Item.objects.create(content_object=instance)
if not hasattr(instance, 'skip_autoupdate'):
if not instance.agenda_item_update_information.get('skip_autoupdate'):
inform_changed_data(instance)
elif not hasattr(instance, 'skip_autoupdate'):
elif not instance.agenda_item_update_information.get('skip_autoupdate'):
# If the object has changed, then also the agenda item has to be sent.
inform_changed_data(instance.agenda_item)

View File

@ -330,6 +330,11 @@ class Assignment(RESTModelMixin, models.Model):
vote_results_dict[candidate].append(votes)
return vote_results_dict
"""
Container for runtime information for agenda app (on create or update of this instance).
"""
agenda_item_update_information = {}
def get_agenda_title(self):
return str(self)

View File

@ -628,6 +628,11 @@ class Motion(RESTModelMixin, models.Model):
if self.recommendation is not None:
self.set_state(self.recommendation)
"""
Container for runtime information for agenda app (on create or update of this instance).
"""
agenda_item_update_information = {}
def get_agenda_title(self):
"""
Return a simple title string for the agenda.
@ -895,6 +900,11 @@ class MotionBlock(RESTModelMixin, models.Model):
id=self.pk)
return super().delete(skip_autoupdate=skip_autoupdate, *args, **kwargs) # type: ignore
"""
Container for runtime information for agenda app (on create or update of this instance).
"""
agenda_item_update_information = {}
@property
def agenda_item(self):
"""

View File

@ -596,7 +596,7 @@ class CategoryViewSet(ModelViewSet):
# Remove old identifiers
for motion in motions:
motion.identifier = None
motion.skip_autoupdate = True # This line is to skip agenda item autoupdate. See agenda/signals.py.
motion.agenda_item_update_information['skip_autoupdate'] = True # This line is to skip agenda item autoupdate. See agenda/signals.py.
motion.save(skip_autoupdate=True)
# Set new identifers and change identifiers of amendments.
@ -615,7 +615,7 @@ class CategoryViewSet(ModelViewSet):
obj['new_identifier'],
child.identifier,
count=1)
child.skip_autoupdate = True # This line is to skip agenda item autoupdate. See agenda/signals.py.
child.agenda_item_update_information['skip_autoupdate'] = True # This line is to skip agenda item autoupdate. See agenda/signals.py.
child.save(skip_autoupdate=True)
instances.append(child)
instances.append(child.agenda_item)

View File

@ -54,6 +54,11 @@ class Topic(RESTModelMixin, models.Model):
id=self.pk)
return super().delete(skip_autoupdate=skip_autoupdate, *args, **kwargs) # type: ignore
"""
Container for runtime information for agenda app (on create or update of this instance).
"""
agenda_item_update_information = {}
@property
def agenda_item(self):
"""