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