Пример #1
0
    def _on_event_update(self, event, **kwargs):
        changes = kwargs['changes']
        if not changes.viewkeys() & {'location_data', 'start_dt', 'end_dt'}:
            return

        request = Request.find_latest_for_event(event,
                                                RoomAssistanceRequest.name)
        if not request or request.state != RequestState.accepted:
            return

        if 'location_data' in changes and not event_has_room_with_support_attached(
                event):
            request.definition.reject(
                request, {
                    'comment':
                    render_plugin_template('auto_reject_no_supported_room.txt')
                }, User.get_system_user())
            request.data = dict(request.data, occurrences=[])
            flash(
                _("The new event location is not in the list of the rooms supported by the room assistance team. "
                  "Room assistance request has been rejected and support will not be provided."
                  ), 'warning')
        if changes.viewkeys() & {'start_dt', 'end_dt'}:
            tz = pytz.timezone(config.DEFAULT_TIMEZONE)
            occurrences = {
                dateutil.parser.parse(occ).astimezone(tz)
                for occ in request.data['occurrences']
            }
            req_dates = {occ.date() for occ in occurrences}
            event_dates = set(event.iter_days())
            old_dates = req_dates - event_dates
            has_overlapping_dates = req_dates & event_dates

            if not has_overlapping_dates:
                request.definition.reject(
                    request, {
                        'comment':
                        render_plugin_template(
                            'auto_reject_no_overlapping_dates.txt')
                    }, User.get_system_user())
                request.data = dict(request.data, occurrences=[])
                flash(
                    _("The new event dates don't overlap with the existing room assistance request for this event. "
                      "Room assistance request has been rejected and support will not be provided."
                      ), 'warning')
            elif old_dates and has_overlapping_dates:
                new_data = dict(request.data)
                new_data['occurrences'] = [
                    occ.astimezone(pytz.utc).isoformat() for occ in occurrences
                    if occ.date() in req_dates & event_dates
                ]
                request.data = new_data
                flash(
                    _("Room assistance had been requested for days that are not between the updated start/end "
                      "dates. Support will not be provided on these days anymore."
                      ), 'warning')
Пример #2
0
def test_render_plugin_template(flask_app_ctx, loaded_engine):
    """
    Check that render_plugin_template works
    """
    plugin = loaded_engine.get_plugin('espresso')
    text = 'plugin test'
    with plugin.plugin_context():
        assert render_template('espresso:test.txt') == text
        assert render_plugin_template('test.txt') == text
        assert render_plugin_template('espresso:test.txt') == text
    # explicit plugin name works outside context
    assert render_plugin_template('espresso:test.txt') == text
    # implicit plugin name fails outside context
    with pytest.raises(RuntimeError):
        render_plugin_template('test.txt')
Пример #3
0
def test_render_plugin_template(flask_app_ctx, loaded_engine):
    """
    Check that render_plugin_template works
    """
    plugin = loaded_engine.get_plugin('espresso')
    text = 'plugin test'
    with plugin.plugin_context():
        assert render_template('espresso:test.txt') == text
        assert render_plugin_template('test.txt') == text
        assert render_plugin_template('espresso:test.txt') == text
    # explicit plugin name works outside context
    assert render_plugin_template('espresso:test.txt') == text
    # implicit plucin name fails outside context
    with pytest.raises(RuntimeError):
        render_plugin_template('test.txt')
Пример #4
0
def extend_plugin_details():
    agents = LiveSyncAgent.query.order_by(LiveSyncAgent.name, LiveSyncAgent.id).all()
    used_backends = {a.backend_name for a in agents}
    available_backends = {name: backend
                          for name, backend in current_plugin.backend_classes.items()
                          if not backend.unique or name not in used_backends}
    return render_plugin_template('plugin_details_extra.html', agents=agents, backends=available_backends)
Пример #5
0
 def inject_event_header(self, event, **kwargs):
     chatrooms = ChatroomEventAssociation.find_for_event(event).all()
     if not chatrooms:
         return ''
     how_to_connect = self.settings.get('how_to_connect')
     return render_plugin_template('event_header.html', event=event, event_chatrooms=chatrooms,
                                   how_to_connect=how_to_connect, chat_links=self.settings.get('chat_links'))
Пример #6
0
 def _getBody(self, params):
     locale = get_current_locale()
     params['language'] = IndicoLocale.parse('en').languages[
         locale.language]
     params['python_msg_core_i18n'] = core_gettext('Hello world!')
     params['python_msg_plugin_i18n'] = _('Hello world!')
     return render_plugin_template('example:example.html', **params)
