VC/Vidyo: Add room name & PIN validation, automute default

This commit is contained in:
Pedro Ferreira 2015-02-16 15:53:07 +01:00 committed by Adrian Moennich
parent 18e40f8ab3
commit c87ef09d64
2 changed files with 38 additions and 17 deletions

View File

@ -20,16 +20,20 @@ import re
from wtforms.fields.core import BooleanField
from wtforms.fields.simple import StringField, TextAreaField
from wtforms.validators import DataRequired, Length, Regexp
from wtforms.validators import DataRequired, Length, Regexp, Optional, ValidationError
from indico.web.forms.base import IndicoForm
from indico.modules.vc.models import VCRoom
from indico.modules.vc.plugins import VCRoomFormBase
from indico.util.i18n import _
from indico.web.forms.fields import PrincipalField, IndicoPasswordField
ROOM_NAME_RE = re.compile(r'[\w\-]+')
PIN_RE = re.compile(r'^\d+$')
ERROR_MSG_PIN = _("The PIN must be a number")
class VCRoomForm(IndicoForm):
class VCRoomForm(VCRoomFormBase):
name = StringField(_('Name'), [DataRequired(), Length(min=3, max=60), Regexp(ROOM_NAME_RE)],
description=_('The name of the room'))
description = TextAreaField(_('Description'), [DataRequired()], description=_('The description of the room'))
@ -37,7 +41,15 @@ class VCRoomForm(IndicoForm):
auto_mute = BooleanField(_('Auto mute'),
description=_('The VidyoDesktop clients will join the meeting muted by default '
'(audio and video)'))
moderator_pin = IndicoPasswordField(_('Moderator PIN'), toggle=True, description=_('Used to moderate the VC Room'))
room_pin = IndicoPasswordField(_('Room PIN'), toggle=True,
description=_('Used to protect the access to the VC Room '
'(leave blank for open access)'))
moderator_pin = IndicoPasswordField(
_('Moderator PIN'),
[Optional(), Length(min=3, max=10), Regexp(PIN_RE)],
toggle=True, description=_('Used to moderate the VC Room'))
room_pin = IndicoPasswordField(
_('Room PIN'),
[Optional(), Length(min=3, max=10), Regexp(PIN_RE, message=ERROR_MSG_PIN)],
toggle=True, description=_('Used to protect the access to the VC Room (leave blank for open access)'))
def validate_name(self, field):
if field.data and VCRoom.find_first(name=field.data):
raise ValidationError(_("There is already a room with this name"))

View File

@ -15,17 +15,18 @@
# along with Indico; if not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import re
from wtforms.fields import IntegerField, TextAreaField
from wtforms.fields.html5 import URLField, EmailField
from wtforms.fields.simple import StringField
from wtforms.validators import NumberRange
from wtforms.validators import NumberRange, DataRequired
from indico.core.config import Config
from indico.core.plugins import IndicoPlugin, url_for_plugin, IndicoPluginBlueprint
from indico.modules.vc import VCPluginSettingsFormBase, VCPluginMixin
from indico.util.i18n import _
from indico.web.forms.fields import EmailListField, UnsafePasswordField
from indico.web.forms.fields import EmailListField, IndicoPasswordField
from indico.web.forms.widgets import CKEditorWidget
from indico_vc_vidyo.forms import VCRoomForm
@ -36,20 +37,21 @@ class PluginSettingsForm(VCPluginSettingsFormBase):
_('Notification emails'),
description=_('Additional email addresses who will always receive notifications (one per line)')
)
username = StringField(_('Username'), description=_('Indico username for Vidyo'))
password = UnsafePasswordField(_('Password'), description=_('Indico password for Vidyo'))
admin_api_wsdl = URLField(_('Admin API WSDL URL'))
user_api_wsdl = URLField(_('User API WSDL URL'))
username = StringField(_('Username'), [DataRequired()], description=_('Indico username for Vidyo'))
password = IndicoPasswordField(_('Password'), [DataRequired()], toggle=True,
description=_('Indico password for Vidyo'))
admin_api_wsdl = URLField(_('Admin API WSDL URL'), [DataRequired()])
user_api_wsdl = URLField(_('User API WSDL URL'), [DataRequired()])
indico_room_prefix = IntegerField(_('Indico rooms prefix'), [NumberRange(min=0)],
description=_('The prefix for Indico rooms'))
room_group_name = StringField(_("Public rooms' group name"),
room_group_name = StringField(_("Public rooms' group name"), [DataRequired()],
description=_('Group name for public video conference rooms created by Indico'))
authenticators = StringField(_('Authenticators'),
authenticators = StringField(_('Authenticators'), [DataRequired()],
description=_('Authenticators to convert Indico users to Vidyo accounts'))
num_days_old = IntegerField(_('VC room age threshold'), [NumberRange(min=1)],
num_days_old = IntegerField(_('VC room age threshold'), [NumberRange(min=1), DataRequired()],
description=_('Number of days after an Indico event when a video conference room is '
'considered old'))
max_rooms_warning = IntegerField(_('Max. num. VC rooms before warning'), [NumberRange(min=1)],
max_rooms_warning = IntegerField(_('Max. num. VC rooms before warning'), [NumberRange(min=1), DataRequired()],
description=_('Maximum number of rooms until a warning is sent to the managers'))
vidyo_phone_link = URLField(_('VidyoVoice phone number'),
description=_('Link to the list of VidyoVoice phone numbers'))
@ -86,6 +88,13 @@ class VidyoPlugin(VCPluginMixin, IndicoPlugin):
}
vc_room_form = VCRoomForm
def get_vc_room_form_defaults(self, event):
return {
# replace invalid chars with underscore
'name': re.sub(r'[^\w_-]', '_', event.getTitle()),
'auto_mute': True
}
@property
def logo_url(self):
return url_for_plugin(self.name + '.static', filename='images/logo.png')