Ejemplo n.º 1
0
 def validate_owner_user(self, field):
     if not field.data:
         raise ValidationError(_("Unable to find this user in Indico."))
     if not next(iter_user_identities(field.data), None):
         raise ValidationError(
             _("This user does not have a suitable account to use Bluejeans."
               ))
Ejemplo n.º 2
0
    def refresh_room(self, vc_room, event):
        client = AdminClient(self.settings)
        try:
            room_obj = self.get_room(vc_room)
        except RoomNotFoundAPIException:
            raise VCRoomNotFoundError(
                _("This room has been deleted from Bluejeans"))

        update_room_from_obj(self.settings, vc_room, room_obj)
        vc_room.data['auto_mute'] = client.get_automute(room_obj.roomID)
        flag_modified(vc_room, 'data')
Ejemplo n.º 3
0
class BluejeansAdvancedFormMixin(object):
    # Advanced options (per event)
    ### BEGIN TEST ###
    test_field = StringField(_('Test'), [DataRequired()],
                             description=_('write something here'))
    ### END TEST ###

    show_pin = BooleanField(
        _('Show PIN'),
        widget=SwitchWidget(),
        description=_("Show the VC Room PIN on the event page (insecure!)"))
    show_autojoin = BooleanField(
        _('Show Auto-join URL'),
        widget=SwitchWidget(),
        description=_("Show the auto-join URL on the event page"))
    show_phone_numbers = BooleanField(
        _('Show Phone Access numbers'),
        widget=SwitchWidget(),
        description=_("Show a link to the list of phone access numbers"))
Ejemplo n.º 4
0
class PluginSettingsForm(VCPluginSettingsFormBase):
    support_email = EmailField(_('Bluejeans email support'))
    username = StringField(_('Username'), [DataRequired()],
                           description=_('Indico username for Bluejeans'))
    password = IndicoPasswordField(
        _('Password'), [DataRequired()],
        toggle=True,
        description=_('Indico password for Bluejeans'))
    admin_api_wsdl = URLField(_('Admin API WSDL URL'), [DataRequired()])
    user_api_wsdl = URLField(_('User API WSDL URL'), [DataRequired()])
    indico_room_prefix = IntegerField(
        _('Indico tenant prefix'), [NumberRange(min=0)],
        description=_(
            'The tenant prefix for Indico rooms created on this server'))
    room_group_name = StringField(
        _("Public rooms' group name"), [DataRequired()],
        description=_(
            'Group name for public videoconference rooms created by Indico'))
    authenticators = StringField(
        _('Authenticators'), [DataRequired()],
        description=_(
            'Identity providers to convert Indico users to Bluejeans accounts')
    )
    num_days_old = IntegerField(
        _('VC room age threshold'),
        [NumberRange(min=1), DataRequired()],
        description=_(
            'Number of days after an Indico event when a videoconference room is '
            'considered old'))
    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'))
    bluejeans_phone_link = URLField(
        _('BluejeansVoice phone number'),
        description=_('Link to the list of BluejeansVoice phone numbers'))
    client_chooser_url = URLField(
        _('Client Chooser URL'),
        description=_(
            "URL for client chooser interface. The room key will be passed as a "
            "'url' GET query argument"))
    creation_email_footer = TextAreaField(
        _('Creation email footer'),
        widget=CKEditorWidget(),
        description=_(
            'Footer to append to emails sent upon creation of a VC room'))
