Пример #1
0
def db_serialize_node(session, tid, language):
    """
    Serialize node info.
    """
    # Contexts and Receivers relationship
    configured = session.query(models.ReceiverContext).filter(models.ReceiverContext.context_id == models.Context.id,
                                                              models.Context.tid == tid).count() > 0

    node = ConfigFactory(session, tid, 'public_node').serialize()

    misc_dict = {
        'languages_enabled': models.EnabledLanguage.list(session, tid) if node['wizard_done'] else list(LANGUAGES_SUPPORTED_CODES),
        'languages_supported': LANGUAGES_SUPPORTED,
        'configured': configured,
        'accept_submissions': State.accept_submissions,
        'logo': db_get_file(session, tid, u'logo'),
        'favicon': db_get_file(session, tid, u'favicon'),
        'css': db_get_file(session, tid, u'css'),
        'homepage': db_get_file(session, tid, u'homepage'),
        'script': db_get_file(session, tid, u'script')
    }

    l10n_dict = NodeL10NFactory(session, tid).localized_dict(language)

    return merge_dicts(node, l10n_dict, misc_dict)
Пример #2
0
def db_serialize_node(session, tid, language):
    """
    Serialize the public node configuration.

    :param session: An ORM session
    :param tid: A tenant ID
    :param language: The language to be used during serialization
    :return: The serialization of the public node configuration
    """
    node_dict = ConfigFactory(session, tid).serialize('public_node')
    l10n_dict = ConfigL10NFactory(
        session,
        tid,
    ).serialize('node', language)

    ret_dict = merge_dicts(node_dict, l10n_dict)

    ret_dict['root_tenant'] = tid == 1
    ret_dict['languages_enabled'] = models.EnabledLanguage.list(
        session,
        tid) if node_dict['wizard_done'] else list(LANGUAGES_SUPPORTED_CODES)
    ret_dict['languages_supported'] = LANGUAGES_SUPPORTED

    records = session.query(models.File.id, models.File.data).filter(
        models.File.tid == tid, models.File.id.in_(['css', 'script']))
    for x in records:
        ret_dict[x[0]] = True

    if tid != 1:
        root_tenant_node = ConfigFactory(session, 1)

        for varname in ['version', 'version_db', 'latest_version']:
            ret_dict[varname] = root_tenant_node.get_val(varname)

        if language not in models.EnabledLanguage.list(session, tid):
            language = root_tenant_node.get_val('default_language')

        root_tenant_l10n = ConfigL10NFactory(session, 1)

        if ret_dict['mode'] != 'default':
            ret_dict['footer'] = root_tenant_l10n.get_val('footer', language)
            ret_dict['whistleblowing_question'] = root_tenant_l10n.get_val(
                'whistleblowing_question', language)
            ret_dict['whistleblowing_button'] = root_tenant_l10n.get_val(
                'whistleblowing_button', language)
            ret_dict['enable_disclaimer'] = root_tenant_node.get_val(
                'enable_disclaimer')
            ret_dict['disclaimer_title'] = root_tenant_l10n.get_val(
                'disclaimer_title', language)
            ret_dict['disclaimer_text'] = root_tenant_l10n.get_val(
                'disclaimer_text', language)

            records = session.query(models.File.id, models.File.data).filter(
                models.File.tid == 1, models.File.id.in_(['css', 'script']))
            for x in records:
                if not ret_dict.get(x[0]):
                    ret_dict[x[0]] = True

    return ret_dict
