[REM] python-qweb support for as-less foreach

This commit is contained in:
Xavier Morel 2014-06-05 17:49:08 +02:00
parent 0de6710c3c
commit a9a83d00c9
3 changed files with 32 additions and 23 deletions

View File

@ -428,29 +428,37 @@
<table class="table js_kanban">
<thead>
<tr>
<t t-set="width" t-value="str(round(100.0 / len(objects), 2)) + '%'"/>
<t t-foreach="objects">
<t t-set="width" t-valuef="{{ round(100.0 / len(objects), 2) }}%"/>
<t t-foreach="objects" t-as="obj">
<th t-att-width="width">
<div t-field="column_id.name" class="text-center"></div>
<div t-field="obj['column_id'].name" class="text-center"></div>
</th>
</t>
</tr>
</thead>
<tbody>
<tr>
<t t-foreach="objects">
<td class="js_kanban_col" t-att-data-template="template" t-att-data-domain="domain" t-att-data-page_count="page_count" t-att-data-model="model" t-att-data-step="step" t-att-data-orderby="orderby">
<t t-foreach="object_ids" t-as="object_id">
<t t-foreach="objects" t-as="obj">
<td class="js_kanban_col" t-att-data-template="template"
t-att-data-domain="obj['domain']"
t-att-data-page_count="obj['page_count']"
t-att-data-model="obj['model']"
t-att-data-step="obj['step']"
t-att-data-orderby="obj['orderby']">
<t t-foreach="obj['object_ids']" t-as="object_id">
<t t-call="#{ template }"></t>
</t>
<!-- pager -->
<div t-if="1 != page_end" class="pagination pagination-centered">
<div t-if="1 != obj['page_end']" class="pagination pagination-centered">
<ul>
<li t-attf-class="prev #{'active' if page == 1 else '' }"> <a t-att-href=" '%s,%s-%s' % (kanban_url, column_id.id, (page &gt; 1 and page-1 or 1)) ">Prev</a></li>
<t t-foreach="range(page_start, page_end+1)" t-as="p">
<li t-att-class=" 'active' if page == p else '' "> <a t-att-href=" '%s,%s-%s' % (kanban_url, column_id.id, p)" t-esc="p"></a></li>
<li t-attf-class="prev #{'active' if obj['page'] == 1 else '' }">
<a t-att-href=" '%s,%s-%s' % (obj['kanban_url'], obj['column_id'].id, (obj['page'] &gt; 1 and obj['page']-1 or 1)) ">Prev</a></li>
<t t-foreach="range(obj['page_start'], obj['page_end']+1)" t-as="p">
<li t-att-class=" 'active' if obj['page'] == p else '' ">
<a t-att-href=" '%s,%s-%s' % (obj['kanban_url'], obj['column_id'].id, p)" t-esc="p"></a></li>
</t>
<li t-attf-class="next #{'active' if page == page_end else '' }"> <a t-att-href=" '%s,%s-%s' % (kanban_url, column_id.id, (page &lt; page_end and page+1 or page_end) )">Next</a></li>
<li t-attf-class="next #{'active' if obj['page'] == obj['page_end'] else '' }">
<a t-att-href=" '%s,%s-%s' % (obj['kanban_url'], obj['column_id'].id, (obj['page'] &lt; obj['page_end'] and obj['page']+1 or obj['page_end']) )">Next</a></li>
</ul>
</div>
</td>

View File

@ -162,10 +162,11 @@
<template id="event_category" inherit_id="website_event.event_left_column" optional="disabled" name="Filter by Category">
<xpath expr="//div[@id='left_column']" position="inside">
<ul class="nav nav-pills nav-stacked mt32">
<t t-foreach="types">
<li t-if="type" t-att-class="searches.get('type') == str(type and type[0]) and 'active' or ''">
<a t-attf-href="/event?{{ keep_query('country', 'date', type=type[0]) }}"><t t-esc="type[1]"/>
<span class="badge pull-right"><t t-esc="type_count"/></span>
<t t-foreach="types" t-as="type">
<li t-if="type['type']"
t-att-class="searches.get('type') == str(type['type'] and type['type'][0]) and 'active' or ''">
<a t-attf-href="/event?{{ keep_query('country', 'date', type=type['type'][0]) }}"><t t-esc="type['type'][1]"/>
<span class="badge pull-right"><t t-esc="type['type_count']"/></span>
</a>
</li>
</t>
@ -176,10 +177,10 @@
<template id="event_location" inherit_id="website_event.event_left_column" optional="disabled" name="Filter by Country">
<xpath expr="//div[@id='left_column']" position="inside">
<ul class="nav nav-pills nav-stacked mt32">
<t t-foreach="countries">
<li t-if="country_id" t-att-class="searches.get('country') == str(country_id and country_id[0]) and 'active' or ''">
<a t-attf-href="/event?{{ keep_query('type', 'data', country=country_id[0]) }}"><t t-esc="country_id[1]"/>
<span class="badge pull-right"><t t-esc="country_id_count"/></span>
<t t-foreach="countries" t-as="country">
<li t-if="country['country_id']" t-att-class="searches.get('country') == str(country['country_id'] and country['country_id'][0]) and 'active' or ''">
<a t-attf-href="/event?{{ keep_query('type', 'data', country=country['country_id'][0]) }}"><t t-esc="country['country_id'][1]"/>
<span class="badge pull-right"><t t-esc="country['country_id_count']"/></span>
</a>
</li>
</t>

View File

@ -88,10 +88,10 @@
<xpath expr="//div[@id='left_column']/ul[1]" position="after">
<ul class="nav nav-pills nav-stacked mt16">
<li class="nav-header"><h3>Location</h3></li>
<t t-foreach="countries">
<li t-if="country_id" t-att-class="country_id[0] == current_country_id and 'active' or ''">
<a t-attf-href="/members#{ membership and '/association/%s' % membership.id or '' }#{ country_id[0] and '/country/%s' % slug(country_id) or '' }#{ search }"><t t-esc="country_id[1]"/>
<span class="badge pull-right"><t t-esc="country_id_count or '0'"/></span>
<t t-foreach="countries" t-as="country">
<li t-if="country['country_id']" t-att-class="country['country_id'][0] == current_country_id and 'active' or ''">
<a t-attf-href="/members#{ membership and '/association/%s' % membership.id or '' }#{ country['country_id'][0] and '/country/%s' % slug(country['country_id']) or '' }#{ search }"><t t-esc="country['country_id'][1]"/>
<span class="badge pull-right"><t t-esc="country['country_id_count'] or '0'"/></span>
</a>
</li>
</t>