示例#1
0
def test_get_overridable_template_name(core_prefix, plugin_prefix):
    plugin = MagicMock(name='dummy')
    name = 'test.html'
    tpl = get_overridable_template_name(name, None, core_prefix=core_prefix, plugin_prefix=plugin_prefix)
    assert tpl == core_prefix + name
    tpl = get_overridable_template_name(name, plugin, core_prefix=core_prefix, plugin_prefix=plugin_prefix)
    assert tpl == ['{}:{}{}'.format(plugin.name, plugin_prefix, name), core_prefix + name]
示例#2
0
def test_get_overridable_template_name(core_prefix, plugin_prefix):
    plugin = MagicMock(name='dummy')
    name = 'test.html'
    tpl = get_overridable_template_name(name,
                                        None,
                                        core_prefix=core_prefix,
                                        plugin_prefix=plugin_prefix)
    assert tpl == core_prefix + name
    tpl = get_overridable_template_name(name,
                                        plugin,
                                        core_prefix=core_prefix,
                                        plugin_prefix=plugin_prefix)
    assert tpl == [f'{plugin.name}:{plugin_prefix}{name}', core_prefix + name]
示例#3
0
 def get_email_body_template(cls, event, **kwargs):
     """Returns the template of the email body for this agreement definition"""
     template_name = cls.email_body_template_name or 'emails/agreement_default_body.html'
     template_path = get_overridable_template_name(template_name,
                                                   cls.plugin,
                                                   'events/agreements/')
     return get_template_module(template_path, event=event)
示例#4
0
文件: base.py 项目: NIIF/indico
    def render_form(cls, **kwargs):
        """Renders the request form

        :param kwargs: arguments passed to the template
        """
        tpl = get_overridable_template_name('event_request_details.html', cls.plugin, 'events/requests/')
        return render_template(tpl, **kwargs)
示例#5
0
    def render_form(cls, event, **kwargs):
        """Render the request form.

        :param event: the event the request is for
        :param kwargs: arguments passed to the template
        """
        tpl = get_overridable_template_name('event_request_details.html', cls.plugin, 'events/requests/')
        return WPRequestsEventManagement.render_template(tpl, event, **kwargs)
示例#6
0
文件: base.py 项目: wtakase/indico
    def render_form(cls, **kwargs):
        """Renders the request form

        :param kwargs: arguments passed to the template
        """
        tpl = get_overridable_template_name('event_request_details.html',
                                            cls.plugin, 'events/requests/')
        return render_template(tpl, **kwargs)
示例#7
0
文件: base.py 项目: indico/indico
    def render_form(cls, event, **kwargs):
        """Renders the request form

        :param event: the event the request is for
        :param kwargs: arguments passed to the template
        """
        tpl = get_overridable_template_name('event_request_details.html', cls.plugin, 'events/requests/')
        return WPRequestsEventManagement.render_template(tpl, event, **kwargs)
示例#8
0
    def get_notification_template(cls, name, **context):
        """Get the template module for a notification email.

        :param name: the template name
        :param context: data passed to the template

        """
        tpl = get_overridable_template_name(name, cls.plugin, 'events/requests/emails/', 'emails/')
        return get_template_module(tpl, **context)
示例#9
0
文件: base.py 项目: indico/indico
    def get_notification_template(cls, name, **context):
        """Gets the template module for a notification email

        :param name: the template name
        :param context: data passed to the template

        """
        tpl = get_overridable_template_name(name, cls.plugin, 'events/requests/emails/', 'emails/')
        return get_template_module(tpl, **context)
示例#10
0
    def render_buttons(self, vc_room, event_vc_room, **kwargs):
        """Renders a list of plugin specific buttons (eg: Join URL, etc) 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 kwargs: arguments passed to the template
        """
        name = get_overridable_template_name('management_buttons.html', self, core_prefix='vc/')
        return render_template(name, plugin=self, vc_room=vc_room, event_vc_room=event_vc_room, **kwargs)