Пример #7
0
    def inject_connect_button(self, template, event_vc_room, **kwargs):  # pragma: no cover
        from indico_ravem.util import has_access
        if event_vc_room.vc_room.type != 'vidyo' or not has_access(event_vc_room):
            return

        return render_plugin_template(template, room_name=event_vc_room.link_object.room.name,
                                      event_vc_room=event_vc_room, **kwargs)
Пример #8
0
    def _apply_changes(self, sender, **kwargs):
        # we are using after_request to avoid spam in case someone changes many contribution times
        if 'av_request_changes' not in g:
            return
        for req in g.av_request_changes:
            identifiers = get_data_identifiers(req)

            if req.state == RequestState.accepted and identifiers['dates'][
                    0] != req.data['identifiers']['dates'][0]:
                notify_rescheduled_request(req)

            if not compare_data_identifiers(
                    identifiers['locations'],
                    req.data['identifiers']['locations']):
                if (not count_capable_contributions(req.event)[0] and req.state
                        in {RequestState.accepted, RequestState.pending}
                        and not is_av_manager(req.created_by_user)):
                    janitor = User.get_system_user()
                    data = dict(req.data,
                                comment=render_plugin_template(
                                    'auto_reject_no_capable_contribs.txt'))
                    req.definition.reject(req, data, janitor)
                elif req.state == RequestState.accepted:
                    notify_relocated_request(req)
            req.data['identifiers'] = identifiers
            flag_modified(req, 'data')
Пример #9
0
    def _get_personal_data_form(self,
                                event,
                                regform,
                                management,
                                registration=None,
                                **kwargs):
        if management or registration is not None:
            return

        if regform.cern_access_request and regform.cern_access_request.is_active:
            req = get_last_request(event)
            if not req.data['during_registration']:
                return
            required = req.data['during_registration_required']
            form_cls = AccessIdentityDataForm if required else RegistrationFormPersonalDataForm
            form = g.get('personal_data_form')
            if not form:
                form = form_cls()
                if req.data['during_registration_preselected'] and not required:
                    form.request_cern_access.data = True
            start_dt, end_dt = get_access_dates(req)
            return render_plugin_template('regform_identity_data_section.html',
                                          event=event,
                                          form=form,
                                          start_dt=start_dt,
                                          end_dt=end_dt,
                                          registration=registration,
                                          required=required)
Пример #10
0
    def _get_personal_data_form(self,
                                event,
                                regform,
                                management,
                                registration=None,
                                **kwargs):
        if management or registration is not None:
            return

        if regform.cern_access_request and regform.cern_access_request.is_active:
            req = get_last_request(event)
            mode = req.data.get('regform_data_mode')
            if mode not in (RegformDataMode.during_registration,
                            RegformDataMode.during_registration_required):
                return
            required = mode == RegformDataMode.during_registration_required
            form_cls = AccessIdentityDataForm if required else RegistrationFormPersonalDataForm
            form = g.get('personal_data_form') or form_cls()
            start_dt, end_dt = get_access_dates(req)
            return render_plugin_template('regform_identity_data_section.html',
                                          event=event,
                                          form=form,
                                          start_dt=start_dt,
                                          end_dt=end_dt,
                                          registration=registration,
                                          required=required)
Пример #11
0
 def _get_cannot_modify_message(self, plugin, event, **kwargs):
     if self != plugin:
         return
     fp_name = self.settings.get('fp_department_name')
     fp_email = self.settings.get('fp_email_address')
     return render_plugin_template('event_settings_readonly.html',
                                   fp_name=fp_name,
                                   fp_email=fp_email)
Пример #12
0
 def render_event_buttons(self, vc_room, event_vc_room, **kwargs):
         """Renders a list of plugin specific buttons (eg: Join URL, etc) in the event page
         :param vc_room: the VC room object
         :param event_vc_room: the association of an event and a VC room
         :param kwargs: arguments passed to the template
         """
         return render_plugin_template('{}:event_buttons.html'.format(self.name), plugin=self, vc_room=vc_room,
                                       event_vc_room=event_vc_room, event=event_vc_room.event, **kwargs)
Пример #13
0
 def render_info_box(self, vc_room, event_vc_room, event, **kwargs):
     """Renders the information shown in the expandable box of a VC room row
     :param vc_room: the VC room object
     :param event_vc_room: the association of an event and a VC room
     :param event: the event with the current VC room attached to it
     :param kwargs: arguments passed to the template
     """
     return render_plugin_template('{}:info_box.html'.format(self.name), plugin=self, event_vc_room=event_vc_room,
                                   event=event, vc_room=vc_room, settings=self.settings, **kwargs)
