diff --git a/vc_zoom/indico_vc_zoom/forms.py b/vc_zoom/indico_vc_zoom/forms.py index f4e6ebe..4834e93 100644 --- a/vc_zoom/indico_vc_zoom/forms.py +++ b/vc_zoom/indico_vc_zoom/forms.py @@ -8,7 +8,7 @@ from __future__ import unicode_literals from flask import session -from wtforms.fields.core import BooleanField +from wtforms.fields.core import BooleanField, StringField from wtforms.fields.simple import TextAreaField from wtforms.validators import DataRequired, ValidationError @@ -16,15 +16,15 @@ from indico.modules.vc.forms import VCRoomAttachFormBase, VCRoomFormBase from indico.util.user import principal_from_identifier from indico.web.forms.base import generated_data from indico.web.forms.fields import IndicoRadioField, PrincipalField -from indico.web.forms.validators import HiddenUnless +from indico.web.forms.validators import HiddenUnless, IndicoRegexp from indico.web.forms.widgets import SwitchWidget from indico_vc_zoom import _ class VCRoomAttachForm(VCRoomAttachFormBase): - password_visibility = IndicoRadioField(_("Password visibility"), - description=_("Who should be able to know this meeting's password"), + password_visibility = IndicoRadioField(_("Passcode visibility"), + description=_("Who should be able to know this meeting's passcode"), orientation='horizontal', choices=[ ('everyone', _('Everyone')), @@ -52,8 +52,12 @@ class VCRoomForm(VCRoomFormBase): host_user = PrincipalField(_("User"), [HiddenUnless('host_choice', 'someone_else'), DataRequired()]) - password_visibility = IndicoRadioField(_("Password visibility"), - description=_("Who should be able to know this meeting's password"), + password = StringField(_("Passcode"), + [DataRequired(), IndicoRegexp(r'^\d{8,}$')], + description=_("Meeting passcode (min. 8 digits)")) + + password_visibility = IndicoRadioField(_("Passcode visibility"), + description=_("Who should be able to know this meeting's passcode"), orientation='horizontal', choices=[ ('everyone', _('Everyone')), diff --git a/vc_zoom/indico_vc_zoom/plugin.py b/vc_zoom/indico_vc_zoom/plugin.py index c2f6ec2..47d1af5 100644 --- a/vc_zoom/indico_vc_zoom/plugin.py +++ b/vc_zoom/indico_vc_zoom/plugin.py @@ -149,7 +149,8 @@ class ZoomPlugin(VCPluginMixin, IndicoPlugin): # webinar hosts cannot be changed through the API form.host_choice.render_kw = {'disabled': True} form.host_user.render_kw = {'disabled': True} - + else: + form.password.data = gen_random_password() return form def _extend_indico_cli(self, sender, **kwargs): @@ -185,7 +186,7 @@ class ZoomPlugin(VCPluginMixin, IndicoPlugin): def update_data_vc_room(self, vc_room, data, is_new=False): super(ZoomPlugin, self).update_data_vc_room(vc_room, data) - fields = {'description'} + fields = {'description', 'password'} if data['meeting_type'] == 'webinar': fields |= {'mute_host_video'} if is_new: @@ -265,7 +266,7 @@ class ZoomPlugin(VCPluginMixin, IndicoPlugin): kwargs.update({ 'topic': vc_room.name, 'agenda': vc_room.data['description'], - 'password': gen_random_password(), + 'password': vc_room.data['password'], 'timezone': event.timezone, 'settings': settings }) @@ -283,7 +284,6 @@ class ZoomPlugin(VCPluginMixin, IndicoPlugin): 'url': meeting_obj['join_url'], 'public_url': meeting_obj['join_url'].split('?')[0], 'start_url': meeting_obj['start_url'], - 'password': meeting_obj['password'], 'host': host.identifier }) @@ -325,6 +325,9 @@ class ZoomPlugin(VCPluginMixin, IndicoPlugin): if vc_room.data['description'] != zoom_meeting['agenda']: changes['agenda'] = vc_room.data['description'] + if vc_room.data['password'] != zoom_meeting['password']: + changes['password'] = vc_room.data['password'] + zoom_meeting_settings = zoom_meeting['settings'] if vc_room.data['mute_host_video'] == zoom_meeting_settings['host_video']: changes.setdefault('settings', {})['host_video'] = not vc_room.data['mute_host_video'] diff --git a/vc_zoom/indico_vc_zoom/templates/buttons.html b/vc_zoom/indico_vc_zoom/templates/buttons.html index c5cef9a..7a10064 100644 --- a/vc_zoom/indico_vc_zoom/templates/buttons.html +++ b/vc_zoom/indico_vc_zoom/templates/buttons.html @@ -7,7 +7,7 @@ {% elif event_vc_room.data.password_visibility == 'no_one' %} {% trans %}Join{% endtrans %} diff --git a/vc_zoom/indico_vc_zoom/templates/info_box.html b/vc_zoom/indico_vc_zoom/templates/info_box.html index a60d9cd..c4627eb 100644 --- a/vc_zoom/indico_vc_zoom/templates/info_box.html +++ b/vc_zoom/indico_vc_zoom/templates/info_box.html @@ -12,7 +12,7 @@ {% endif %} {% if event_vc_room.data.password_visibility == 'everyone' or is_manager or (session.user and event_vc_room.data.password_visibility == 'logged_in') %} -
{% trans %}Password{% endtrans %}
+
{% trans %}Passcode{% endtrans %}
{{ vc_room.data.password }}
{% endif %} {% if event_vc_room.data.show_autojoin %} diff --git a/vc_zoom/indico_vc_zoom/templates/manage_event_info_box.html b/vc_zoom/indico_vc_zoom/templates/manage_event_info_box.html index ef6bab5..d1a0d71 100644 --- a/vc_zoom/indico_vc_zoom/templates/manage_event_info_box.html +++ b/vc_zoom/indico_vc_zoom/templates/manage_event_info_box.html @@ -24,7 +24,7 @@ {% trans %}Session{% endtrans %}: {{ obj.full_title }} {% endif %} -
{% trans %}Password{% endtrans %}
+
{% trans %}Passcode{% endtrans %}
{{ vc_room.data.password }}
{% trans %}Zoom URL{% endtrans %}