[FIX] website_forum: display the users as a table in block of 3 cols
authorMartin Trigaux <mat@openerp.com>
Mon, 26 May 2014 11:37:58 +0000 (13:37 +0200)
committerMartin Trigaux <mat@openerp.com>
Mon, 26 May 2014 11:37:58 +0000 (13:37 +0200)
addons/website_forum/controllers/main.py
addons/website_forum/views/website_forum.xml

index 4bb414c..53397f3 100644 (file)
@@ -449,7 +449,10 @@ class WebsiteForum(http.Controller):
         pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30)
 
         obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], order='karma DESC', context=context)
-        users = User.browse(cr, SUPERUSER_ID, obj_ids, context=context)
+        # put the users in block of 3 to display them as a table
+        users = [[] for i in range(len(obj_ids)/3+1)]
+        for index, user in enumerate(User.browse(cr, SUPERUSER_ID, obj_ids, context=context)):
+            users[index/3].append(user)
         searches['users'] = 'True'
 
         values = self._prepare_forum_values(forum=forum, searches=searches)
index 4a96899..f4650d7 100644 (file)
 
 <template id="users">
     <t t-call="website_forum.header">
-        <t t-foreach="users" t-as="user">
-            <t t-if="user_index % 3 == 0">
-                <div class="row"></div>
-            </t>
-            <div class="col-sm-4">
+        <div t-foreach="users" t-as="row_users" class="row mt16">
+            <div t-foreach="row_users" t-as="user" class="col-sm-4">
                 <img class="pull-left img img-circle img-avatar" t-attf-src="/forum/user/#{user.id}/avatar"/>
                 <div>
                     <a t-attf-href="/forum/#{slug(forum)}/user/#{user.id}" t-field="user.name"/>
                     <t t-raw="0"/>
                 </div>
             </div>
-        </t>
+        </div>
         <div class="pull-left">
             <t t-call="website.pager"/>
         </div>