Esempio n. 1
0
    def _process(self):
        defaults = FormDefaults(self.plugin.get_vc_room_attach_form_defaults(self.event_new))
        form = self.plugin.vc_room_attach_form(
            prefix="vc-", obj=defaults, event=self.event_new, service=self.plugin.service_name
        )

        if form.validate_on_submit():
            vc_room = form.data["room"]
            if not self.plugin.can_manage_vc_rooms(session.user, self.event_new):
                flash(
                    _("You are not allowed to attach {plugin_name} rooms to this event.").format(
                        plugin_name=self.plugin.friendly_name
                    ),
                    "error",
                )
            elif not self.plugin.can_manage_vc_room(session.user, vc_room):
                flash(_("You are not authorized to attach the room '{room.name}'".format(room=vc_room)), "error")
            else:
                event_vc_room = process_vc_room_association(self.plugin, self.event_new, vc_room, form)
                if event_vc_room:
                    flash(_("The room has been attached to the event."), "success")
                    db.session.add(event_vc_room)
            return redirect_or_jsonify(url_for(".manage_vc_rooms", self.event_new), flash=False)

        return WPVCManageEvent.render_template(
            "attach_room.html",
            self._conf,
            event=self.event_new,
            form=form,
            skip_fields=form.conditional_fields | {"room"},
            plugin=self.plugin,
        )
Esempio n. 2
0
 def _process(self):
     action = request.args.get('vc_room_action', '.manage_vc_rooms_create')
     return WPVCManageEvent.render_template(
         'manage_event_select.html',
         self._conf,
         vc_room_action=action,
         event=self._conf,
         plugins=get_vc_plugins().values())
Esempio n. 3
0
 def _process(self):
     try:
         room_event_assocs = VCRoomEventAssociation.find_for_event(self._conf, include_hidden=True,
                                                                   include_deleted=True).all()
     except ValueError:
         raise IndicoError(_('This page is not available for legacy events.'))
     event_vc_rooms = [event_vc_room for event_vc_room in room_event_assocs if event_vc_room.vc_room.plugin]
     return WPVCManageEvent.render_template('manage_event.html', self._conf, event=self._conf,
                                            event_vc_rooms=event_vc_rooms, plugins=get_vc_plugins().values())
Esempio n. 4
0
 def _process(self):
     action = request.args.get("vc_room_action", ".manage_vc_rooms_create")
     attach = request.args.get("attach", "")
     return WPVCManageEvent.render_template(
         "manage_event_select.html",
         self._conf,
         vc_room_action=action,
         event=self.event_new,
         plugins=get_vc_plugins().values(),
         attach=attach,
     )
Esempio n. 5
0
 def _process(self):
     room_event_assocs = VCRoomEventAssociation.find_for_event(
         self.event, include_hidden=True, include_deleted=True).all()
     event_vc_rooms = [
         event_vc_room for event_vc_room in room_event_assocs
         if event_vc_room.vc_room.plugin
     ]
     return WPVCManageEvent.render_template(
         'manage_event.html',
         self.event,
         event_vc_rooms=event_vc_rooms,
         plugins=get_vc_plugins().values())
Esempio n. 6
0
 def _process(self):
     room_event_assocs = VCRoomEventAssociation.find_for_event(
         self.event_new, include_hidden=True, include_deleted=True
     ).all()
     event_vc_rooms = [event_vc_room for event_vc_room in room_event_assocs if event_vc_room.vc_room.plugin]
     return WPVCManageEvent.render_template(
         "manage_event.html",
         self._conf,
         event=self.event_new,
         event_vc_rooms=event_vc_rooms,
         plugins=get_vc_plugins().values(),
     )
Esempio n. 7
0
    def _process(self):
        defaults = FormDefaults(self.plugin.get_vc_room_attach_form_defaults(self.event))
        form = self.plugin.vc_room_attach_form(prefix='vc-', obj=defaults, event=self.event,
                                               service=self.plugin.service_name)

        if form.validate_on_submit():
            vc_room = form.data['room']
            if not self.plugin.can_manage_vc_rooms(session.avatar, self.event):
                flash(_("You are not allowed to attach {plugin_name} rooms to this event.").format(
                    plugin_name=self.plugin.friendly_name), 'error')
            elif not self.plugin.can_manage_vc_room(session.avatar, vc_room):
                flash(_("You are not authorized to attach the room '{room.name}'".format(room=vc_room)), 'error')
            else:
                event_vc_room = process_vc_room_association(self.plugin, self.event, vc_room, form)
                if event_vc_room:
                    flash(_("The room has been attached to the event."), 'success')
                    db.session.add(event_vc_room)
            return redirect_or_jsonify(url_for('.manage_vc_rooms', self.event), flash=False)

        return WPVCManageEvent.render_template('attach_room.html', self._conf, event=self._conf, form=form,
                                               skip_fields=form.conditional_fields | {'room'},
                                               plugin=self.plugin)
Esempio n. 8
0
 def _process(self):
     action = request.args.get('vc_room_action', '.manage_vc_rooms_create')
     attach = request.args.get('attach', '')
     return WPVCManageEvent.render_template('manage_event_select.html', self._conf, vc_room_action=action,
                                            event=self.event_new, plugins=get_vc_plugins().values(), attach=attach)