diff --git a/citadel/MANIFEST.in b/citadel/MANIFEST.in
index e6902c6..a34f1da 100644
--- a/citadel/MANIFEST.in
+++ b/citadel/MANIFEST.in
@@ -1,4 +1,5 @@
graft indico_citadel/migrations
+graft indico_citadel/templates
graft indico_citadel/translations
global-exclude *.pyc __pycache__ .keep
diff --git a/citadel/README.md b/citadel/README.md
index d4ee838..6e44c46 100644
--- a/citadel/README.md
+++ b/citadel/README.md
@@ -9,6 +9,8 @@ to provide advanced search functionality using an Elasticsearch backend.
- Adapt to Indico 3.3 changes
- Support Python 3.12
+- Add option to show a warning in large categories, encourating managers to use groups instead of
+ individual ACL entries (to avoid having to re-send huge amounts of data to the backend)
### 3.2.2
diff --git a/citadel/indico_citadel/plugin.py b/citadel/indico_citadel/plugin.py
index cdd506c..f9acb18 100644
--- a/citadel/indico_citadel/plugin.py
+++ b/citadel/indico_citadel/plugin.py
@@ -5,6 +5,7 @@
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.
+from flask_pluginengine.plugin import render_plugin_template
from wtforms.fields import BooleanField, IntegerField, URLField
from wtforms.validators import URL, DataRequired, NumberRange
@@ -51,6 +52,13 @@ class CitadelSettingsForm(IndicoForm):
'is used, the internal Indico search interface will be used. This may '
'be useful when you are still running a larger initial export and do '
'not want people to get incomplete search results during that time.'))
+ large_category_warning_threshold = IntegerField(_('Large Category Warning Threshold'),
+ [NumberRange(min=0)],
+ description=_('Displays a warning to category managers when '
+ 'changing the ACL of big categories that would '
+ 'result in sending a large amount of data to '
+ 'the Citadel server. You can set the threshold '
+ 'to 0 to suppress this warning.'))
class CitadelPlugin(LiveSyncPluginBase):
@@ -75,6 +83,7 @@ class CitadelPlugin(LiveSyncPluginBase):
'num_threads_files': 5,
'num_threads_files_initial': 25,
'disable_search': False,
+ 'large_category_warning_threshold': 0,
}
backend_classes = {'citadel': LiveSyncCitadelBackend}
@@ -82,6 +91,7 @@ class CitadelPlugin(LiveSyncPluginBase):
super().init()
self.connect(signals.core.get_search_providers, self.get_search_providers)
self.connect(signals.plugin.cli, self._extend_indico_cli)
+ self.template_hook('category-protection-page', self._check_event_categories)
def get_search_providers(self, sender, **kwargs):
from indico_citadel.search import CitadelProvider
@@ -89,3 +99,8 @@ class CitadelPlugin(LiveSyncPluginBase):
def _extend_indico_cli(self, sender, **kwargs):
return cli
+
+ def _check_event_categories(self, category):
+ threshold = self.settings.get('large_category_warning_threshold')
+ if threshold and category.deep_events_count > threshold:
+ return render_plugin_template('event_category_warning.html')
diff --git a/citadel/indico_citadel/templates/event_category_warning.html b/citadel/indico_citadel/templates/event_category_warning.html
new file mode 100644
index 0000000..a8e4720
--- /dev/null
+++ b/citadel/indico_citadel/templates/event_category_warning.html
@@ -0,0 +1,10 @@
+{% from 'message_box.html' import message_box %}
+
+{% call message_box('warning', large_icon=true, fixed_width=true) %}
+ {% trans %}This category contains a large number of events.{% endtrans %}
+
+ {% trans -%}
+ Please consider using groups instead of individual users when granting access or management permissions
+ since any change to the list below requires re-synchronizing all events with Indico's search engine.
+ {%- endtrans %}
+{% endcall %}