[ADD] added functionality to make question favourite, and improved some code
[odoo/odoo.git] / addons / website_forum / views / website_forum.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <openerp>
3     <data>
4
5         <template id="editor_head" inherit_id="website.editor_head"
6             name="Event Editor">
7             <xpath expr="//script[@id='website_tour_js']" position="after">
8                 <script type="text/javascript"
9                     src="/website_forum/static/src/js/website.tour.forum.js"/>
10                 <script type="text/javascript" 
11                     src="/website_forum/static/src/js/website_forum.editor.js"/>
12             </xpath>
13         </template>
14
15         <!-- Layout add nav and footer -->
16         <template id="header_footer_custom" inherit_id="website.layout"
17             name="Footer Questions Link">
18             <xpath expr="//footer//ul[@name='products']" position="inside">
19                 <li>
20                     <a t-attf-href="/forum/%(website_forum.forum_help)d/">Q&amp;A</a>
21                 </li>
22             </xpath>
23         </template>
24
25         <!-- List of Questions -->
26         <template id="post_list">
27             <div class="question clearfix">
28                 <div class="pull-left text-center">
29                     <div t-attf-class="box #{question.child_count and 'oe_green' or 'oe_grey'}">
30                         <span t-esc="question.child_count"/>
31                         <span t-if="question.correct" class="fa fa-2x fa-check-circle"/>
32                         <div t-if="question.child_count&gt;1">Answers</div>
33                         <div t-if="question.child_count&lt;=1">Answer</div>
34                     </div>
35                     <div class="text-muted text-center">
36                         <span t-field="question.views"/> Views
37                     </div>
38                 </div>
39                 <div style="margin-left: 95px;">
40                     <div class="question-name">
41                         <a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }" t-field="question.name"/>
42                             <span t-if="not question.active"><b> [Deleted]</b></span>
43                             <span t-if="question.state == 'close'"><b> [Closed]</b></span>
44                     </div>
45                     <div class="text-muted">
46                         by <a t-attf-href="/forum/#{ slug(forum) }/user/#{ question.user_id.id }" t-field="question.user_id"/>
47                         <t t-if="question.user_id.country_id"> 
48                             <span t-field="question.user_id.country_id.image" t-field-options='{"widget": "image", "class":"forum_user_flag"}'/>
49                         </t>
50                         on <span t-field="question.write_date" t-field-options='{"format":"short"}'/>
51                         <div t-if="question.vote_count">
52                             <strong>with <span t-esc="question.vote_count"/> votes</strong>
53                         </div>
54                     </div>
55                     <t t-foreach="question.tags" t-as="tag">
56                         <a t-attf-href="/forum/#{ slug(forum) }/tag/#{ tag.id }/questions" class="badge" t-field="tag.name"/>
57                     </t>
58                 </div>
59             </div>
60         </template>
61
62         <!-- Page Index -->
63         <template id="header" name="Forum Index">
64             <t t-call="website.layout">
65                 <t t-set="head">
66                     <link rel='stylesheet' href="/web/static/lib/jquery.textext/jquery.textext.css"/>
67                     <link rel='stylesheet' href='/website_forum/static/src/css/website_forum.css'/>
68                     <!--
69                     FP Note: Why do we need this ? Can we remove this code?
70                     The problem is that you add your script for every page, not only for the forum
71                     -->
72                     <script type="text/javascript" src="/website_forum/static/src/js/website_forum.js"/>
73                     <script type="text/javascript" src="/web/static/lib/jquery.textext/jquery.textext.js"/>
74                     <script type="text/javascript" src="/web/static/lib/ckeditor/ckeditor.js"/>
75                     <script type="text/javascript">
76                         CKEDITOR.config.toolbar = [['Bold','Italic','Underline','Strike'],['NumberedList','BulletedList', 'Blockquote']
77                         ,['Outdent','Indent','Link','Unlink','Image'],] ;
78                     </script>
79                 </t>
80                 <div class="container mt16">
81                     <div class="navbar navbar-default">
82                         <div class="navbar-header">
83                             <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#oe-help-navbar-collapse">
84                                 <span class="sr-only">Toggle navigation</span>
85                                 <span class="icon-bar"></span>
86                                 <span class="icon-bar"></span>
87                                 <span class="icon-bar"></span>
88                             </button>
89                             <a class="navbar-brand" t-attf-href="/forum/#{slug(forum)}">
90                                 <span t-field="forum.name"/>
91                             </a>
92                         </div>
93                         <div class="collapse navbar-collapse" id="oe-help-navbar-collapse">
94                             <ul class="nav navbar-nav">
95                                 <li t-att-class="filters in ('all', 'unanswered','followed','question','tag') and 'active' or '' ">
96                                     <a t-attf-href="/forum/#{ slug(forum) }">Questions</a>
97                                 </li>
98                                 <li t-att-class="searches.get('users') and 'active' or '' ">
99                                     <a t-attf-href="/forum/#{ slug(forum) }/users">People</a>
100                                 </li>
101                                 <li t-att-class="searches.get('tags') and 'active' or '' ">
102                                     <a t-attf-href="/forum/#{ slug(forum) }/tag">Tags</a>
103                                 </li>
104                                 <li t-att-class="searches.get('badges') and 'active' or '' ">
105                                     <a t-attf-href="/forum/#{ slug(forum) }/badge">Badges</a>
106                                 </li>
107                             </ul>
108                             <form class="navbar-form navbar-right" role="search" t-attf-action="/forum/#{ slug(forum) }" method="get">
109                                 <div class="form-group">
110                                     <input type="search" class="form-control"
111                                         name="search" placeholder="Search a question..."
112                                         t-att-value="searches.get('search') or ''"/>
113                                     <button type="submit" class="btn btn-default">Search</button>
114                                 </div>
115                             </form>
116                         </div>
117                     </div>
118                 </div>
119
120                 <div id="wrap" class="container">
121                     <div class="row">
122                         <div class="col-sm-9">
123                             <div t-foreach="notifications.get('notifications') or []" t-as="notification" class="alert alert-success alert-dismissable">
124                                 <button type="button" class="close notification_close" t-att-id="notification.id" data-dismiss="alert" aria-hidden="true">&amp;times;</button>
125                                 <div t-field="notification.body"/>
126                                 <a t-attf-href="/forum/#{ slug(forum) }/user/#{ slug(notifications.get('user')) }#badges" class="fa fa-arrow-right">View Your Badges</a>
127                             </div>
128                             <t t-raw="0"/>
129                         </div>
130                         <div class="col-sm-3" id="right-column">
131                             <a t-if="not ask_question" class="btn btn-primary btn-lg btn-block mb16" t-attf-href="/forum/#{ slug(forum) }/ask">Ask a Question</a>
132                             <div t-field="forum.right_column"/>
133                             <div t-if="question_data">
134                                 <div class="panel panel-default">
135                                     <div class="panel-heading text-center">
136                                         <h3 class="panel-title">Question tools</h3>
137                                     </div>
138                                     <div class="panel-body text-center">
139                                         <a class="btn btn-block btn-default btn-md" t-if="not following"
140                                             t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/subscribe">Follow</a>
141                                         <a class="btn btn-block btn-default btn-md" t-if="following"
142                                             t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/unsubscribe">UnFollow</a>
143                                         <div class="mt8">
144                                             <strong><t t-raw="len(question.message_follower_ids)"/></strong> follower
145                                         </div>
146                                     </div>
147                                     <div class="panel-heading text-center">
148                                         <h3 class="panel-title ">Stats</h3>
149                                     </div>
150                                     <div class="panel-body"> 
151                                         <table class="table">
152                                             <thead><tr><td> Asked: <strong><span t-field="question.create_date" t-field-options='{"format":"short"}'/></strong></td></tr></thead>
153                                             <tr><td> Seen: <strong><t t-raw="question.views"/></strong>
154                                                 <span t-if="question.views&gt;1">times</span>
155                                                 <span t-if="question.views&lt;=1">time</span>
156                                             </td></tr>
157                                             <tr><td> Last updated: <strong><span t-field="question.write_date" t-field-options='{"format":"short"}'/></strong></td></tr>
158                                         </table>
159                                     </div>
160                                 </div>
161                             </div>
162                         </div>
163                     </div>
164                 </div>
165                 <div class="oe_structure"/>
166             </t>
167         </template>
168
169         <template id="faq">
170             <t t-call="website_forum.header">
171                 <div t-field="forum.faq"/>
172             </t>
173         </template>
174
175         <template id="forum_index">
176             <t t-call="website.layout">
177                 <div class="container">
178                     <h1 class="mb32">Our forums</h1>
179                     <div class="row">
180                         <div t-foreach="forums" t-as="forum" class="col-sm-3 text-center mb32">
181                             <a t-attf-href="/forum/#{ slug(forum) }">
182                                 <div class="fa fa-5x fa-comment mb16"/>
183                                 <div t-field="forum.name"/>
184                             </a>
185                         </div>
186                     </div>
187                 </div>
188             </t>
189         </template>
190
191         <template id="index">
192             <t t-call="website_forum.header">
193                 <h1 class="page-header mt0">
194                     <t t-esc="total_questions"/>
195                     <span>Questions</span>
196                     <small class="dropdown" t-if="filters in ('all', 'unanswered','followed', 'tag')">
197                       <a href="#" class="dropdown-toggle" data-toggle="dropdown">
198                           <t t-if="filters == 'all'">All</t>
199                           <t t-if="filters == 'unanswered'">Unanswered</t>
200                           <t t-if="filters == 'followed'">Followed</t>
201                           <t t-if="filters == 'tag'">Tag</t>
202                           <t t-if="sorting == 'date'"> by activity date</t>
203                           <t t-if="sorting == 'answered'"> by most answered</t>
204                           <t t-if="sorting == 'vote'"> by most voted</t>
205                           <b class="caret"/>
206                       </a>
207                       <ul class="dropdown-menu">
208                           <li class="dropdown-header">Filter on</li>
209                           <li t-att-class="filters == 'all' and 'active' or '' ">
210                               <a t-att-href="url_for('') + '?' + keep_query( 'sorting', filters='all')">All</a>
211                           </li>
212                           <li t-att-class="filters == 'unanswered' and 'active' or '' ">
213                               <a t-att-href="url_for('') + '?' + keep_query( 'sorting', filters='unanswered')">Unanswered</a>
214                           </li>
215                           <li t-if="uid" t-att-class="filters == 'followed' and 'active' or '' ">
216                               <a t-att-href="url_for('') + '?' + keep_query( 'sorting', filters='followed')">Followed</a>
217                           </li>
218                           <li t-if="tag" t-att-class="tag and 'active' or '' ">
219                               <a href=""><t t-esc="tag.name"/> Tag</a>
220                           </li>
221                           <li class="dropdown-header">Sort by</li>
222                           <li t-att-class="sorting == 'date' and 'active' or '' ">
223                               <a t-att-href="url_for('') + '?' + keep_query( 'filters', sorting='date')">Last activity date</a>
224                           </li>
225                           <li t-att-class="sorting == 'answered' and 'active' or '' ">
226                               <a t-att-href="url_for('') + '?' + keep_query( 'filters', sorting='answered')">Most answered</a>
227                           </li>
228                           <li t-att-class="sorting == 'vote' and 'active' or '' ">
229                               <a t-att-href="url_for('') + '?' + keep_query( 'filters', sorting='vote')">Most voted</a>
230                           </li>
231                       </ul>
232                     </small>
233                 </h1>
234                 <div t-foreach="question_ids" t-as="question" class="mb16">
235                     <t t-call="website_forum.post_list"/>
236                 </div>
237                 <t t-call="website.pager"/>
238             </t>
239         </template>
240
241         <template id="404">
242             <t t-call="website_forum.header">
243                 <div class="oe_structure oe_empty"/>
244                 <h1 class="mt32">Question not found!</h1>
245                 <p>Sorry, this question is not available anymore.</p>
246                 <p>
247                     <a t-attf-href="/forum">Return to the question list.</a>
248                 </p>
249             </t>
250         </template>
251
252         <template id="user_detail">
253             <div>
254                 <span t-field="user.image" t-field-options='{"widget": "image", "class":"pull-left img img-circle img-avatar"}'/>
255                 <div>
256                     <a t-attf-href="/forum/#{ slug(forum) }/user/#{ slug(user) }" t-field="user.name"/>
257                     <t t-if="user.country_id">
258                         <span t-field="user.country_id.image" t-field-options='{"widget": "image", "class":"forum_user_flag"}'/>
259                     </t>
260                     <b><t t-esc="user.karma"/></b>
261                     <t t-raw="separator"/>
262                         <div>
263                             <b> badges:</b>
264                             <span class="fa fa-circle badge-gold"/>
265                             <t t-esc="user.gold_badge"/>
266                             <span class="fa fa-circle badge-silver"/>
267                             <t t-esc="user.silver_badge"/>
268                             <span class="fa fa-circle badge-bronze"/>
269                             <t t-esc="user.bronze_badge"/>
270                         </div>
271                         <t t-raw="0"/>
272                 </div>
273             </div>
274         </template>
275
276         <template id="ask_question">
277             <t t-call="website_forum.header">
278                 <h1 class="mt0">Ask your Question</h1>
279                 <ul>
280                     <li> please, try to make your question interesting to others </li>
281                     <li> provide enough details and, if possible, give an example </li>
282                     <li> be clear and concise, avoid unnecessary introductions (Hi, ... Thanks...) </li>
283                 </ul>
284                 <form t-attf-action="/forum/#{ slug(forum) }/question/ask" method="post" role="form" class="tag_text">
285                     <input type="text" name="question_name" required="True" t-attf-value="#{question_name}"
286                         class="form-control" placeholder="Enter your Question"/>
287                     <h5 class="mt20">Please enter a descriptive question (should finish by a '?')</h5>
288                     <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
289                     <textarea name="content" required="True" class="form-control load_editor">
290                         <t t-esc="question_content"/>
291                     </textarea>
292                     <br/>
293                     <input type="text" name="question_tags" t-attf-value="#{question_tag or ''}" 
294                         placeholder="Tags" class="form-control load_tags"/>
295                     <br/>
296                     <button class="btn btn-primary" id="btn_ask_your_question">Post Your Question</button>
297                 </form>
298                 <script type="text/javascript">
299                     CKEDITOR.replace("content");
300                 </script>
301             </t>
302         </template>
303
304         <template id="edit_post">
305             <t t-call="website_forum.header">
306                 <h3 t-if="not is_answer">Edit question</h3>
307                 <h3 t-if="is_answer">Edit answer</h3>
308                 <form t-attf-action="/forum/#{ slug(forum) }/post/save" method="post" role="form" class="tag_text">
309                     <select class="form-control post_history">
310                         <t t-foreach="post_history" t-as="history">
311                             <option t-att-value="history.id"><t t-esc="history.name"/></option>
312                         </t>
313                     </select>
314                     <div t-if="not is_answer">
315                         <input type="text" name="question_name" id="question_name" required="True"
316                             t-attf-value="#{question.name}" class="form-control" placeholder="Edit your Question"/>
317                         <h5 class="mt20">Please enter a descriptive question (should finish by a '?')</h5>
318                         <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
319                     </div>
320                     <textarea name="content" required="True" class="form-control load_editor">
321                         <t t-if="is_answer"> <t t-esc="answer.content"/></t>
322                         <t t-if="not is_answer"><t t-esc="question.content"/></t>
323                     </textarea>
324                     <input name="question_id" t-att-value="question.id" type="hidden"/>
325                     <div t-if="is_answer">
326                         <input name="answer_id" t-att-value="answer.id" type="hidden"/>
327                     </div>
328                     <div t-if="not is_answer">
329                         <br/>
330                         <input type="text" name="question_tag" class="form-control col-md-9 load_tags" placeholder="Tags" t-attf-value="#{tags}"/>
331                         <br/>
332                     </div>
333                     <button class="btn btn-primary btn-lg">Save</button>
334                 </form>
335                 <script type="text/javascript">
336                     CKEDITOR.replace("content");
337                 </script>
338             </t>
339         </template>
340
341         <template id="close_question">
342             <t t-call="website_forum.header">
343                 <h3 class=""><b>Close question</b></h3><br/>
344                 <form t-attf-action="/forum/#{ slug(forum) }/question/close" method="post" role="form">
345                     <input name="post_id" t-att-value="post.id" type="hidden"/>
346                     <span class="pull-left">Close the question:</span>
347                     <a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(post) }" t-field="post.name"/>
348                     <div class="mt16">
349                         <label class="col-md-2 control-label mb16" for="reason">Reasons:</label>
350                         <div class="col-md-9 mb16">
351                             <select class="form-control" name="reason">
352                                 <t t-foreach="reasons or []" t-as="reason">
353                                     <option t-att-value="reason.id" t-att-selected="reason.id == post.reason_id.id"><t t-esc="reason.name"/></option>
354                                 </t>
355                             </select>
356                         </div>
357                     </div>
358                     <div>
359                         <button class="btn btn-primary btn-lg">Close</button>
360                     </div>
361                 </form>
362             </t>
363         </template>
364
365         <template id="post_answer">
366             <h3 class="mt10">Your answer</h3>
367             <p>
368                 <b>Please try to give a substantial answer.</b> If you wanted to comment on the question or answer, just
369                 <b>use the commenting tool.</b> Please remember that you can always <b>revise your answers</b>
370                 - no need to answer the same question twice. Also, please <b>don't forget to vote</b>
371                 - it really helps to select the best questions and answers!
372             </p>
373             <form t-attf-action="/forum/#{ slug(forum) }/question/postanswer" method="post" role="form">
374                 <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
375                 <textarea name="content" class="form-control load_editor" required="True"/>
376                 <input name="post_id" t-att-value="question.id" type="hidden"/>
377                 <button class="btn btn-primary" id="btn_ask_your_question">Post Your Answer</button>
378             </form>
379             <script type="text/javascript">
380                 CKEDITOR.replace("content");
381             </script>
382         </template>
383
384         <template id="vote">
385             <div t-attf-class="box oe_grey">
386                 <a t-attf-class="vote_up fa fa-thumbs-up no-decoration #{post.user_vote == 1 and 'text-success' or ''}" 
387                     t-attf-id="#{post.id}" t-attf-value="1"/>
388                 <span id="vote_count" t-esc="post.vote_count"/>
389                 <a t-attf-class="vote_down fa fa-thumbs-down no-decoration #{post.user_vote == -1 and 'text-warning' or ''}" 
390                     t-attf-id="#{post.id}" t-attf-value="-1"/>
391                 <div>
392                     votes
393                 </div>
394             </div>
395         </template>
396
397         <template id="post_description_full" name="Question Navigation">
398             <t t-call="website_forum.header">
399
400                 <div t-attf-class="question #{not question.active and 'alert alert-danger' or ''}">
401                     <div class="text-center pull-left">
402                         <t t-call="website_forum.vote">
403                             <t t-set="post" t-value="question"/>
404                         </t>
405                         <div class="text-muted">
406                             <span t-esc="question.child_count"/>
407                             <span t-if="question.child_count&gt;1">Answers</span>
408                             <span t-if="question.child_count&lt;=1">Answer</span>
409                         </div>
410                         <div>
411                             <a t-attf-id="#{question.id}" t-attf-class="favourite_question no-decoration fa fa-2x fa-star #{question.user_favourite and 'forum_favourite_question' or ''}"/>
412                         </div>
413                     </div>
414                     <div style="margin-left: 95px;">
415                         <h1 class="mt0">
416                             <span t-field="question.name"/>
417                             <span t-if="not question.active"><b> [Deleted]</b></span>
418                             <span t-if="question.state == 'close'"><b> [Closed]</b></span>
419                         </h1>
420                         <t t-raw="question.content"/>
421
422                         <div class="mt16 clearfix">
423                             <div class="pull-right">
424                                 <div class="text-right">
425                                     <t t-foreach="question.tags" t-as="tag">
426                                         <a t-attf-href="/forum/#{ slug(forum) }/tag/#{ tag.id }/questions" class="badge" t-field="tag.name"/>
427                                     </t>
428                                 </div>
429                                 <ul class="list-inline">
430                                     <li>
431                                         <a style="cursor: pointer" data-toggle="collapse" class="text-muted fa fa-comment-o"
432                                               t-attf-data-target="#comment#{ question._name.replace('.','') + '-' + str(question.id) }">
433                                             comment
434                                         </a>
435                                     </li>
436                                     <li t-if="question.state != 'close' and (user.id == question.user_id.id or user.karma&gt;=100)">
437                                         <a class="text-muted fa fa-times" t-attf-href="/forum/#{ slug(forum) }/close/question/#{ question.id }">close</a>
438                                     </li>
439                                     <li t-if="question.state == 'close' and user.karma&gt;=500">
440                                         <a class="text-muted fa fa-undo" t-attf-href="/forum/#{ slug(forum) }/reopen/question/#{ question.id }">reopen</a>
441                                     </li>
442                                     <li t-if="user.id == question.user_id.id or user.karma&gt;=300">
443                                         <a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/edit/question/#{ question.id }">edit</a>
444                                     </li>
445                                     <li t-if="question.active and user.id == question.user_id.id or user.karma&gt;=1000">
446                                         <a class="text-muted fa fa-trash-o" t-attf-href="/forum/#{ slug(forum) }/delete/question/#{ question.id }">delete</a>
447                                     </li>
448                                     <li t-if="uid == question.user_id.id and not question.active">
449                                         <a class="text-muted fa fa-trash-o" t-attf-href="/forum/#{ slug(forum) }/undelete/question/#{ question.id }">undelete</a>
450                                     </li>
451                                     <li><a class="text-muted fa fa-share" href="">share</a></li>
452                                 </ul>
453                             </div>
454                             <div>
455                                 <t t-call="website_forum.user_detail">
456                                     <t t-set="user" t-value="question.user_id"/>
457                                     <span class="text-muted">Asked on <span t-field="question.write_date" t-field-options='{"format":"short"}'/></span>
458                                 </t>
459                             </div>
460                             <div class="alert alert-info" t-if="question.state == 'close'">
461                                 <p class="mt32 mb32 text-center">
462                                     <b>The question has been closed for the following reason "<span t-field="question.reason_id.name"/>"
463                                     <i>by <a t-attf-href="/forum/#{ slug(forum) }/user/#{ slug(question.closed_by) }" t-field="question.closed_by.name"/> </i>
464                                     <br/>close date <span t-field="question.closed_date"/></b>
465                                 </p>
466                             </div>
467                         </div>
468                         <t t-call="website_forum.comments">
469                             <t t-set="object" t-value="question"/>
470                         </t>
471                     </div>
472                 </div>
473                 <hr/>
474
475                 <div t-foreach="question.child_ids" t-as="answer" class="mt16 mb32">
476                     <a t-attf-id="answer-#{str(answer.id)}"/>
477                     <div t-attf-class="#{answer.correct and 'alert alert-info answer_correct' or ''}" t-attf-id="answer_#{answer.id}" >
478                         <div class="text-center pull-left">
479                             <t t-call="website_forum.vote">
480                                 <t t-set="post" t-value="answer"/>
481                             </t>
482                             <div class="text-muted">
483                                 <a t-attf-id="#{answer.id}" t-if="answer.correct" class="accept_answer fa fa-2x fa-check-circle no-decoration oe_answer_true"/>
484                                 <a t-attf-id="#{answer.id}" t-if="not answer.correct" class="accept_answer fa fa-2x fa-check-circle no-decoration oe_answer_false"/>
485                             </div>
486                         </div>
487                         <div style="margin-left: 95px;" class="clearfix">
488                             <t t-raw="answer.content"/>
489                             <div class="mt16">
490                                 <ul class="list-inline pull-right">
491                                     <li>
492                                         <a style="cursor: pointer" data-toggle="collapse" class="text-muted fa fa-comment-o"
493                                               t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }">comment
494                                         </a>
495                                     </li>
496                                     <li t-if="user.id == answer.user_id.id or user.karma&gt;=300">
497                                         <a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/edit/#{ answer.id }">edit</a>
498                                     </li>
499                                     <li t-if="user.id == answer.user_id.id or user.karma&gt;=1000">
500                                         <a class="text-muted delete fa fa-trash-o" href="" t-attf-id="#{answer.id}">delete</a>
501                                     </li>
502                                     <li t-if="uid">
503                                         <a class="text-muted fa fa-magic" t-attf-href="/forum/#{ slug(forum) }/post/#{ answer.id }/converttocomment">Convert as a comment</a>
504                                     </li>
505                                     <li><a class="text-muted fa fa-share" t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/#answer-#{ answer.id }">share</a></li>
506                                 </ul>
507                                 <t t-call="website_forum.user_detail">
508                                     <t t-set="user" t-value="answer.user_id"/>
509                                     <span class="text-muted">Answered on <span t-field="answer.create_date" t-field-options='{"format":"short"}'/></span>
510                                 </t>
511                             </div>
512                             <t t-call="website_forum.comments">
513                                 <t t-set="object" t-value="answer"/>
514                             </t>
515                         </div>
516                     </div>
517                 </div>
518                 <div t-if="not answer_done">
519                     <t t-call="website_forum.post_answer"/>
520                 </div>
521                 <div t-if="answer_done" class="mb16">
522                     <a class="btn btn-primary" t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/editanswer">Edit Your Previous Answer</a>
523                     <span class="text-muted">(only one answer per question is allowed)</span>
524                 </div>
525             </t>
526         </template>
527
528         <template id="comments">
529             <div class="row clearfix">
530                 <div class="col-sm-10 col-sm-offset-2">
531                     <div t-foreach="reversed(object.website_message_ids)" t-as="message" id="comment" class="oe_comment_grey" style="padding: 4px;">
532                         <small class="text-muted">
533                             <button type="button" t-if="user.id == message.create_uid.id or user.karma&gt;=750" t-att-id="message.id" class="close comment_delete">&amp;times;</button>
534                             <span t-field="message.body"/>
535                             <a t-attf-href="/forum/#{ slug(forum) }/user/#{ message.create_uid.id }" t-field="message.create_uid"/>
536                                 on <span t-field="message.date" t-field-options='{"format":"short"}'/>
537                             <a class="fa fa-magic text-muted pull-right" t-if="uid == message.create_uid.id"
538                                 t-attf-href="/forum/#{ slug(forum) }/post/#{ object.id }/commet/#{ message.id }/converttoanswer">Convert as an answer</a>
539                         </small>
540                     </div>
541                     <div class="css_editable_mode_hidden">
542                         <form t-attf-id="comment#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse" t-attf-action="/forum/#{ slug(forum) }/comment" method="POST">
543                             <input name="post_id" t-att-value="object.id" type="hidden"/>
544                             <textarea name="comment" class="form-control" placeholder="Comment this post..."/>
545                             <button type="submit" class="btn btn-primary mt8">Post</button>
546                         </form>
547                     </div>
548                 </div>
549             </div>
550         </template>
551
552         <template id="tag">
553             <t t-call="website_forum.header">
554                 <h1 class="mt0">
555                     Tags
556                 </h1>
557                 <p class="text-muted">
558                     A tag is a label that categorizes your question with other,
559                     similar questions. Using the right tags makes it easier for
560                     others to find and answer your question.
561                 </p>
562                 <div class="row">
563                     <div class="col-sm-3 mt16" t-foreach="tags" t-as="tag">
564                         <a t-attf-href="/forum/#{ slug(forum) }/tag/#{ slug(tag) }/questions?{{ keep_query( filters='tag') }}" class="badge">
565                             <span t-field="tag.name"/>
566                         </a>
567                         <span> 
568                             X <t t-esc="tag.posts_count"/>
569                         </span>
570                     </div>
571                 </div>
572             </t>
573         </template>
574
575         <template id="badge">
576             <t t-call="website_forum.header">
577                 <h1 class="mt0">
578                     Badges
579                 </h1>
580                 <p>
581                     Besides gaining reputation with your questions and answers,
582                     you receive badges for being especially helpful. Badges
583                     appear on your profile page, and your posts.
584                 </p>
585                 <table class="table mt32 mb64">
586                     <tr t-foreach="badges" t-as="badge">
587                         <td>
588                             <a t-attf-href="/forum/#{ slug(forum) }/badge/#{ slug(badge) }" class="badge pull-left">
589                                 <span t-if="badge.level == 'gold'" class="fa fa-circle badge-gold"/>
590                                 <span t-if="badge.level == 'silver'" class="fa fa-circle badge-silver"/>
591                                 <span t-if="badge.level == 'bronze'" class="fa fa-circle badge-bronze"/>
592                                 <span t-field="badge.name"/>
593                             </a>
594                         </td><td>
595                             <b t-esc="badge.stat_count_distinct"/>
596                             <i class="text-muted">awarded users</i>
597                         </td><td>
598                             <span t-field="badge.description"/>
599                         </td>
600                     </tr>
601                 </table>
602             </t>
603         </template>
604
605         <template id="badge_user">
606             <t t-call="website_forum.header">
607                 <h3 class="mt32 mb32"> 
608                     <b>Badge "<span t-field="badge.name"/>"</b>
609                 </h3>
610                 <div>
611                     <div class="pull-left badge">
612                         <span t-if="badge.level == 'gold'" class="fa fa-circle badge-gold"/>
613                         <span t-if="badge.level == 'silver'" class="fa fa-circle badge-silver"/>
614                         <span t-if="badge.level == 'bronze'" class="fa fa-circle badge-bronze"/>
615                         <span t-field="badge.name"/>
616                     </div>
617                     <span t-field="badge.description" style="margin-left:20px"/>
618                 </div>
619                 <h4 class="mt32">
620                     <t class="pull-left" t-esc="badge.stat_count_distinct"/>
621                     <span t-if="badge.stat_count_distinct&gt;1">users</span>
622                     <span t-if="badge.stat_count_distinct&lt;=1">user</span>
623                     received this badge:
624                 </h4>
625                 <div class="row">
626                     <div class="col-sm-3 mt16" t-foreach="users" t-as="user">
627                         <span t-field="user.image" t-field-options='{"widget": "image", "class":"pull-left img img-circle img-avatar"}'/>
628                         <div>
629                             <a t-attf-href="/forum/#{ slug(forum) }/user/#{ slug(user) }" t-field="user.name"/>
630                         </div>
631                     </div>
632                 </div>
633             </t>
634         </template>
635
636         <template id="users">
637             <t t-call="website_forum.header">
638                 <div class="row">
639                     <div t-foreach="users" t-as="user" class="col-sm-4">
640                         <t t-set="separator"><br/></t>
641                         <t t-call="website_forum.user_detail"/>
642                         <span class="text-muted">Joined on <span t-field="user.create_date" t-field-options='{"format":"short"}'/></span>
643                     </div>
644                 </div>
645                 <div class="pull-left">
646                     <t t-call="website.pager"/>
647                 </div>
648             </t>
649         </template>
650
651         <template id="edit_profile">
652             <t t-call="website_forum.header">
653                 <h3>Edit Profile </h3>
654                     <div class="col-md-2">
655                         <span t-field="user.image" t-field-options='{"widget": "image", "class": "img img-responsive img-circle"}'/>
656                     </div>
657                     <form t-attf-action="/forum/#{ slug(forum) }/save/profile" method="post" role="form" class="form-horizontal">
658                         <input name="user_id" t-att-value="user.id" type="hidden"/>
659                         <label class="col-md-2 control-label mb16" for="user.name">Real name</label>
660                         <div class="col-md-7 mb16">
661                             <input type="text" class="col-md-7 mb16 form-control" name="name" required="True" t-attf-value="#{user.name}"/>
662                         </div> 
663                         <label class="col-md-2 control-label mb16" for="user.partner_id.website">Website</label>
664                         <div class="col-md-7 mb16">
665                             <input type="text" class="form-control" name="website" t-attf-value="#{user.partner_id.website or ''}"/>
666                         </div>
667                         <label class="col-md-4 control-label mb16" for="user.partner_id.email">Email</label>
668                         <div class="col-md-7 mb16">
669                             <input type="text" class="form-control" name="email" required="True" t-attf-value="#{user.partner_id.email}"/>
670                         </div>
671                         <label class="col-md-4 control-label mb16" for="user.partner_id.city">City</label>
672                         <div class="col-md-7  mb16">
673                             <input type="text" class="form-control" name="city" t-attf-value="#{user.partner_id.city or ''}"/>
674                         </div>
675                         <label class="col-md-4 control-label mb16" for="contact_name">Country</label>
676                         <div class="col-md-7 mb16">
677                             <select class="form-control" name="country">
678                                 <option value="">Country...</option>
679                                 <t t-foreach="countries or []" t-as="country">
680                                     <option t-att-value="country.id" t-att-selected="country.id == user.partner_id.country.id"><t t-esc="country.name"/></option>
681                                 </t>
682                              </select>
683                         </div>
684                         <!--Note: using website_description fiels instead of using commnt firld of partner-->
685                         <label class="col-md-4 control-label mb16" for="user.partner_id.website_description">Biography</label>
686                         <div class="col-md-7 mb16">
687                             <textarea name="description" style="min-height: 120px" required="True" 
688                                 class="form-control"><t t-esc="user.partner_id.website_description"/></textarea>
689                         </div>
690                         <div class="col-sm-offset-4 col-md-4 mb16">
691                             <button class="btn btn-primary btn-lg">Update</button>
692                         </div>
693                     </form>
694             </t>
695         </template>
696
697         <template id="user_detail_full">
698             <t t-call="website_forum.header">
699                 <h1 class="mt0 page-header">
700                     <span t-field="user.name"/>
701                     <small>profile</small>
702                 </h1>
703                 <div class="row">
704                     <div class="col-sm-2">
705                         <span t-field="user.image"
706                             t-field-options='{"widget": "image", "class": "img img-responsive img-circle"}'/>
707                     </div>
708                     <div class="col-sm-10">
709                         <table class="table table-condensed">
710                         <tr>
711                             <td rowspan="2" valign="top"><span class="text-muted">contributions</span></td>
712                             <td>member since</td>
713                             <td><span t-field="user.create_date" t-field-options='{"format": "short"}'/></td>
714                         </tr><tr>
715                             <td>last connection</td>
716                             <td><span t-field="user.login_date" t-field-options='{"format": "short"}'/></td>
717                         </tr>
718                         <tr>
719                             <td rowspan="2" valign="top"><span class="text-muted">bio</span></td>
720                             <td>website</td>
721                             <td>
722                                 <a t-att-href="user.website" t-if="user.website">
723                                     <span t-field="user.website"/>
724                                 </a>
725                             </td>
726                         </tr><tr>
727                             <td>location</td>
728                             <td>
729                                 <span t-field="user.city"/>
730                                 <span t-if="user.city and user.country_id">, </span>
731                                 <span t-field="user.country_id"/>
732                                 <t t-if="user.country_id"> <span t-field="user.country_id.image" t-field-options='{"widget": "image", "class":"forum_user_flag"}'/></t>
733                                 
734                             </td>
735                         </tr>
736                         <tr>
737                             <td rowspan="2" valign="top"><span class="text-muted">stats</span></td>
738                             <td>karma</td>
739                             <td><span t-field="user.karma"/></td>
740                         </tr><tr>
741                             <td>votes</td>
742                             <td>
743                                 <span class="fa fa-thumbs-up"/>
744                                 <span t-esc="up_votes"/>
745                                 <span class="fa fa-thumbs-down"/>
746                                 <span t-esc="down_votes"/>
747                             </td>
748                         </tr>
749                         </table>
750                         <div class="well well-sm">
751                             <span t-field="user.partner_id.website_description"/>
752                             <t t-if="uid == user.id">
753                                 <a class="fa fa-arrow-right"  t-attf-href="/forum/#{ slug(forum) }/edit/profile/#{ user.id }"> Edit Your Bio</a>
754                             </t>
755                         </div>
756                     </div>
757                 </div>
758
759                 <ul class="nav nav-tabs">
760                     <li class="active">
761                         <a href="#questions" data-toggle="tab"><t t-esc="len(questions)"/> Questions</a>
762                     </li>
763                     <li>
764                         <a href="#answers" data-toggle="tab"><t t-esc="len(answers)"/> Answers</a>
765                     </li>
766                     <li t-if="uid == user.id">
767                         <a href="#activity" data-toggle="tab">Activity</a>
768                     </li>
769                     <li>
770                         <a href="#badges" data-toggle="tab">Badges</a>
771                     </li>
772                     <li t-if="uid == user.id">
773                         <a href="#followed_question" data-toggle="tab"><t t-esc="len(followed)"/> Followed Question</a>
774                     </li>
775                     <li>
776                         <a href="#votes" data-toggle="tab">Votes</a>
777                     </li>
778                 </ul>
779                 <div class="tab-content mt16">
780                     <div class="tab-pane active" id="questions">
781                         <div class="mb16" t-foreach="questions" t-as="question">
782                             <t t-call="website_forum.post_list"/>
783                         </div>
784                     </div><div class="tab-pane" id="answers">
785                         <div t-foreach="answers" t-as="answer">
786                             <t t-call="website_forum.post_list_answer"/>
787                         </div>
788                     </div>
789                     <div class="tab-pane" id="karma">
790                         <h1>Karma</h1>
791                     </div>
792                     <div class="tab-pane" id="badges">
793                         <t t-call="website_forum.user_badges"/>
794                     </div>
795                     <div class="tab-pane" id="followed_question">
796                         <div t-foreach="followed" t-as="question">
797                             <t t-call="website_forum.post_list"/>
798                         </div>
799                     </div>
800                     <div class="tab-pane" id="votes">
801                         <t t-call="website_forum.user_votes"/>
802                     </div>
803                     <div class="tab-pane" id="activity">
804                         <ul class="list-unstyled">
805                             <li t-foreach="activities" t-as="activity">
806                                 <span t-esc="activity.date"/>
807                                 <span t-esc="activity.subtype_id.name" class="label label-info"/>
808                                 <t t-set="post" t-value="posts[activity.res_id]"/>
809                                 <span t-if="post[1]"> 
810                                     <a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(post[0]) }#answer-#{ str(post[1].id) }">
811                                         Gave an answer
812                                     </a> on
813                                 </span>
814                                 <a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(post[0]) }">
815                                     <span t-esc="post[0].name"/>
816                                 </a>
817                             </li>
818                         </ul>
819                     </div>
820                 </div>
821             </t>
822         </template>
823
824         <template id="user_badges">
825             <table class="table mt32 mb64">
826                 <tr t-foreach="user.badges" t-as="badge">
827                     <td>
828                         <a t-attf-href="/forum/#{ slug(forum) }/badge/#{ slug(badge.badge_id) }" class="badge pull-left">
829                             <span t-if="badge.badge_id.level == 'gold'" class="fa fa-circle badge-gold"/>
830                             <span t-if="badge.badge_id.level == 'silver'" class="fa fa-circle badge-silver"/>
831                             <span t-if="badge.badge_id.level == 'bronze'" class="fa fa-circle badge-bronze"/>
832                             <span t-field="badge.badge_id.name"/>
833                         </a>
834                     </td><td>
835                         <b t-esc="badge.badge_id.stat_count_distinct"/>
836                         <i class="text-muted">awarded users</i>
837                     </td><td>
838                         <span t-field="badge.badge_id.description"/>
839                     </td>
840                 </tr>
841             </table>
842             <div class="mb16" t-if="not user.badges">
843                 <b>No badge yet!</b><br/>
844                 <a t-attf-href="/forum/#{ slug(forum) }/badge" class="fa fa-arrow-right"> Check available badges</a>
845             </div>
846         </template>
847
848         <template id="user_votes">
849             <div t-foreach="vote_post" t-as="vote">
850                 <t t-esc="vote.post_id.create_date"/>
851                 <span t-if="vote.vote == '1'" class="fa fa-thumbs-up text-success" style="margin-left:30px"/>
852                 <span t-if="vote.vote == '-1'" class="fa fa-thumbs-down text-warning" style="margin-left:30px"/>
853                 <t t-if="vote.post_id.parent_id">
854                     <a t-attf-href="/forum/#{ slug(forum) }/question/#{ vote.post_id.parent_id.id }/#answer-#{ vote.post_id.id }" t-esc="vote.post_id.parent_id.name" style="margin-left:10px"/>
855                 </t>
856                 <t t-if="not vote.post_id.parent_id">
857                     <a t-attf-href="/forum/#{ slug(forum) }/question/#{ vote.post_id.id }" style=" color:black;margin-left:10px" t-esc="vote.post_id.name"/>
858                 </t>
859             </div>
860             <div class="mb16" t-if="not vote_post">
861                 <b>No vote given by you yet!</b>
862             </div>
863         </template>
864
865         <template id="post_list_answer">
866             <div class="clearfix">
867                 <div t-attf-class="pull-left text-center mb16 box #{len(answer.vote_ids) and 'oe_green' or 'oe_grey'}">
868                     <div t-esc="len(answer.vote_ids)"/>
869                 </div>
870                 <div class="question-name" style="margin-left: 32px;">
871                     <a style="font-size: 15px;" t-attf-href="/forum/#{ slug(forum) }/question/#{ answer.parent_id.id }/#answer-#{ answer.id }" t-esc="answer.parent_id.name"/>
872                     <t t-if="len(answer.website_message_ids)&gt;0">
873                         (<t t-esc="len(answer.website_message_ids)"/>
874                         <t t-if="len(answer.website_message_ids)&gt;1">Comments</t>
875                         <t t-if="len(answer.website_message_ids)&lt;=1">Comment</t>)
876                     </t>
877                 </div>
878             </div>
879         </template>
880
881     </data>
882 </openerp>