Пример #14
0
 def render_info_box(self, vc_room, event_vc_room, event, **kwargs):
     """Renders the information shown in the expandable box of a VC room row
     :param vc_room: the VC room object
     :param event_vc_room: the association of an event and a VC room
     :param event: the event with the current VC room attached to it
     :param kwargs: arguments passed to the template
     """
     return render_plugin_template('{}:info_box.html'.format(self.name), plugin=self, event_vc_room=event_vc_room,
                                   event=event, vc_room=vc_room, settings=self.settings, **kwargs)
Пример #15
0
 def inject_tracking(self, **kwargs):
     server_url = self._get_tracking_url()
     site_id_general = self.settings.get('site_id_general')
     if not self.settings.get('enabled') or not server_url or not site_id_general:
         return ''
     event_tracking_params = self._get_event_tracking_params()
     return render_plugin_template('tracking.html',
                                   site_id_general=site_id_general,
                                   server_url=server_url,
                                   **event_tracking_params)
Пример #16
0
 def default_settings(self):
     return {
         'notify_emails': [],
         'how_to_connect':
         render_plugin_template('how_to_connect.html'),
         'chat_links': [{
             'title': 'Desktop Client',
             'link': 'xmpp:{room}@{server}?join'
         }]
     }
Пример #17
0
 def _room_assistance_action(self, event, **kwargs):
     has_room_assistance_request = event.requests.filter_by(
         type='room-assistance').has_rows()
     room_allows_assistance = event.room is not None and event.room in self.settings.get(
         'rooms_with_assistance')
     can_request_assistance = not event.has_ended and not has_room_assistance_request and room_allows_assistance
     return render_plugin_template(
         'room_assistance_action.html',
         event=event,
         can_request_assistance=can_request_assistance)
Пример #18
0
 def default_settings(self):
     return {
         'server': '',
         'muc_server': '',
         'bot_jid': '',
         'bot_password': '',
         'notify_emails': [],
         'log_url': '',
         'chat_links': [{'title': 'Desktop Client', 'link': 'xmpp:{room}@{server}?join'}],
         'how_to_connect': render_plugin_template('how_to_connect.html')
     }
Пример #19
0
 def inject_event_header(self, event, **kwargs):
     chatrooms = ChatroomEventAssociation.find_for_event(event).all()
     if not chatrooms:
         return ''
     how_to_connect = self.settings.get('how_to_connect')
     return render_plugin_template(
         'event_header.html',
         event=event,
         event_chatrooms=chatrooms,
         how_to_connect=how_to_connect,
         chat_links=self.settings.get('chat_links'))
Пример #20
0
    def render_manage_event_info_box(self, vc_room, event_vc_room, event, **kwargs):
        """
        Render the information shown in the expandable box on a
        VC room in the management area.

        :param vc_room: the VC room object
        :param event_vc_room: the association of an event and a VC room
        :param event: the event with the current VC room attached to it
        :param kwargs: arguments passed to the template
        """
        return render_plugin_template(f'{self.name}:manage_event_info_box.html', plugin=self,
                                      event_vc_room=event_vc_room, event=event, vc_room=vc_room,
                                      settings=self.settings, **kwargs)
Пример #21
0
 def _process(self):
     access_request = self.registration.cern_access_request
     if not access_request or access_request.has_identity_info:
         raise UserValueError(_('The personal data for this registrant has already been entered'))
     form = AccessIdentityDataForm()
     if form.validate_on_submit():
         form.populate_obj(access_request)
         db.session.flush()
         send_ticket(self.registration)
         return jsonify_data(html=render_plugin_template('cern_access_status.html', registration=self.registration,
                                                         header=False))
     return jsonify_template('identity_data_form_management.html', render_plugin_template, form=form,
                             registration=self.registration)
Пример #22
0
 def _get_vc_assistance_request_link(self, event, **kwargs):
     from definition import VCAssistanceRequest
     req = Request.find_latest_for_event(event, VCAssistanceRequest.name)
     support_email = VCAssistanceRequestPlugin.settings.get('support_email')
     return render_plugin_template(
         'vc_assistance_request_link.html',
         event=event,
         name=VCAssistanceRequest.name,
         request_accepted=req is not None
         and req.state == RequestState.accepted,
         has_capable_vc_room_attached=has_vc_rooms_attached_to_capable(
             event),
         support_email=support_email)
Пример #23
0
 def _event_display_after_attachment(self, attachment, top_level, has_label,
                                     **kwargs):
     if attachment.type != AttachmentType.file:
         return None
     if now_utc() - attachment.file.created_dt > info_ttl:
         return None
     if cache.get(unicode(attachment.id)) != 'pending':
         return None
     return render_plugin_template('pdf_attachment.html',
                                   attachment=attachment,
                                   top_level=top_level,
                                   has_label=has_label,
                                   title=get_pdf_title(attachment))