Пример #3
0
def db_serialize_node(session, tid, language):
    """
    Serialize the public node configuration.
    """
    node_dict = ConfigFactory(session, tid).serialize('public_node')
    l10n_dict = ConfigL10NFactory(
        session,
        tid,
    ).serialize('node', language)

    ret_dict = merge_dicts(node_dict, l10n_dict)

    ret_dict['root_tenant'] = tid == 1
    ret_dict['languages_enabled'] = models.EnabledLanguage.list(
        session,
        tid) if node_dict['wizard_done'] else list(LANGUAGES_SUPPORTED_CODES)
    ret_dict['languages_supported'] = LANGUAGES_SUPPORTED

    files = [u'logo', u'favicon', u'css', u'script']
    records = session.query(models.File.id, models.File.data).filter(
        models.File.tid == tid,
        models.File.id.in_([u'logo', u'favicon', u'css', u'script']))
    for x in records:
        ret_dict[x[0]] = x[1] if x[0] == 'logo' else True

    if tid != 1:
        root_tenant_node = ConfigFactory(session, 1)

        for varname in ['version', 'version_db', 'latest_version']:
            ret_dict[varname] = root_tenant_node.get_val(varname)

        if language not in models.EnabledLanguage.list(session, tid):
            language = root_tenant_node.get_val(u'default_language')

        root_tenant_l10n = ConfigL10NFactory(session, 1)

        if ret_dict['mode'] != u'default':
            ret_dict['footer'] = root_tenant_l10n.get_val(u'footer', language)
            ret_dict['whistleblowing_question'] = root_tenant_l10n.get_val(
                u'whistleblowing_question', language)
            ret_dict['whistleblowing_button'] = root_tenant_l10n.get_val(
                u'whistleblowing_button', language)
            ret_dict['enable_disclaimer'] = root_tenant_node.get_val(
                u'enable_disclaimer')
            ret_dict['disclaimer_title'] = root_tenant_l10n.get_val(
                u'disclaimer_title', language)
            ret_dict['disclaimer_text'] = root_tenant_l10n.get_val(
                u'disclaimer_text', language)

            records = session.query(models.File.id, models.File.data).filter(
                models.File.tid == 1,
                models.File.id.in_([u'logo', u'favicon', u'css', u'script']))
            for x in records:
                if not ret_dict[x[0]]:
                    ret_dict[x[0]] = x[1] if x[0] == 'logo' else True

    return ret_dict
Пример #4
0
def db_serialize_node(session, tid, language):
    """
    Serialize node info.
    """
    # Contexts and Receivers relationship
    configured = session.query(models.ReceiverContext).filter(
        models.ReceiverContext.context_id == models.Context.id,
        models.Context.tid == tid).count() > 0

    node_dict = ConfigFactory(session, tid, 'public_node').serialize()
    l10n_dict = NodeL10NFactory(session, tid).localized_dict(language)

    ret_dict = merge_dicts(node_dict, l10n_dict)

    ret_dict['root_tenant'] = tid == 1
    ret_dict['languages_enabled'] = models.EnabledLanguage.list(
        session,
        tid) if node_dict['wizard_done'] else list(LANGUAGES_SUPPORTED_CODES)
    ret_dict['languages_supported'] = LANGUAGES_SUPPORTED
    ret_dict['configured'] = configured
    ret_dict['accept_submissions'] = State.accept_submissions

    ret_dict['logo'] = db_get_file(session, tid, u'logo')
    ret_dict['favicon'] = db_get_file(session, tid, u'favicon')
    ret_dict['css'] = db_get_file(session, tid, u'css')
    ret_dict['script'] = db_get_file(session, tid, u'script')

    if tid != 1:
        root_tenant_node = ConfigFactory(session, 1, 'public_node')

        if language not in models.EnabledLanguage.list(session, tid):
            language = root_tenant_node.get_val(u'default_language')

        for x in [u'logo', u'favicon', u'css', u'scripts']:
            if not ret_dict[x]:
                ret_dict[x] = db_get_file(session, 1, x)

        root_tenant_l10n = NodeL10NFactory(session, tid)

        if not root_tenant_node.get_val(u'enable_footer_customization'):
            ret_dict['footer'] = root_tenant_l10n.get_val(u'footer', language)

        if ret_dict['mode'] == u'whistleblowing.it':
            ret_dict['whistleblowing_question'] = root_tenant_l10n.get_val(
                u'whistleblowing_question', language)
            ret_dict['whistleblowing_button'] = root_tenant_l10n.get_val(
                u'whistleblowing_button', language)
            ret_dict['enable_disclaimer'] = root_tenant_node.get_val(
                u'enable_disclaimer')
            ret_dict['disclaimer_title'] = root_tenant_l10n.get_val(
                u'disclaimer_title', language)
            ret_dict['disclaimer_text'] = root_tenant_l10n.get_val(
                u'disclaimer_text', language)

    return ret_dict
Пример #5
0
def admin_serialize_notification(store, language):
    config_dict = NotificationFactory(store).admin_export()
    conf_l10n_dict = NotificationL10NFactory(store).localized_dict(language)

    cmd_flags = {
        'reset_templates': False,
        'exception_email_pgp_key_remove': False,
        'smtp_password': '',
    }

    return merge_dicts(config_dict, cmd_flags, conf_l10n_dict)