Ejemplo n.º 5
0
    def update_room(self, vc_room, event):
        client = AdminClient(self.settings)

        try:
            room_obj = self.get_room(vc_room)
        except RoomNotFoundAPIException:
            raise VCRoomNotFoundError(
                _("This room has been deleted from Bluejeans"))

        owner = retrieve_principal(vc_room.data['owner'])
        changed_owner = room_obj.ownerName not in iter_user_identities(owner)
        if changed_owner:
            login_gen = iter_user_identities(owner)
            login = next(login_gen, None)
            if login is None:
                raise VCRoomError(
                    _("No valid Bluejeans account found for this user"),
                    field='owner_user')
            room_obj.ownerName = login

        room_obj.name = vc_room.name
        room_obj.description = vc_room.data['description']

        room_obj.RoomMode.hasPIN = bool(vc_room.data['room_pin'])
        room_obj.RoomMode.hasModeratorPIN = bool(
            vc_room.data['moderation_pin'])

        if room_obj.RoomMode.hasPIN:
            room_obj.RoomMode.roomPIN = vc_room.data['room_pin']
        if room_obj.RoomMode.hasModeratorPIN:
            room_obj.RoomMode.moderatorPIN = vc_room.data['moderation_pin']

        bluejeans_id = vc_room.data['bluejeans_id']
        while True:
            try:
                client.update_room(bluejeans_id, room_obj)
            except RoomNotFoundAPIException:
                raise VCRoomNotFoundError(
                    _("This room has been deleted from Bluejeans"))
            except APIException as err:
                err_msg = err.message
                if err_msg.startswith('Room exist for name'):
                    raise VCRoomError(_("Room name already in use"),
                                      field='name')

                elif err_msg.startswith('Member not found for ownerName'):
                    if changed_owner:
                        login = next(login_gen, None)
                    if not changed_owner or login is None:
                        raise VCRoomError(_(
                            "No valid Bluejeans account found for this user"),
                                          field='owner_user')
                    room_obj.ownerName = login

                else:
                    raise
            else:
                updated_room_obj = self.get_room(vc_room)

                update_room_from_obj(self.settings, vc_room, updated_room_obj)
                flag_modified(vc_room, 'data')

                client.set_automute(bluejeans_id, vc_room.data['auto_mute'])
                break
Ejemplo n.º 6
0
    def create_room(self, vc_room, event):
        """Create a new Bluejeans room for an event, given a VC room.

        In order to create the Bluejeans room, the function will try to do so with
        all the available identities of the user based on the authenticators
        defined in Bluejeans plugin's settings, in that order.

        :param vc_room: VCRoom -- The VC room from which to create the Bluejeans
                        room
        :param event: Event -- The event to the Bluejeans room will be attached
        """

        client = AdminClient(self.settings)
        owner = retrieve_principal(vc_room.data['owner'])
        login_gen = iter_user_identities(owner)
        login = next(login_gen, None)
        if login is None:
            raise VCRoomError(
                _("No valid Bluejeans account found for this user"),
                field='owner_user')

        extension_gen = iter_extensions(
            self.settings.get('indico_room_prefix'), event.id)
        extension = next(extension_gen)

        while True:
            room_mode = {
                'isLocked': False,
                'hasPIN': bool(vc_room.data['room_pin']),
                'hasModeratorPIN': bool(vc_room.data['moderation_pin'])
            }
            if room_mode['hasPIN']:
                room_mode['roomPIN'] = vc_room.data['room_pin']
            if room_mode['hasModeratorPIN']:
                room_mode['moderatorPIN'] = vc_room.data['moderation_pin']

            room_obj = client.create_room_object(
                name=vc_room.name,
                RoomType='Public',
                ownerName=login,
                extension=extension,
                groupName=self.settings.get('room_group_name'),
                description=vc_room.data['description'],
                RoomMode=room_mode)

            if room_obj.RoomMode.hasPIN:
                room_obj.RoomMode.roomPIN = vc_room.data['room_pin']
            if room_obj.RoomMode.hasModeratorPIN:
                room_obj.RoomMode.moderatorPIN = vc_room.data['moderation_pin']

            try:
                client.add_room(room_obj)
            except APIException as err:
                err_msg = err.message

                if err_msg.startswith('Room exist for name'):
                    raise VCRoomError(_("Room name already in use"),
                                      field='name')
                elif err_msg.startswith('Member not found for ownerName'):
                    login = next(login_gen, None)
                    if login is None:
                        raise VCRoomError(_(
                            "No valid Bluejeans account found for this user"),
                                          field='owner_user')
                elif err_msg.startswith('Room exist for extension'):
                    extension = next(extension_gen)
                else:
                    raise

            else:
                # get room back, in order to fetch Bluejeans-set parameters
                created_room = client.find_room(extension)

                if not created_room:
                    raise VCRoomNotFoundError(
                        _("Could not find newly created room in Bluejeans"))
                vc_room.data.update({
                    'bluejeans_id':
                    unicode(created_room.roomID),
                    'url':
                    created_room.RoomMode.roomURL,
                    'owner_identity':
                    created_room.ownerName
                })
                flag_modified(vc_room, 'data')
                vc_room.bluejeans_extension = BluejeansExtension(
                    vc_room_id=vc_room.id,
                    extension=int(created_room.extension),
                    owned_by_user=owner)

                client.set_automute(created_room.roomID,
                                    vc_room.data['auto_mute'])
                break