Пример #24
0
 def _inject_ursh_link(self,
                       target=None,
                       event=None,
                       dropdown=False,
                       element_class='',
                       text='',
                       **kwargs):
     if is_configured() and (target or event):
         return render_plugin_template('ursh_link.html',
                                       target=target,
                                       event=event,
                                       dropdown=dropdown,
                                       element_class=element_class,
                                       text=text,
                                       **kwargs)
Пример #25
0
    def render_payment_form(self, registration):
        """Returns the payment form shown to the user.

        :param registration: a :class:`Registration` object
        """
        event = registration.registration_form.event
        settings = self.settings.get_all()
        event_settings = self.event_settings.get_all(event)
        data = {'event': event,
                'registration': registration,
                'amount': registration.price,
                'currency': registration.currency,
                'settings': settings,
                'event_settings': event_settings}
        self.adjust_payment_form_data(data)
        return render_plugin_template('event_payment_form.html', **data)
Пример #26
0
def render_engine_or_search_template(template_name, **context):
    """Renders a template from the engine plugin or the search plugin

    If the template is available in the engine plugin, it's taken
    from there, otherwise the template from this plugin is used.

    :param template_name: name of the template
    :param context: the variables that should be available in the
                    context of the template.
    """
    from indico_search.plugin import SearchPlugin
    assert current_plugin == SearchPlugin.instance

    templates = ('{}:{}'.format(SearchPlugin.instance.engine_plugin.name,
                                template_name), template_name)
    return render_plugin_template(templates, **context)
Пример #27
0
    def render_payment_form(self, registration):
        """Return the payment form shown to the user.

        :param registration: a :class:`Registration` object
        """
        event = registration.registration_form.event
        settings = self.settings.get_all()
        event_settings = self.event_settings.get_all(event)
        data = {'event': event,
                'registration': registration,
                'amount': registration.price,
                'currency': registration.currency,
                'settings': settings,
                'event_settings': event_settings}
        self.adjust_payment_form_data(data)
        return render_plugin_template('event_payment_form.html', **data)
Пример #28
0
def render_engine_or_search_template(template_name, **context):
    """Renders a template from the engine plugin or the search plugin

    If the template is available in the engine plugin, it's taken
    from there, otherwise the template from this plugin is used.

    :param template_name: name of the template
    :param context: the variables that should be available in the
                    context of the template.
    """
    from indico_search.plugin import SearchPlugin
    assert current_plugin == SearchPlugin.instance

    templates = ('{}:{}'.format(SearchPlugin.instance.engine_plugin.name, template_name),
                 template_name)
    return render_plugin_template(templates, **context)
Пример #29
0
    def render_payment_form(self, event, registrant, amount, currency):
        """Returns the payment form shown to the user.

        :param event: the :class:`Conference`
        :param registrant: the :class:`Registrant`
        :param amount: the amount of money the registrant has to pay
        :param currency: the currency used for the payment
        """
        settings = self.settings.get_all()
        event_settings = self.event_settings.get_all(event)
        data = {'event': event,
                'registrant': registrant,
                'amount': amount,
                'currency': currency,
                'settings': settings,
                'event_settings': event_settings}
        self.adjust_payment_form_data(data)
        return render_plugin_template('event_payment_form.html', **data)
Пример #30
0
    def render_manage_event_info_box(self, vc_room, event_vc_room, event, **kwargs):
        """Renders the information shown in the expandable box on a VC room in the management area

        :param vc_room: the VC room object
        :param event_vc_room: the association of an event and a VC room
        :param event: the event with the current VC room attached to it
        :param kwargs: arguments passed to the template
        """
        return render_plugin_template(
            "{}:manage_event_info_box.html".format(self.name),
            plugin=self,
            event_vc_room=event_vc_room,
            event=event,
            vc_room=vc_room,
            retrieve_principal=retrieve_principal,
            settings=self.settings,
            **kwargs
        )
Пример #31
0
    def render_payment_form(self, registration):
        """Returns the payment form shown to the user.

        :param registration: a :class:`Registration` object
        """
        from indico.modules.payment import event_settings as event_payment_settings

        event = registration.registration_form.event
        settings = self.settings.get_all()
        event_settings = self.event_settings.get_all(event)
        data = {
            "event": registration.registration_form.event,
            "registration": registration,
            "amount": registration.price,
            "currency": event_payment_settings.get(event, "currency"),
            "settings": settings,
            "event_settings": event_settings,
        }
        self.adjust_payment_form_data(data)
        return render_plugin_template("event_payment_form.html", **data)