Пример #6
0
def db_serialize_node(session, tid, language):
    """
    Serialize the public node configuration.
    """
    # Contexts and Receivers relationship
    node_dict = ConfigFactory(session, tid).serialize('public_node')
    l10n_dict = ConfigL10NFactory(
        session,
        tid,
    ).serialize('node', language)

    ret_dict = merge_dicts(node_dict, l10n_dict)

    ret_dict['root_tenant'] = tid == 1
    ret_dict['languages_enabled'] = models.EnabledLanguage.list(
        session,
        tid) if node_dict['wizard_done'] else list(LANGUAGES_SUPPORTED_CODES)
    ret_dict['languages_supported'] = LANGUAGES_SUPPORTED

    files = [u'logo', u'favicon', u'css', u'script']
    for x in files:
        ret_dict[x] = db_get_file(session, tid, x)

    if tid != 1:
        root_tenant_node = ConfigFactory(session, 1)

        for varname in ['version', 'version_db', 'latest_version']:
            ret_dict[varname] = root_tenant_node.get_val(varname)

        if language not in models.EnabledLanguage.list(session, tid):
            language = root_tenant_node.get_val(u'default_language')

        root_tenant_l10n = ConfigL10NFactory(session, 1)

        if ret_dict['mode'] == u'whistleblowing.it' or ret_dict[
                'mode'] == u'eat':
            ret_dict['footer'] = root_tenant_l10n.get_val(u'footer', language)
            ret_dict['whistleblowing_question'] = root_tenant_l10n.get_val(
                u'whistleblowing_question', language)
            ret_dict['whistleblowing_button'] = root_tenant_l10n.get_val(
                u'whistleblowing_button', language)
            ret_dict['enable_disclaimer'] = root_tenant_node.get_val(
                u'enable_disclaimer')
            ret_dict['disclaimer_title'] = root_tenant_l10n.get_val(
                u'disclaimer_title', language)
            ret_dict['disclaimer_text'] = root_tenant_l10n.get_val(
                u'disclaimer_text', language)

            for x in files:
                if not ret_dict[x]:
                    ret_dict[x] = db_get_file(session, 1, x)

    return ret_dict
Пример #7
0
def admin_serialize_notification(session, tid, language):
    config_dict = ConfigFactory(session, tid).serialize('admin_notification')

    conf_l10n_dict = ConfigL10NFactory(session,
                                       tid).serialize('notification', language)

    cmd_flags = {
        'reset_templates': False,
        'exception_email_pgp_key_remove': False,
        'smtp_password': '',
    }

    return merge_dicts(config_dict, cmd_flags, conf_l10n_dict)
Пример #8
0
def db_get_notification(session, tid, language):
    """
    Transaction to get the notification settings for the specified tenant

    :param session: An ORM session
    :param tid: A tenant ID
    :param language: The language to be used in the serialization
    :return: the serialization of notification settings for the specified tenant
    """
    config_dict = ConfigFactory(session, tid).serialize('admin_notification')

    conf_l10n_dict = ConfigL10NFactory(session,
                                       tid).serialize('notification', language)

    additional_dict = {
        'smtp_password': '',
        'templates': ConfigL10NFilters['notification']
    }

    return merge_dicts(config_dict, conf_l10n_dict, additional_dict)
Пример #9
0
def db_get_notification(session, tid, language):
    """
    Transaction to get the notification settings for the specified tenant

    :param session: An ORM session
    :param tid: A tenant ID
    :param language: The language to be used in the serialization
    :return: the serialization of notification settings for the specified tenant
    """
    config_dict = ConfigFactory(session, tid).serialize('admin_notification')

    conf_l10n_dict = ConfigL10NFactory(session,
                                       tid).serialize('notification', language)

    cmd_flags = {
        'reset_templates': False,
        'exception_email_pgp_key_remove': False,
        'smtp_password': '',
    }

    return merge_dicts(config_dict, cmd_flags, conf_l10n_dict)
