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