<commit_before># This file is part of the Indico plugins.
# Copyright (C) 2020 CERN and ENEA
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.

from __future__ import unicode_literals

from flask import flash, session
from markupsafe import escape
from requests.exceptions import HTTPError
from sqlalchemy.orm.attributes import flag_modified
from werkzeug.exceptions import Forbidden, NotFound
from wtforms.fields.core import BooleanField
from wtforms.fields import TextAreaField
from wtforms.fields.simple import StringField
from wtforms.validators import DataRequired, ValidationError

from indico.core import signals
from indico.core.auth import multipass
from indico.core.plugins import IndicoPlugin, render_plugin_template, url_for_plugin
from indico.modules.events.views import WPSimpleEventDisplay
from indico.modules.vc import VCPluginMixin, VCPluginSettingsFormBase
from indico.modules.vc.exceptions import VCRoomError
from indico.modules.vc.models.vc_rooms import VCRoom
from indico.modules.vc.views import WPVCEventPage, WPVCManageEvent
from indico.util.user import principal_from_identifier
from indico.web.forms.fields import IndicoEnumSelectField, IndicoPasswordField, TextListField
from indico.web.forms.validators import HiddenUnless
from indico.web.forms.widgets import CKEditorWidget, SwitchWidget

from indico_vc_zoom import _
from indico_vc_zoom.api import ZoomIndicoClient
from indico_vc_zoom.blueprint import blueprint
from indico_vc_zoom.cli import cli
from indico_vc_zoom.forms import VCRoomAttachForm, VCRoomForm
from indico_vc_zoom.notifications import notify_new_host, notify_host_start_url
from indico_vc_zoom.util import (UserLookupMode, fetch_zoom_meeting, find_enterprise_email, gen_random_password,
                                 get_schedule_args, get_url_data_args, update_zoom_meeting, ZoomMeetingType)


