Template not rendering correctly

I have only one template inside the templates folder for a plugin I am developing.

The contents of the template are:

{% extends 'overview/base.html' %}
{% block content %}
    <ul id="session.user.username">
      <li>Username: <b> {{ session.user.name }}</b></li>
    </ul>
{% endblock %}

The controller returns the template successfully, but only the session user name is rendered in the browser, and none of the rest of Indico top menus, etc. (just a blank page with the user name)

It seems that {% extends 'overview/base.html' %} is not working :frowning:

Which WP class are you using to render this template?

PS: A . inside an HTML element’s ID is a very bad idea.

This is my controllers.py file:

class RHInvoiceManagement(RH):
    """Main Invoice Management area"""

    def _process(self):
        return render_plugin_template('invoice_management.html', session=session)

P.S. Agree. I’m testing stuff out and must have blindly copy-pasted it this way in… I’ll put the dashes soon

return render_plugin_template(...) is the problem. You are just rendering the raw template (and the one it’s inheriting from), without any of the indico layout around it. Which WP class to use highly depends on how you want to show it. Also, since you are providing your own content block, i’m pretty sure that you do not want to inherit from overview/base.html since the point of that template is to create a page like this (with a result list below):

image

If you tell me where you plan to use your page (fully standalone, event management, indico administration) I can tell you which base template and which WP class to use. But generally, you want to have a class similar to this one (usually inside a views.py):

class WPInvoiceManagement(WPJinjaMixinPlugin, WPDecorated):
    def _get_breadcrumbs(self):
        return render_breadcrumbs(_('Invoice Management'))

    def _get_body(self, params):
        return self._get_page_content(params)

In your RH you then use it like this:

return WPInvoiceManagement.render_template('whatever.html')

PS: Unless you need to target your element with CSS (classes are usually better in that case) or access it in JS, you probably don’t need an ID at all.

I will need to have a context-aware Invoice plugin.

Fully Standalone mode will show a table with ALL the available invoices in the system (regardless of Conference, Event, etc.)

Event Management mode will basically be the same as Fully Standalone, except it will only show Invoices relevant to the current Conference, Event context the user is in.

That’d do it for now

Thanks

Create separate RHs and WPs for that, otherwise you’ll make your code overly complex. If you have common stuff simply put it in functions or, in case of templates, in Jinja macros in separate files.

What I posted above works fine for the standalone page, but inherit from layout/base.html. You many want to add {% block page_class %}fixed-width-standalone-page{% endblock %} to your template to restrict the max width of the content area.

For event management pages, use WPEventManagement instead of WPDecorated in the WP’s base classes and do not override _get_breadcrumbs. The RH class should inherit from RHManageEventBase which does the proper access checks for event management and also gets the event from the URL path (you should have /event/<confId>/manage/... in the path). To render the template using the WP, use this as the event management WP requires access to the event:

WPEventInvoiceManagement.render_template('whatever.html', self.event, 'xxx')

You can omit the xxx argument if you do not have an event management sidemenu item; but if you do have one (you should), then provide the name of that menu item there so it’s shown as active while you are on this page.

Is there an Indico plugin that already does this cleanly (has a separate logic for Fully Standalone and Event Management), that you are aware of, that I can study instead of bothering you with a million questions? Thanks @ThiefMaster

No, I don’t think so… I’d recommend you to make the standalone page just an overview that links to the respective event management pages.