Пример #32
0
    def render_payment_form(self, event, registrant, amount, currency):
        """Returns the payment form shown to the user.

        :param event: the :class:`Conference`
        :param registrant: the :class:`Registrant`
        :param amount: the amount of money the registrant has to pay
        :param currency: the currency used for the payment
        """
        settings = self.settings.get_all()
        event_settings = self.event_settings.get_all(event)
        data = {
            'event': event,
            'registrant': registrant,
            'amount': amount,
            'currency': currency,
            'settings': settings,
            'event_settings': event_settings
        }
        self.adjust_payment_form_data(data)
        return render_plugin_template('event_payment_form.html', **data)
Пример #33
0
 def default_settings(self):
     return {
         'server':
         '',
         'muc_server':
         '',
         'bot_jid':
         '',
         'bot_password':
         '',
         'notify_emails': [],
         'log_url':
         '',
         'chat_links': [{
             'title': 'Desktop Client',
             'link': 'xmpp:{room}@{server}?join'
         }],
         'how_to_connect':
         render_plugin_template('how_to_connect.html')
     }
Пример #34
0
    def render_payment_form(self, event, registrant, amount, currency):
        """Returns the payment form shown to the user.

        :param event: the :class:`Conference`
        :param registrant: the :class:`Registrant`
        :param amount: the amount of money the registrant has to pay
        :param currency: the currency used for the payment
        """
        settings = self.settings.get_all()
        event_settings = self.event_settings.get_all(event)
        data = {
            "event": event,
            "registrant": registrant,
            "amount": amount,
            "currency": currency,
            "settings": settings,
            "event_settings": event_settings,
        }
        self.adjust_payment_form_data(data)
        return render_plugin_template("event_payment_form.html", **data)
Пример #35
0
def extend_plugin_details():
    agents = LiveSyncAgent.find().order_by(LiveSyncAgent.name, LiveSyncAgent.id).all()
    return render_plugin_template('plugin_details_extra.html', agents=agents, backends=current_plugin.backend_classes)
Пример #36
0
def _inject_vc_room_action_buttons(event, item, **kwargs):
    event_vc_room = VCRoomEventAssociation.get_linked_for_event(event).get(item)
    if event_vc_room and event_vc_room.vc_room.plugin:
        return render_plugin_template('{}:vc_room_timetable_buttons.html'.format(event_vc_room.vc_room.plugin.name),
                                      event=event, event_vc_room=event_vc_room, **kwargs)
Пример #37
0
 def _get_encoding_warning(self, plugin=None, event=None):
     if plugin == self:
         return render_plugin_template(
             'event_settings_encoding_warning.html')
Пример #38
0
 def _get_access_status(self, regform, registration, header, **kwargs):
     if regform.cern_access_request and regform.cern_access_request.is_active:
         return render_plugin_template('cern_access_status.html',
                                       registration=registration,
                                       header=header)
Пример #39
0
 def _get_access_action_button(self, regform, **kwargs):
     if regform.cern_access_request and regform.cern_access_request.is_active:
         return render_plugin_template('cern_access_action_button.html',
                                       regform=regform)
Пример #40
0
 def _process(self):
     return render_plugin_template('test.html')
Пример #41
0
 def _inject_event_header(self, event, **kwargs):
     url = self._get_event_webcast_url(event)
     if not url:
         return
     return render_plugin_template('event_header.html', url=url)
Пример #42
0
 def _room_assistance_action(self, event, **kwargs):
     return render_plugin_template(
         'room_assistance_action.html',
         event=event,
         can_request_assistance=can_request_assistance_for_event(event))
Пример #43
0
 def _inject_conference_header_subtitle(self, event, **kwargs):
     url = self._get_event_webcast_url(event)
     if not url:
         return
     return render_plugin_template('conference_header.html', url=url)
Пример #44
0
 def default_settings(self):
     return {'notify_emails': [],
             'how_to_connect': render_plugin_template('how_to_connect.html'),
             'chat_links': [{'title': 'Desktop Client', 'link': 'xmpp:{room}@{server}?join'}]}
Пример #45
0
 def _show_hide_clippy(self):
     return render_plugin_template('hide_clippy.html')
Пример #46
0
 def _getBody(self, params):
     locale = get_current_locale()
     params['language'] = IndicoLocale.parse('en').languages[locale.language]
     params['python_msg_core_i18n'] = core_gettext('Hello world!')
     params['python_msg_plugin_i18n'] = _('Hello world!')
     return render_plugin_template('example:example.html', **params)