示例#11
0
 def render_form(cls, agreement, form, **kwargs):
     template_name = cls.form_template_name or '{}.html'.format(
         cls.name.replace('-', '_'))
     template_path = get_overridable_template_name(template_name,
                                                   cls.plugin,
                                                   'events/agreements/')
     return render_template(template_path,
                            agreement=agreement,
                            form=form,
                            **kwargs)
示例#12
0
def notify_deleted(plugin, room, room_assoc, event, user):
    """Notifies about the deletion of a vc_room from the system.

    :param room: the vc_room
    :param event: the event
    :param user: the user performing the action
    """
    name = get_overridable_template_name('emails/deleted.html', plugin, core_prefix='vc/')
    tpl = get_template_module(name, plugin=plugin, vc_room=room, event=event, vc_room_event=room_assoc, user=user)
    _send('delete', user, plugin, event, room, tpl)
示例#13
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:
        plugin = event_vc_room.vc_room.plugin
        name = get_overridable_template_name('vc_room_timetable_buttons.html',
                                             plugin,
                                             core_prefix='vc/')
        return render_template(name,
                               event=event,
                               event_vc_room=event_vc_room,
                               **kwargs)
示例#14
0
def notify_created(plugin, room, room_assoc, event, user):
    """Notifies about the creation of a vc_room.

    :param room: the vc_room
    :param event: the event
    :param user: the user performing the action
    """

    name = get_overridable_template_name('emails/created.html', plugin, core_prefix='vc/')
    tpl = get_template_module(name, plugin=plugin, vc_room=room, event=event, vc_room_event=room_assoc, user=user,
                              linked_to_title=get_linked_to_description(room_assoc))
    _send('create', user, plugin, event, room, tpl)
示例#15
0
def notify_deleted(plugin, room, room_assoc, event, user):
    """Notifies about the deletion of a vc_room from the system.

    :param room: the vc_room
    :param event: the event
    :param user: the user performing the action
    """
    name = get_overridable_template_name('emails/deleted.html',
                                         plugin,
                                         core_prefix='vc/')
    tpl = get_template_module(name,
                              plugin=plugin,
                              vc_room=room,
                              event=event,
                              vc_room_event=room_assoc,
                              user=user)
    _send('delete', user, plugin, event, room, tpl)
示例#16
0
def notify_created(plugin, room, room_assoc, event, user):
    """Notifies about the creation of a vc_room.

    :param room: the vc_room
    :param event: the event
    :param user: the user performing the action
    """

    name = get_overridable_template_name('emails/created.html',
                                         plugin,
                                         core_prefix='vc/')
    tpl = get_template_module(
        name,
        plugin=plugin,
        vc_room=room,
        event=event,
        vc_room_event=room_assoc,
        user=user,
        linked_to_title=get_linked_to_description(room_assoc))
    _send('create', user, plugin, event, room, tpl)
示例#17
0
文件: plugins.py 项目: NIIF/indico
 def render_custom_create_button(self, **kwargs):
     tpl = get_overridable_template_name('create_button.html', self, 'vc/')
     return render_template(tpl, plugin=self, **kwargs)
示例#18
0
文件: base.py 项目: bkolobara/indico
 def render_form(cls, agreement, form, **kwargs):
     template_name = cls.form_template_name or '{}.html'.format(cls.name.replace('-', '_'))
     template_path = get_overridable_template_name(template_name, cls.plugin, 'events/agreements/')
     return render_template(template_path, agreement=agreement, form=form, **kwargs)
示例#19
0
文件: base.py 项目: bkolobara/indico
 def get_email_body_template(cls, event, **kwargs):
     """Returns the template of the email body for this agreement definition"""
     template_name = cls.email_body_template_name or 'emails/agreement_default_body.html'
     template_path = get_overridable_template_name(template_name, cls.plugin, 'events/agreements/')
     return get_template_module(template_path, event=event)
示例#20
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:
        plugin = event_vc_room.vc_room.plugin
        name = get_overridable_template_name('vc_room_timetable_buttons.html', plugin, core_prefix='vc/')
        return render_template(name, event=event, event_vc_room=event_vc_room, **kwargs)