Пример #10
0
def db_serialize_node(session, tid, language):
    """
    Serialize the public node configuration.
    """
    # Contexts and Receivers relationship
    node_dict = ConfigFactory(session, tid).serialize('public_node')
    l10n_dict = ConfigL10NFactory(session, tid,).serialize('node', language)

    ret_dict = merge_dicts(node_dict, l10n_dict)

    ret_dict['root_tenant'] = tid == 1
    ret_dict['languages_enabled'] = models.EnabledLanguage.list(session, tid) if node_dict['wizard_done'] else list(LANGUAGES_SUPPORTED_CODES)
    ret_dict['languages_supported'] = LANGUAGES_SUPPORTED

    files = [u'logo', u'favicon', u'css', u'script']
    for x in files:
        ret_dict[x] = db_get_file(session, tid, x)

    if tid != 1:
        root_tenant_node = ConfigFactory(session, 1)

        if language not in models.EnabledLanguage.list(session, tid):
            language = root_tenant_node.get_val(u'default_language')

        root_tenant_l10n = ConfigL10NFactory(session, 1)

        if ret_dict['mode'] == u'whistleblowing.it' or ret_dict['mode'] == u'eat':
            ret_dict['footer'] = root_tenant_l10n.get_val(u'footer', language)
            ret_dict['whistleblowing_question'] = root_tenant_l10n.get_val(u'whistleblowing_question', language)
            ret_dict['whistleblowing_button'] = root_tenant_l10n.get_val(u'whistleblowing_button', language)
            ret_dict['enable_disclaimer'] = root_tenant_node.get_val(u'enable_disclaimer')
            ret_dict['disclaimer_title'] = root_tenant_l10n.get_val(u'disclaimer_title', language)
            ret_dict['disclaimer_text'] = root_tenant_l10n.get_val(u'disclaimer_text', language)

            for x in files:
                if not ret_dict[x]:
                    ret_dict[x] = db_get_file(session, 1, x)

    return ret_dict
Пример #11
0
def db_serialize_node(session, tid, language):
    """
    Serialize node info.
    """
    # Contexts and Receivers relationship
    configured = session.query(models.ReceiverContext).filter(models.ReceiverContext.context_id == models.Context.id,
                                                              models.Context.tid == tid).count() > 0

    node = ConfigFactory(session, tid, 'public_node').serialize()

    ret_dict = {
        'root_tenant': tid == 1,
        'languages_enabled': models.EnabledLanguage.list(session, tid) if node['wizard_done'] else list(LANGUAGES_SUPPORTED_CODES),
        'languages_supported': LANGUAGES_SUPPORTED,
        'configured': configured,
        'accept_submissions': State.accept_submissions,
        'logo': db_get_file(session, tid, u'logo')
    }

    l10n_dict = NodeL10NFactory(session, tid).localized_dict(language)

    if tid != 1:
        root_tenant_node = ConfigFactory(session, 1, 'public_node')
        ret_dict['enable_footer_customization'] = root_tenant_node.get_val(u'enable_footer_customization')

        if language not in models.EnabledLanguage.list(session, tid):
            language = root_tenant_node.get_val(u'default_language')

        root_tenant_l10n = NodeL10NFactory(session, tid)
        l10n_dict['footer'] = root_tenant_l10n.get_val(u'footer', language)

    ret_dict['favicon'] = ret_dict['css'] = ret_dict['script'] = ''
    if tid == 1 or node['enable_graphic_customization']:
        ret_dict['css'] = db_get_file(session, tid, u'css')
        ret_dict['favicon'] = db_get_file(session, tid, u'favicon')
        ret_dict['script'] = db_get_file(session, tid, u'script')

    return merge_dicts(node, ret_dict, l10n_dict)
Пример #12
0
def db_serialize_node(store, language):
    """
    Serialize node info.
    """
    # Contexts and Receivers relationship
    configured = store.find(models.ReceiverContext).count() > 0

    ro_node = NodeFactory(store).public_export()

    misc_dict = {
        'languages_enabled': l10n.EnabledLanguage.list(store),
        'languages_supported': LANGUAGES_SUPPORTED,
        'configured': configured,
        'accept_submissions': State.accept_submissions,
        'logo': db_get_file(store, u'logo'),
        'favicon': db_get_file(store, u'favicon'),
        'css': db_get_file(store, u'css'),
        'homepage': db_get_file(store, u'homepage'),
        'script': db_get_file(store, u'script')
    }

    l10n_dict = NodeL10NFactory(store).localized_dict(language)

    return merge_dicts(ro_node, l10n_dict, misc_dict)
