LiveSync: Correctly handle unlisted events (#156)

This commit is contained in:
Javier Ferrer 2021-09-24 15:44:54 +02:00 committed by GitHub
parent 4b7a777407
commit cf8cd5eb41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 9 deletions

View File

@ -91,17 +91,21 @@ def _is_category_excluded(category):
def _moved(obj, old_parent, **kwargs):
_register_change(obj, ChangeType.moved)
# if an unlisted event is moved, it triggers a creation instead
if isinstance(obj, Event) and old_parent is None:
_register_change(obj, ChangeType.created)
else:
_register_change(obj, ChangeType.moved)
new_category = obj if isinstance(obj, Category) else obj.category
old_excluded = _is_category_excluded(old_parent)
new_excluded = _is_category_excluded(new_category)
if old_excluded != new_excluded:
_register_change(obj, ChangeType.unpublished if new_excluded else ChangeType.published)
new_category = obj if isinstance(obj, Category) else obj.category
old_excluded = _is_category_excluded(old_parent) if old_parent else False
new_excluded = _is_category_excluded(new_category)
if old_excluded != new_excluded:
_register_change(obj, ChangeType.unpublished if new_excluded else ChangeType.published)
if obj.is_inheriting:
# If protection is inherited, check whether it changed
category_protection = old_parent.effective_protection_mode
category_protection = old_parent.effective_protection_mode if old_parent else None
new_category_protection = obj.protection_parent.effective_protection_mode
# Protection of new parent is different
if category_protection != new_category_protection:

View File

@ -286,6 +286,8 @@ class LiveSyncQueueEntry(db.Model):
return
else:
event = obj.folder.event if isinstance(obj, Attachment) else obj.event
if event.is_unlisted:
return
if event.category not in g.setdefault('livesync_excluded_categories_checked', {}):
g.livesync_excluded_categories_checked[event.category] = \
excluded_categories & set(event.category_chain)

View File

@ -1,6 +1,6 @@
[metadata]
name = indico-plugin-livesync
version = 3.0.1
version = 3.1-dev
description = Framework for pushing Indico event data to external services
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8; variant=GFM
@ -20,7 +20,7 @@ zip_safe = false
include_package_data = true
python_requires = ~=3.9.0
install_requires =
indico>=3.0
indico>=3.1.dev0
[options.entry_points]
indico.plugins =