def _make_form(self): form_class = type('FeaturesForm', (IndicoForm,), {}) disallowed = get_disallowed_features(self.event) for name, feature in sorted(get_feature_definitions().items(), key=lambda x: x[1].friendly_name): if name in disallowed: continue field = BooleanField(feature.friendly_name, widget=SwitchWidget(), description=feature.description) setattr(form_class, name, field) defaults = {name: True for name in get_enabled_features(self.event)} return form_class(csrf_enabled=False, obj=FormDefaults(defaults))
def _make_form(self): form_class = type(b'FeaturesForm', (IndicoForm,), {}) disallowed = get_disallowed_features(self.event) for name, feature in sorted(get_feature_definitions().iteritems(), key=lambda x: x[1].friendly_name): if name in disallowed: continue field = BooleanField(feature.friendly_name, widget=SwitchWidget(on_label=_('On'), off_label=_('Off')), description=feature.description) setattr(form_class, name, field) defaults = {name: True for name in get_enabled_features(self.event)} return form_class(csrf_enabled=False, obj=FormDefaults(defaults))
def _event_type_changed(event, **kwargs): from indico.modules.events.features.util import (format_feature_names, get_disallowed_features, get_enabled_features, set_feature_enabled) conflicting = get_enabled_features(event, only_explicit=True) & get_disallowed_features(event) if conflicting: for feature in conflicting: set_feature_enabled(event, feature, False) # XXX: we cannot flash a message in the legacy js ajax editor for the event type. # remove this check once we don't use it anymore (on the general settings page) flash(ngettext('Feature disabled: {features} (not available for this event type)', 'Features disabled: {features} (not available for this event type)', len(conflicting)) .format(features=format_feature_names(conflicting)), 'warning')
def _event_type_changed(event, **kwargs): from indico.modules.events.features.util import (get_enabled_features, get_disallowed_features, set_feature_enabled, format_feature_names) conflicting = get_enabled_features(event, only_explicit=True) & get_disallowed_features(event) if conflicting: for feature in conflicting: set_feature_enabled(event, feature, False) if request.endpoint != 'api.jsonrpc': # XXX: we cannot flash a message in the legacy js ajax editor for the event type. # remove this check once we don't use it anymore (on the general settings page) flash(ngettext('Feature disabled: {features} (not available for this event type)', 'Features disabled: {features} (not available for this event type)', len(conflicting)) .format(features=format_feature_names(conflicting)), 'warning')
def _process_PUT(self): prev = get_enabled_features(self.event) feature = get_feature_definition(request.view_args['feature']) if feature.name in get_disallowed_features(self.event): raise Forbidden('Feature not available') changed = set() if set_feature_enabled(self.event, feature.name, True): current = get_enabled_features(self.event) changed = current - prev flash(ngettext('Feature enabled: {features}', 'Features enabled: {features}', len(changed)) .format(features=format_feature_names(changed)), 'success') logger.info("Feature '%s' for event %s enabled by %s", feature.name, self.event, session.user) self.event.log(EventLogRealm.management, EventLogKind.positive, 'Features', 'Enabled {}'.format(feature.friendly_name), session.user) return jsonify_data(enabled=True, event_menu=self.render_event_menu(), changed=list(changed))
def _process_PUT(self): prev = get_enabled_features(self.event) feature = get_feature_definition(request.view_args['feature']) if feature.name in get_disallowed_features(self.event): raise Forbidden('Feature not available') changed = set() if set_feature_enabled(self.event, feature.name, True): current = get_enabled_features(self.event) changed = current - prev flash(ngettext('Feature enabled: {features}', 'Features enabled: {features}', len(changed)) .format(features=format_feature_names(changed)), 'success') logger.info("Feature '%s' for event %s enabled by %s", feature.name, self.event, session.user) self.event.log(EventLogRealm.management, EventLogKind.positive, 'Features', f'Enabled {feature.friendly_name}', session.user) return jsonify_data(enabled=True, event_menu=self.render_event_menu(), changed=list(changed))