def _process_DELETE(self): setting = self._get_priv_setting() if session_settings.get(self.event_new, setting): session_settings.set(self.event_new, setting, False) self.event_new.log(EventLogRealm.management, EventLogKind.negative, 'Protection', 'Session coordinator privilege revoked: {}'.format(COORDINATOR_PRIV_TITLES[self.priv]), session.user) return jsonify(enabled=False)
def _process_PUT(self): setting = self._get_priv_setting() if not session_settings.get(self.event_new, setting): session_settings.set(self.event_new, setting, True) self.event_new.log(EventLogRealm.management, EventLogKind.positive, 'Protection', 'Session coordinator privilege granted: {}'.format(COORDINATOR_PRIV_TITLES[self.priv]), session.user) return jsonify(enabled=True)
def _update_session_coordinator_privs(self, form): for priv_field in form.priv_fields: try: setting = COORDINATOR_PRIV_SETTINGS[priv_field] except KeyError: raise BadRequest('No such privilege') if session_settings.get(self.event_new, setting) == form.data[priv_field]: continue session_settings.set(self.event_new, setting, form.data[priv_field]) log_msg = 'Session coordinator privilege changed to {}: {}'.format(form.data[priv_field], COORDINATOR_PRIV_TITLES[priv_field]) self.event_new.log(EventLogRealm.management, EventLogKind.positive, 'Protection', log_msg, session.user)
def session_coordinator_priv_enabled(event, priv): """Check whether a coordinator privilege is enabled. Currently the following privileges are available: - manage-contributions - manage-blocks :param event: The `Event` to check for :param priv: The name of the privilege """ from indico.modules.events.sessions import COORDINATOR_PRIV_SETTINGS, session_settings return session_settings.get(event, COORDINATOR_PRIV_SETTINGS[priv])
def update_session_coordinator_privs(event, data): changes = {} for priv, enabled in data.iteritems(): setting = COORDINATOR_PRIV_SETTINGS[priv] if session_settings.get(event, setting) == enabled: continue session_settings.set(event, setting, enabled) changes[priv] = (not enabled, enabled) db.session.flush() logger.info('Session coordinator privs of event %r updated with %r by %r', event, data, session.user) if changes: log_fields = {priv: orig_string(title) for priv, title in COORDINATOR_PRIV_TITLES.iteritems()} event.log(EventLogRealm.management, EventLogKind.change, 'Sessions', 'Coordinator privileges updated', session.user, data={'Changes': make_diff_log(changes, log_fields)})