Пример #13
0
    'backup_remote_server': text_type,
    'backup_remote_port': int,
    'backup_remote_username': text_type,
    'backup_remote_password': text_type
}

AdminNotificationDesc = merge_dicts(
    {
        'smtp_server': text_type,
        'smtp_port': int,
        'smtp_security': text_type,  # 'TLS' or 'SSL' only
        'smtp_authentication': bool,
        'smtp_username': text_type,
        'smtp_password': text_type,
        'smtp_source_name': text_type,
        'smtp_source_email': email_regexp,
        'disable_admin_notification_emails': bool,
        'disable_custodian_notification_emails': bool,
        'disable_receiver_notification_emails': bool,
        'tip_expiration_threshold': int,
        'notification_threshold_per_hour': int,
        'reset_templates': bool
    },
    {k: text_type
     for k in ConfigL10NFilters['notification']})

AdminFieldOptionDesc = {
    'id': uuid_regexp_or_empty,
    'label': text_type,
    'presentation_order': int,
    'score_type': int,
Пример #14
0
    'basic_auth_password': unicode,
    'reachable_via_web': bool,
    'anonymize_outgoing_connections': bool
}

AdminNotificationDesc = merge_dicts({
    'server': unicode,
    'port': int,
    'security': unicode, # 'TLS' or 'SSL' only
    'username': unicode,
    'smtp_password': unicode,
    'source_name': unicode,
    'source_email': email_regexp,
    'disable_admin_notification_emails': bool,
    'disable_custodian_notification_emails': bool,
    'disable_receiver_notification_emails': bool,
    'tip_expiration_threshold': int,
    'notification_threshold_per_hour': int,
    'reset_templates': bool,
    'exception_email_address': email_regexp,
    'exception_email_pgp_key_fingerprint': unicode,
    'exception_email_pgp_key_expiration': unicode,
    'exception_email_pgp_key_public': unicode,
    'exception_email_pgp_key_remove': bool
  },
  {k: unicode for k in NotificationL10NFactory.modifiable_keys}
)

AdminFieldOptionDesc = {
    'id': uuid_regexp_or_empty,
    'label': unicode,
    'presentation_order': int,
Пример #15
0
    'basic_auth_password': unicode,
    'reachable_via_web': bool,
    'anonymize_outgoing_connections': bool,
    'enable_admin_exception_notification': bool,
    'enable_developers_exception_notification': bool
}

AdminNotificationDesc = merge_dicts(
    {
        'smtp_server': unicode,
        'smtp_port': int,
        'smtp_security': unicode,  # 'TLS' or 'SSL' only
        'smtp_username': unicode,
        'smtp_password': unicode,
        'smtp_source_name': unicode,
        'smtp_source_email': email_regexp,
        'disable_admin_notification_emails': bool,
        'disable_custodian_notification_emails': bool,
        'disable_receiver_notification_emails': bool,
        'tip_expiration_threshold': int,
        'notification_threshold_per_hour': int,
        'reset_templates': bool
    },
    {k: unicode
     for k in NotificationL10NFactory.keys})

AdminFieldOptionDesc = {
    'id': uuid_regexp_or_empty,
    'label': unicode,
    'presentation_order': int,
    'score_points': int,
    'trigger_field': uuid_regexp_or_empty
Пример #16
0
    'backup_remote': bool,
    'backup_remote_server': text_type,
    'backup_remote_port': int,
    'backup_remote_username': text_type,
    'backup_remote_password': text_type
}

AdminNotificationDesc = merge_dicts({
    'smtp_server': text_type,
    'smtp_port': int,
    'smtp_security': text_type,  # 'TLS' or 'SSL' only
    'smtp_authentication': bool,
    'smtp_username': text_type,
    'smtp_password': text_type,
    'smtp_source_name': text_type,
    'smtp_source_email': email_regexp,
    'disable_admin_notification_emails': bool,
    'disable_custodian_notification_emails': bool,
    'disable_receiver_notification_emails': bool,
    'tip_expiration_threshold': int,
    'notification_threshold_per_hour': int,
    'reset_templates': bool
  },
  {k: text_type for k in ConfigL10NFilters['notification']}
)

AdminFieldOptionDesc = {
    'id': uuid_regexp_or_empty,
    'label': text_type,
    'hint1': text_type,
    'hint2': text_type,
    'block_submission': bool,