Ejemplo n.º 7
0
class VCRoomForm(VCRoomFormBase, BluejeansAdvancedFormMixin):
    """Contains all information concerning a Bluejeans booking"""

    advanced_fields = {'show_pin', 'show_autojoin', 'show_phone_numbers'
                       } | VCRoomFormBase.advanced_fields
    skip_fields = advanced_fields | VCRoomFormBase.conditional_fields

    description = TextAreaField(_('Description'), [DataRequired()],
                                description=_('The description of the room'))
    owner_user = PrincipalField(_('Owner'), [DataRequired()],
                                description=_('The owner of the room'))
    moderation_pin = IndicoPasswordField(
        _('Moderation PIN'),
        PIN_VALIDATORS,
        toggle=True,
        description=_('Used to moderate the VC Room. Only digits allowed.'))
    room_pin = IndicoPasswordField(
        _('Room PIN'),
        PIN_VALIDATORS,
        toggle=True,
        description=_(
            'Used to protect the access to the VC Room (leave blank for open '
            'access). Only digits allowed.'))
    auto_mute = BooleanField(
        _('Auto mute'),
        widget=SwitchWidget(_('On'), _('Off')),
        description=_(
            'The BluejeansDesktop clients will join the VC room muted by default '
            '(audio and video)'))

    def __init__(self, *args, **kwargs):
        defaults = kwargs['obj']
        if defaults.owner_user is None and defaults.owner is not None:
            defaults.owner_user = retrieve_principal(defaults.owner)
        super(VCRoomForm, self).__init__(*args, **kwargs)

    @generated_data
    def owner(self):
        return self.owner_user.data.as_principal

    def validate_owner_user(self, field):
        if not field.data:
            raise ValidationError(_("Unable to find this user in Indico."))
        if not next(iter_user_identities(field.data), None):
            raise ValidationError(
                _("This user does not have a suitable account to use Bluejeans."
                  ))
Ejemplo n.º 8
0
### BEGIN TEST ###
from wtforms.fields.simple import StringField
### END TEST ###

from indico.modules.vc.forms import VCRoomAttachFormBase, VCRoomFormBase
from indico.web.forms.base import generated_data
from indico.web.forms.fields import IndicoPasswordField, PrincipalField
from indico.web.forms.widgets import SwitchWidget

from indico_vc_bluejeans import _
from indico_vc_bluejeans.util import iter_user_identities, retrieve_principal

PIN_VALIDATORS = [
    Optional(),
    Length(min=3, max=10),
    Regexp(r'^\d+$', message=_("The PIN must be a number"))
]


class BluejeansAdvancedFormMixin(object):
    # Advanced options (per event)
    ### BEGIN TEST ###
    test_field = StringField(_('Test'), [DataRequired()],
                             description=_('write something here'))
    ### END TEST ###

    show_pin = BooleanField(
        _('Show PIN'),
        widget=SwitchWidget(),
        description=_("Show the VC Room PIN on the event page (insecure!)"))
    show_autojoin = BooleanField(