oTree Forum >

Suppress currency variables points/currency nomination

#1 by esker

Is there a quick way to suppress the points/currency of a currency field when inserting them on an html file?

For example, I have a table where I have the following loop:
{% for p in player_in_previous_rounds %}
{{ p.payoff }}
{% endfor %}
The table would be much neeter if "points" would not be repeated on every line.


#2 by BonnEconLab

You can achieve this by creating the respective list in Python. That is, in the __init__.py file, include something like the following:

    def vars_for_template(player):
        return dict(
            payoffs_so_far = [int(p.payoff) for p in player.in_previous_rounds()],

This converts the payoff variable into an integer (which makes sense if you use points instead of real currency units).

In the HTML template, you can then include something along the following lines:

    <table class="table">
            {% for payoff in payoffs_so_far %}
                <tr><td>{{ forloop.counter }}</td><td>{{ payoff }}</td></tr>
            {% endfor %}

A ZIP archive of a minimal working example is attached.

Write a reply

Set forum username