mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
Citadel: Add large-category warning (#222)
This commit is contained in:
parent
a00e1ba013
commit
9f7d6d9338
@ -1,4 +1,5 @@
|
||||
graft indico_citadel/migrations
|
||||
graft indico_citadel/templates
|
||||
graft indico_citadel/translations
|
||||
|
||||
global-exclude *.pyc __pycache__ .keep
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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')
|
||||
|
||||
10
citadel/indico_citadel/templates/event_category_warning.html
Normal file
10
citadel/indico_citadel/templates/event_category_warning.html
Normal file
@ -0,0 +1,10 @@
|
||||
{% from 'message_box.html' import message_box %}
|
||||
|
||||
{% call message_box('warning', large_icon=true, fixed_width=true) %}
|
||||
<strong>{% trans %}This category contains a large number of events.{% endtrans %}</strong>
|
||||
<br>
|
||||
{% 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 %}
|
||||
Loading…
x
Reference in New Issue
Block a user