Skip to content

Commit

Permalink
Citadel: Improve error message
Browse files Browse the repository at this point in the history
and apply changes from review
  • Loading branch information
GovernmentPlates committed Feb 12, 2024
1 parent 9eaea4a commit 4300296
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
11 changes: 9 additions & 2 deletions citadel/indico_citadel/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -18,7 +19,6 @@
from indico_citadel.backend import LiveSyncCitadelBackend
from indico_citadel.cli import cli
from indico_livesync import LiveSyncPluginBase
from indico_citadel.util import check_event_categories


class CitadelSettingsForm(IndicoForm):
Expand Down Expand Up @@ -90,11 +90,18 @@ def init(self):
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', check_event_categories)
self.template_hook('category-protection-page', self.check_event_categories)

def get_search_providers(self, sender, **kwargs):
from indico_citadel.search import CitadelProvider
return CitadelProvider

def _extend_indico_cli(self, sender, **kwargs):
return cli

def check_event_categories(self, category):
threshold = self.settings.get('large_category_warning_threshold')
num_events = category.deep_events_count

if threshold and num_events > threshold:
return render_plugin_template('event_category_warning.html')
7 changes: 4 additions & 3 deletions citadel/indico_citadel/templates/event_category_warning.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% from 'message_box.html' import message_box %}

{% call message_box('warning', large_icon=true, fixed_width=true) %}
{% trans category_title=category.title, max_events_threshold=threshold -%}
<b>The '{{ category_title }}' category contains over {{ max_events_threshold }} events - this may cause performance issues.</b>
{% trans -%}
<b>This category contains a large number of events.</b>
<br/>
Please consider using groups instead of individual users to avoid having to re-send large amounts of changes to users individually.
Please consider using groups instead of individual users when granting access or management privileges
since any change to the access control list requires re-synchronizing all events with Indico's search engine.
{%- endtrans %}
{% endcall %}
11 changes: 0 additions & 11 deletions citadel/indico_citadel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from flask import current_app
from flask.globals import _cv_app
from flask_pluginengine.plugin import render_plugin_template

from indico.core.db import db
from indico.core.db.sqlalchemy.principals import PrincipalMixin, PrincipalPermissionsMixin, PrincipalType
Expand Down Expand Up @@ -216,13 +215,3 @@ def get_user_access(user, admin_override_enabled=False):
for x in user.iter_all_multipass_groups()]
access += _include_capitalized_groups(multipass_groups)
return access


def check_event_categories(category):
from indico_citadel.plugin import CitadelPlugin

threshold = CitadelPlugin.settings.get('large_category_warning_threshold')
num_events = category.deep_events_count

if threshold and num_events > threshold:
return render_plugin_template('event_category_warning.html', category=category, threshold=threshold)

0 comments on commit 4300296

Please sign in to comment.