Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

render dictionary with in dictionary

I have added a method to meta.py in views. Method is very similar to existing badge method. it returns following data structure:

(Pdb) print d

    {'badge_1': {'badge_recipients': [<User: NNN>], 'badge': <BadgeData: gold: gold-badge>, 'page_class': 'meta'}, 'badge_2': {'badge_recipients': [<User: aa>, <User: NNN>, <User: admin>, <User: Test>, <User: bbb>], 'badge': <BadgeData: bronze: maroon-badge>, 'page_class': 'meta'}}

I want to simply render this and present as a list:

current badge.html has following:

<div id="award-list">
    {% for recipient in badge_recipients %}
        <div class="user">
                <span class="thumb">{{ gravatar(recipient, 32) }}</span>
                <span><a href="{{ recipient.get_absolute_url() }}">{{recipient.username|escape}}</a></span>
                <span>{{ macros.user_score_and_badge_summary(user) }}</span>
        </div>
    {% endfor %}
</div>

how can I change this to print the users as a list based on the badge I like to render as follows:

Badge 1 Wiinners
   user a
   user b
Badge 2 Winners
   user b

render dictionary with in dictionary

I have added a method to meta.py in views. Method is very similar to existing badge method. it returns following data structure:

(Pdb) print d

    {'badge_1': {'badge-1': {'badge_recipients': [<User: NNN>], 'badge': <BadgeData: gold: gold-badge>, badge-2>, 'page_class': 'meta'}, 'badge_2': 'badge-2': {'badge_recipients': [<User: aa>, <User: NNN>, <User: admin>, <User: Test>, <User: bbb>], 'badge': <BadgeData: bronze: maroon-badge>, badge-1>, 'page_class': 'meta'}}

I want to simply render this and present as a list:

current badge.html has following:

<div id="award-list">
    {% for recipient in badge_recipients %}
        <div class="user">
                <span class="thumb">{{ gravatar(recipient, 32) }}</span>
                <span><a href="{{ recipient.get_absolute_url() }}">{{recipient.username|escape}}</a></span>
                <span>{{ macros.user_score_and_badge_summary(user) }}</span>
        </div>
    {% endfor %}
</div>

how can I change this to print the users as a list based on the badge I like to render as follows:

Badge 1 Wiinners
   user a
   user b
Badge 2 Winners
   user b