<commit_before># This file is part of Indico.
# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Indico is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

from flask import request, redirect, flash, session
from werkzeug.exceptions import BadRequest, NotFound

from indico.core import signals
from indico.core.db.sqlalchemy.principals import PrincipalType
from indico.core.roles import check_roles, ManagementRole, get_available_roles
from indico.modules.events.logs import EventLogRealm, EventLogKind
from indico.modules.events.models.events import Event
from indico.modules.events.models.legacy_mapping import LegacyEventMapping
from indico.modules.events.models.settings import EventSetting, EventSettingPrincipal
from indico.modules.events.util import notify_pending
from indico.util.i18n import _, ngettext, orig_string
from indico.util.string import is_legacy_id
from indico.web.flask.util import url_for


__all__ = ('Event', 'event_management_object_url_prefixes', 'event_object_url_prefixes')

#: URL prefixes for the various event objects (public area)
#: All prefixes are expected to be used inside the '/event/<confId>'
#: url space.
event_object_url_prefixes = {
    'event': [''],
    'session': ['/session/<sessionId>'],
    'contribution': ['/session/<sessionId>/contribution/<contribId>', '/contribution/<contribId>'],
    'subcontribution': ['/session/<sessionId>/contribution/<contribId>/<subContId>',
                        '/contribution/<contribId>/<subContId>']
}

#: URL prefixes for the various event objects (management area)
#: All prefixes are expected to be used inside the '/event/<confId>'
#: url space.
event_management_object_url_prefixes = {
    'event': ['/manage'],
    'session': ['/manage/session/<sessionId>'],
    'contribution': ['/manage/session/<sessionId>/contribution/<contribId>', '/manage/contribution/<contribId>'],
    'subcontribution': ['/manage/session/<sessionId>/contribution/<contribId>/subcontribution/<subContId>',
                        '/manage/contribution/<contribId>/subcontribution/<subContId>']
}


@signals.event.deleted.connect
def _event_deleted(event, **kwargs):
    event.as_event.is_deleted = True


@signals.users.merged.connect
def _merge_users(target, source, **kwargs):<commit_msg>Log ZODB OID on event deletion<commit_after># This file is part of Indico.
# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Indico is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

from flask import request, redirect, flash, session
from werkzeug.exceptions import BadRequest, NotFound

from indico.core import signals
from indico.core.db.sqlalchemy.principals import PrincipalType
from indico.core.logger import Logger
from indico.core.roles import check_roles, ManagementRole, get_available_roles
from indico.modules.events.logs import EventLogRealm, EventLogKind
from indico.modules.events.models.events import Event
from indico.modules.events.models.legacy_mapping import LegacyEventMapping
from indico.modules.events.models.settings import EventSetting, EventSettingPrincipal
from indico.modules.events.util import notify_pending
from indico.util.i18n import _, ngettext, orig_string
from indico.util.string import is_legacy_id
from indico.web.flask.util import url_for


__all__ = ('Event', 'logger', 'event_management_object_url_prefixes', 'event_object_url_prefixes')
logger = Logger.get('events')

#: URL prefixes for the various event objects (public area)
#: All prefixes are expected to be used inside the '/event/<confId>'
#: url space.
event_object_url_prefixes = {
    'event': [''],
    'session': ['/session/<sessionId>'],
    'contribution': ['/session/<sessionId>/contribution/<contribId>', '/contribution/<contribId>'],
    'subcontribution': ['/session/<sessionId>/contribution/<contribId>/<subContId>',
                        '/contribution/<contribId>/<subContId>']
}

#: URL prefixes for the various event objects (management area)
#: All prefixes are expected to be used inside the '/event/<confId>'
#: url space.
event_management_object_url_prefixes = {
    'event': ['/manage'],
    'session': ['/manage/session/<sessionId>'],
    'contribution': ['/manage/session/<sessionId>/contribution/<contribId>', '/manage/contribution/<contribId>'],
    'subcontribution': ['/manage/session/<sessionId>/contribution/<contribId>/subcontribution/<subContId>',
                        '/manage/contribution/<contribId>/subcontribution/<subContId>']
}


@signals.event.deleted.connect
def _event_deleted(event, **kwargs):
    event.as_event.is_deleted = True
    logger.info('Event %s deleted. ZODB OID: %r', event.as_event, event._p_oid)


@signals.users.merged.connect
def _merge_users(target, source, **kwargs):
{'fraction_non_alphanumeric': 0.10896250210190012, 'fraction_numerical': 0.0036993442071632755, 'mean_word_length': 4.953953953953954, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7299448', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1708, 'n_words': 531}