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]
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]
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
def render_custom_create_button(self, **kwargs): tpl = get_overridable_template_name('create_button.html', self, 'vc/') return render_template(tpl, plugin=self, **kwargs)
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)
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)