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