class PluginSettingsForm(VCPluginSettingsFormBase):
    _fieldsets = [
        ('API Credentials', ['api_key', 'api_secret', 'webhook_token']),
        ('Zoom Account', ['user_lookup_mode', 'email_domains', 'authenticators', 'enterprise_domain', 'assistant_id',
                          'allow_webinars']),
        ('Room Settings', ['mute_audio', 'mute_host_video', 'mute_participant_video', 'join_before_host',
                           'waiting_room']),
        ('Notifications', ['creation_email_footer', 'send_host_url'])
    ]

    api_key = StringField(_('API Key'), [DataRequired()])

    api_secret = IndicoPasswordField(_('API Secret'), [DataRequired()], toggle=True)

    webhook_token = IndicoPasswordField(_('Webhook Token'), toggle=True,
                                        description=_("Specify Zoom's webhook token if you want live updates"))

    user_lookup_mode = IndicoEnumSelectField(_('User lookup mode'), [DataRequired()], enum=UserLookupMode,
                                             description=_('Specify how Indico should look up the zoom user that '
                                                           'corresponds to an Indico user.'))

    email_domains = TextListField(_('E-mail domains'),
                                  [HiddenUnless('user_lookup_mode', UserLookupMode.email_domains), DataRequired()],
                                  description=_('List of e-mail domains which can use the Zoom API. Indico attempts '
                                                'to find Zoom accounts using all email addresses of a user which use '
                                                'those domains.'))

    authenticators = TextListField(_('Indico identity providers'),
                                   [HiddenUnless('user_lookup_mode', UserLookupMode.authenticators), DataRequired()],
                                   description=_('Identity providers from which to get usernames. '
                                                 'Indico queries those providers using the email addresses of the user '
                                                 'and attempts to find Zoom accounts having an email address looking '
                                                 'like <username>@<enterprise-domain>.'))

    enterprise_domain = StringField(_('Enterprise domain'),
                                    [HiddenUnless('user_lookup_mode', UserLookupMode.authenticators), DataRequired()],
                                    description=_('The domain name used together with the usernames from the Indico '
                                                  'identity provider'))

    assistant_id = StringField(_('Assistant Zoom ID'), [DataRequired()],
                               description=_('Account to be used as owner of all rooms. It will get "assistant" '<commit_msg>VC/Zoom: Fix form field description<commit_after># This file is part of the Indico plugins.
# Copyright (C) 2020 CERN and ENEA
#
# The Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.

from __future__ import unicode_literals

from flask import flash, session
from markupsafe import escape
from requests.exceptions import HTTPError
from sqlalchemy.orm.attributes import flag_modified
from werkzeug.exceptions import Forbidden, NotFound
from wtforms.fields.core import BooleanField
from wtforms.fields import TextAreaField
from wtforms.fields.simple import StringField
from wtforms.validators import DataRequired, ValidationError

from indico.core import signals
from indico.core.auth import multipass
from indico.core.plugins import IndicoPlugin, render_plugin_template, url_for_plugin
from indico.modules.events.views import WPSimpleEventDisplay
from indico.modules.vc import VCPluginMixin, VCPluginSettingsFormBase
from indico.modules.vc.exceptions import VCRoomError
from indico.modules.vc.models.vc_rooms import VCRoom
from indico.modules.vc.views import WPVCEventPage, WPVCManageEvent
from indico.util.user import principal_from_identifier
from indico.web.forms.fields import IndicoEnumSelectField, IndicoPasswordField, TextListField
from indico.web.forms.validators import HiddenUnless
from indico.web.forms.widgets import CKEditorWidget, SwitchWidget

from indico_vc_zoom import _
from indico_vc_zoom.api import ZoomIndicoClient
from indico_vc_zoom.blueprint import blueprint
from indico_vc_zoom.cli import cli
from indico_vc_zoom.forms import VCRoomAttachForm, VCRoomForm
from indico_vc_zoom.notifications import notify_new_host, notify_host_start_url
from indico_vc_zoom.util import (UserLookupMode, fetch_zoom_meeting, find_enterprise_email, gen_random_password,
                                 get_schedule_args, get_url_data_args, update_zoom_meeting, ZoomMeetingType)


class PluginSettingsForm(VCPluginSettingsFormBase):
    _fieldsets = [
        ('API Credentials', ['api_key', 'api_secret', 'webhook_token']),
        ('Zoom Account', ['user_lookup_mode', 'email_domains', 'authenticators', 'enterprise_domain', 'assistant_id',
                          'allow_webinars']),
        ('Room Settings', ['mute_audio', 'mute_host_video', 'mute_participant_video', 'join_before_host',
                           'waiting_room']),
        ('Notifications', ['creation_email_footer', 'send_host_url'])
    ]

    api_key = StringField(_('API Key'), [DataRequired()])

    api_secret = IndicoPasswordField(_('API Secret'), [DataRequired()], toggle=True)

    webhook_token = IndicoPasswordField(_('Webhook Token'), toggle=True,
                                        description=_("Specify Zoom's webhook token if you want live updates"))

    user_lookup_mode = IndicoEnumSelectField(_('User lookup mode'), [DataRequired()], enum=UserLookupMode,
                                             description=_('Specify how Indico should look up the zoom user that '
                                                           'corresponds to an Indico user.'))

    email_domains = TextListField(_('E-mail domains'),
                                  [HiddenUnless('user_lookup_mode', UserLookupMode.email_domains), DataRequired()],
                                  description=_('List of e-mail domains which can use the Zoom API. Indico attempts '
                                                'to find Zoom accounts using all email addresses of a user which use '
                                                'those domains.'))

    authenticators = TextListField(_('Indico identity providers'),
                                   [HiddenUnless('user_lookup_mode', UserLookupMode.authenticators), DataRequired()],
                                   description=_('Identity providers from which to get usernames. '
                                                 'Indico queries those providers using the email addresses of the user '
                                                 'and attempts to find Zoom accounts having an email address with the '
                                                 'format username@enterprise-domain.'))

    enterprise_domain = StringField(_('Enterprise domain'),
                                    [HiddenUnless('user_lookup_mode', UserLookupMode.authenticators), DataRequired()],
                                    description=_('The domain name used together with the usernames from the Indico '
                                                  'identity provider'))

    assistant_id = StringField(_('Assistant Zoom ID'), [DataRequired()],
                               description=_('Account to be used as owner of all rooms. It will get "assistant" '
{'fraction_non_alphanumeric': 0.0721038961038961, 'fraction_numerical': 0.0008311688311688312, 'mean_word_length': 2.723791102514507, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7638107', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2323, 'n_words': 711}