Hello,
I’m running into an error when trying to generate documents for my conference attendants:
ERROR errors.py:110 – Could not load template preview data: {‘registration’: {‘transaction’: {‘data’: [‘Field may not be null.’]}}}
Full details below:
2024-07-02 10:50:48,619 ca59a322dd0347bf 1 indico.flask - ERROR errors.py:110 -- Could not load template preview data: {'registration': {'transaction': {'data': ['Field may not be null.']}}}
Traceback (most recent call last):
File "/opt/indico/.venv/lib/python3.12/site-packages/indico/modules/receipts/util.py", line 265, in get_safe_template_context
return tds.load(dumped)
^^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/marshmallow/schema.py", line 722, in load
return self._do_load(
^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/marshmallow/schema.py", line 909, in _do_load
raise exc
marshmallow.exceptions.ValidationError: {'registration': {'transaction': {'data': ['Field may not be null.']}}}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/indico/.venv/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/indico/web/flask/util.py", line 80, in wrapper
return obj().process()
^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/indico/web/rh.py", line 299, in process
res = self._do_process()
^^^^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/indico/web/rh.py", line 267, in _do_process
rv = self._process()
^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/webargs/core.py", line 649, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/indico/modules/receipts/controllers/event.py", line 220, in _process
html_sources = {registration: _compile_receipt_for_reg(registration) for registration in self.registrations}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/indico/modules/receipts/controllers/event.py", line 216, in _compile_receipt_for_reg
safe_ctx = get_safe_template_context(self.event, registration, custom_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/indico/.venv/lib/python3.12/site-packages/indico/modules/receipts/util.py", line 269, in get_safe_template_context
raise RuntimeError(f'Could not load template preview data: {exc}') from exc
RuntimeError: Could not load template preview data: {'registration': {'transaction': {'data': ['Field may not be null.']}}}
The template I am using is the following:
{% set personal_data = registration.personal_data %}
{% set txn = registration.transaction %}
<h1>Certificate
of Participation</h1>
<aside id="title">
<div class="title">
<!-- Title -->
<h2>{{ event.title }}</h2>
<!-- Date(s) -->
{% if event.start_dt.date() != event.end_dt.date() %}
{{ event.start_dt | format_date('dd MMM') }}
-
{{ event.end_dt | format_date('dd MMM') }}
{% else %}
{{ event.start_dt | format_date('dd MMM YYYY') }}
{% endif %}
<!-- Venue -->
{% if custom_fields.venue %}
- {{ custom_fields.venue }}
{% elif event.venue_name %}
- {{ event.venue_name }}
{% endif %}
{% if custom_fields.add_url %}
<p>{{ event.url }}</p>
{% endif %}
</div>
<!-- Logo -->
{% if custom_fields.logo %}
<img src="{{ custom_fields.logo }}">
{% endif %}
</aside>
<aside id="addresses">
<!-- Address of organizer -->
<address id="from">
{{ custom_fields.address_from }}
</address>
<!-- Address of participant -->
<address id="to">
<strong>{{ personal_data.first_name }} {{ personal_data.last_name }}</strong>
{%- if custom_fields.add_affiliation %}
{{ personal_data.affiliation }}
{%- endif %}
{%- if custom_fields.address_to_override %}
{{ custom_fields.address_to_override }}
{% elif personal_data.address %}
{{ personal_data.address }}
{{ personal_data.country }}
{% else %}
{{ personal_data.country }}
{% endif %}
</address>
</aside>
This is to certify that {{ registration.personal_data.title }} {{ registration.personal_data.first_name }} {{ registration.personal_data.last_name }}
affiliated with {{ registration.field_data[4].friendly_value }} has registered and taken part in {{ event.title }}, that took place at {{ event.venue_name }}, {{ event.address }}
on
{% if event.start_dt.date() != event.end_dt.date() %}
{{ event.start_dt | format_date('dd MMM') }}
-
{{ event.end_dt | format_date('dd MMM YYYY') }}.
{% else %}
{{ event.start_dt | format_date('dd MMM YYYY') }}.
{% endif %}
<aside id="signature">
<div class="signature">
Prof. Nicolas Blarel
<br>
Conference Coordinator
<br>
European Initiative for Security Studies
</div>
</aside>
</tbody>