values = { 'forums': forums }
return request.website.render("website_forum.forum_index", values)
- @http.route(['/forum/<model("website.forum"):forum>/view'], type='http', auth="public", website=True, multilang=True)
- def view_forum(self, forum, **searches):
- return request.website.render("website_forum.forum", {'forum': forum })
-
@http.route('/forum/add_forum/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
def add_forum(self, forum_name="New Forum", **kwargs):
forum_id = request.registry['website.forum'].create(request.cr, request.uid, {
'name': forum_name,
- 'faq': 'F.A.Q'
}, context=request.context)
- return request.redirect("/forum/%s/view/?enable_editor=1" % forum_id)
+ return request.redirect("/forum/%s" % forum_id)
- @http.route(['/forum/<model("website.forum"):forum>/', '/forum/<model("website.forum"):forum>/page/<int:page>'], type='http', auth="public", website=True, multilang=True)
+ @http.route(['/forum/<model("website.forum"):forum>', '/forum/<model("website.forum"):forum>/page/<int:page>'], type='http', auth="public", website=True, multilang=True)
def questions(self, forum, page=1, **searches):
cr, uid, context = request.cr, request.uid, request.context
Forum = request.registry['website.forum.post']
'question': question,
'searches': post,
'answer_done': answer_done,
+ 'reversed': reversed,
'forum': forum,
}
return request.website.render("website_forum.post_description_full", values)
--- /dev/null
+<h1>Guidelines</h1>
+<h2><a id="good_questions">What kinds of questions can I ask here?</a></h2>
+<p>
+ This community is for professional and enthusiast users,
+ partners and programmers. You can ask questions about:
+</p>
+<ul>
+ <li>how to install OpenERP on a specific infrastructure,</li>
+ <li>how to configure or customize OpenERP to specific business needs,</li>
+ <li>what's the best way to use OpenERP for a specific business need,</li>
+ <li>how to develop modules for your own need,</li>
+ <li>specific questions about OpenERP service offers, etc.</li>
+</ul>
+<p>
+ <b>Before you ask - please make sure to search for a similar question.</b> You can
+ search questions by their title or tags. It’s also OK to
+ answer your own question.
+</p><p>
+ <b>Please avoid asking questions that are too subjective
+ and argumentative</b> or not relevant to this community.
+</p>
+<h2><a name="bad_questions">What should I avoid in my questions?</a></h2>
+<p>
+ You should only ask practical, answerable questions based
+ on actual problems that you face. Chatty, open-ended
+ questions diminish the usefulness of this site and push
+ other questions off the front page.
+</p><p>
+ To prevent your question from being flagged and possibly removed, avoid asking
+ subjective questions where …
+</p>
+<ul>
+ <li>every answer is equally valid: “What’s your favorite ______?”</li>
+ <li>your answer is provided along with the question, and you expect more answers: “I use ______ for ______, what do you use?”</li>
+ <li>there is no actual problem to be solved: “I’m curious if other people feel like I do.”</li>
+ <li>we are being asked an open-ended, hypothetical question: “What if ______ happened?”</li>
+ <li>it is a rant disguised as a question: “______ sucks, am I right?”</li>
+</ul>
+<p>
+ If you fit in one of these example or if your motivation for asking the
+ question is “I would like to participate in a discussion about ______”, then
+ you should not be asking here but on our mailing lists.
+ However, if your motivation is “I would like others to explain ______ to me”,
+ then you are probably OK.
+</p><p>
+ (The above section was adapted from Stackoverflow’s FAQ.)
+</p><p>
+ More over:
+</p>
+<ul>
+ <li><b>Answers should not add or expand questions</b>. Instead either edit the question edit or add a question comment.</li>
+ <li><b>Answers should not comment other answers</b>. Instead add a comment on the other answers.</li>
+ <li><b>Answers shouldn't just point to other Questions</b>. Instead add a question comment indication "Possible duplicate of...". However, it's ok to include links to other questions or answers providing relevant additional information.</li>
+ <li><b>Answers shouldn't just provide a link a solution</b>. Instead provide the solution description text in your answer, even if it's just a copy/paste. Links are welcome, but should complementary to answer, referring sources or additional reading.</li>
+</ul>
+
+<h2><a name="bad_answers">What should I avoid in my answers?</a></h2>
+<p>
+ <b>Answers should not add or expand questions</b>. Instead
+ either edit the question or add a comment.
+</p><p>
+ <b>Answers should not comment other answers</b>. Instead
+ add a comment on the other answers.
+</p><p>
+ <b>Answers shouldn't just point to other questions</b>.
+ Instead add a comment indicating <i>"Possible duplicate
+ of..."</i>. However, it's fine to include links to other
+ questions or answers providing relevant additional
+ information. </p> <p> <b>Answers shouldn't just provide a
+ link a solution</b>. Instead provide the solution
+ description text in your answer, even if it's just a
+ copy/paste. Links are welcome, but should complementary to
+ answer, referring sources or additional reading.
+</p><p>
+ <b>Answers should not start debates</b>
+ This community Q&A is not a discussion group. Please avoid holding debates in
+ your answers as they tend to dilute the essence of questions and answers. For
+ brief discussions please use commenting facility.
+</p> <p>
+ When a question or answer is upvoted, the user who posted them will gain some
+ points, which are called "karma points". These points serve as a rough
+ measure of the community trust to him/her. Various moderation tasks are
+ gradually assigned to the users based on those points.
+</p> <p>
+ For example, if you ask an interesting question or give a helpful answer, your
+ input will be upvoted. On the other hand if the answer is misleading - it will
+ be downvoted. Each vote in favor will generate 10 points, each vote against
+ will subtract 10 points. There is a limit of 200 points that can be accumulated
+ for a question or answer per day. The table below explains reputation point
+ requirements for each type of moderation task.
+</p>
+
+<table class="table table-striped">
+<tbody>
+ <tr>
+ <td class="faq-rep-item"><strong>1</strong></td>
+ <td>upvote, add comments</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>10</strong></td>
+ <td>downvote</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>30</strong></td>
+ <td>insert text link, upload files</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>50</strong></td>
+ <td>insert clickable link, answer own question immediately</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>75</strong></td>
+ <td>retag, edit wiki questions and answers</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>100</strong></td>
+ <td>flag offensive, close own questions</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>200</strong></td>
+ <td>answer/comment by email</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>300</strong></td>
+ <td>edit any post, view offensive flags</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>400</strong></td>
+ <td>delete any comment</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>500</strong></td>
+ <td>accept any answer (after 1 week)</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>750</strong></td>
+ <td>delete any comment</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>900</strong></td>
+ <td>lock posts</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong>1000</strong></td>
+ <td>delete any question or answer</td>
+ </tr>
+</tbody>
+</table>
+
+<h2><a name="community_edit">Why can other people edit my questions/answers?</a></h2>
+<p>
+ The goal of this site is create a relevant knowledge base that would answer
+ questions related to OpenERP.
+</p><p>
+ Therefore questions and answers can be edited like wiki pages by experienced users of
+ this site in order to improve the overall quality of the knowledge base content.
+ Such privileges are granted based on user karma level: you will be able to do the same
+ once your karma gets high enough.
+</p><p>
+ If this approach is not for you, please respect the community and use Google+
+ communities instead.
+</p>
import re
+import openerp
from openerp import SUPERUSER_ID
from openerp.osv import osv, fields
from openerp.tools.translate import _
'faq': fields.html('FAQ'),
'right_column': fields.html('FAQ'),
}
+ def _get_default_faq(self, cr, uid, context={}):
+ fname = openerp.modules.get_module_resource('website_forum', 'data', 'forum_default_faq.html')
+ with open(fname, 'r') as f:
+ return f.read()
+ return False
+
+ _defaults = {
+ 'faq': _get_default_faq
+ }
class Post(osv.Model):
_name = 'website.forum.post'
def _get_votes(self, cr, uid, ids, field_name, arg, context):
res = dict.fromkeys(ids, False)
+ # TODO: implement this with a read_group call instead of browsing all records
for post in self.browse(cr, uid, ids, context=context):
if post.vote_ids:
for vote in post.vote_ids:
return res
_columns = {
+ 'name': fields.char('Title', size=128),
'forum_id': fields.many2one('website.forum', 'Forum', required=True),
- 'name': fields.char('Topic', size=64),
- 'content': fields.text('Contents', help='contents'),
+ 'content': fields.text('Content'),
'create_date': fields.datetime('Asked on', select=True, readonly=True),
'create_uid': fields.many2one('res.users', 'Asked by', select=True, readonly=True ),
'write_date': fields.datetime('Update on', select=True, readonly=True ),
'state': fields.selection([('active', 'Active'),('close', 'Close'),('offensive', 'Offensive')], 'Status'),
'active': fields.boolean('Active'),
- 'views': fields.integer('Views'),
+ 'views': fields.integer('Page Views'),
- 'parent_id': fields.many2one('website.forum.post', 'Parent'),
- 'child_ids': fields.one2many('website.forum.post', 'parent_id', 'Child'),
+ 'parent_id': fields.many2one('website.forum.post', 'Question'),
+ 'child_ids': fields.one2many('website.forum.post', 'parent_id', 'Answers'),
'history_ids': fields.one2many('blog.post.history', 'post_id', 'History', help='Last post modifications'),
# TODO FIXME: when website_mail/mail_thread.py inheritance work -> this field won't be necessary
string='Post Messages',
help="Comments on forum post",
),
- 'user_vote':fields.function(_get_votes, string="Number of user votes", type='boolean'),
- 'vote_count':fields.function(_get_vote_count, string="Number of user votes count", type='integer'),
+ # TODO: add a store={} on those two fields. Why is it a boolean?
+ 'user_vote':fields.function(_get_votes, string="My Vote", type='boolean'),
+
+ # TODO: add a store={} on those two fields
+ 'vote_count':fields.function(_get_vote_count, string="Votes", type='integer'),
}
_defaults = {
'state': 'active',
context = {}
create_context = dict(context, mail_create_nolog=True)
post_id = super(Post, self).create(cr, uid, vals, context=create_context)
- self.create_history(cr, uid, [post_id], vals, context)
self.create_activity(cr, uid, [post_id], method='create', context=context)
return post_id
def write(self, cr, uid, ids, vals, context=None):
- result = super(Post, self).write(cr, uid, ids, vals, context=context)
self.create_history(cr, uid, ids, vals, context=context)
+ result = super(Post, self).write(cr, uid, ids, vals, context=context)
self.create_activity(cr, uid, ids, method='write', context=context)
return result
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
- <a class="navbar-brand" href="/forum">Help</a>
- <!-- FP Note: Replace by this when controllers have changed
- <a class="navbar-brand" t-attf-href="/forum/#{slug(forum)}">
- <span t-field="forum.name"/>
- </a>
- -->
+ <a class="navbar-brand" t-attf-href="/forum/#{slug(forum)}">
+ <span t-field="forum.name"/>
+ </a>
</div>
<div class="collapse navbar-collapse" id="oe-help-navbar-collapse">
<ul class="nav navbar-nav">
<template id="faq">
<t t-call="website_forum.header">
- <h1>Guidelines</h1>
-
- <h2><a id="good_questions">What kinds of questions can I ask here?</a></h2>
- <p>
- This community is for professional and enthusiast users,
- partners and programmers. You can ask questions about:
- </p>
- <ul>
- <li>how to install OpenERP on a specific infrastructure,</li>
- <li>how to configure or customize OpenERP to specific business needs,</li>
- <li>what's the best way to use OpenERP for a specific business need,</li>
- <li>how to develop modules for your own need,</li>
- <li>specific questions about OpenERP service offers, etc.</li>
- </ul>
- <p>
- <b>Before you ask - please make sure to search for a similar question.</b> You can
- search questions by their title or tags. It’s also OK to
- answer your own question.
- </p><p>
- <b>Please avoid asking questions that are too subjective
- and argumentative</b> or not relevant to this community.
- </p>
- <h2><a name="bad_questions">What should I avoid in my questions?</a></h2>
- <p>
- You should only ask practical, answerable questions based
- on actual problems that you face. Chatty, open-ended
- questions diminish the usefulness of this site and push
- other questions off the front page.
- </p><p>
- To prevent your question from being flagged and possibly removed, avoid asking
- subjective questions where …
- </p>
- <ul>
- <li>every answer is equally valid: “What’s your favorite ______?”</li>
- <li>your answer is provided along with the question, and you expect more answers: “I use ______ for ______, what do you use?”</li>
- <li>there is no actual problem to be solved: “I’m curious if other people feel like I do.”</li>
- <li>we are being asked an open-ended, hypothetical question: “What if ______ happened?”</li>
- <li>it is a rant disguised as a question: “______ sucks, am I right?”</li>
- </ul>
- <p>
- If you fit in one of these example or if your motivation for asking the
- question is “I would like to participate in a discussion about ______”, then
- you should not be asking here but on our mailing lists.
- However, if your motivation is “I would like others to explain ______ to me”,
- then you are probably OK.
- </p><p>
- (The above section was adapted from Stackoverflow’s FAQ.)
- </p><p>
- More over:
- </p>
- <ul>
- <li><b>Answers should not add or expand questions</b>. Instead either edit the question edit or add a question comment.</li>
- <li><b>Answers should not comment other answers</b>. Instead add a comment on the other answers.</li>
- <li><b>Answers shouldn't just point to other Questions</b>. Instead add a question comment indication "Possible duplicate of...". However, it's ok to include links to other questions or answers providing relevant additional information.</li>
- <li><b>Answers shouldn't just provide a link a solution</b>. Instead provide the solution description text in your answer, even if it's just a copy/paste. Links are welcome, but should complementary to answer, referring sources or additional reading.</li>
- </ul>
-
- <h2><a name="bad_answers">What should I avoid in my answers?</a></h2>
- <p>
- <b>Answers should not add or expand questions</b>. Instead
- either edit the question or add a comment.
- </p><p>
- <b>Answers should not comment other answers</b>. Instead
- add a comment on the other answers.
- </p><p>
- <b>Answers shouldn't just point to other questions</b>.
- Instead add a comment indicating <i>"Possible duplicate
- of..."</i>. However, it's fine to include links to other
- questions or answers providing relevant additional
- information. </p> <p> <b>Answers shouldn't just provide a
- link a solution</b>. Instead provide the solution
- description text in your answer, even if it's just a
- copy/paste. Links are welcome, but should complementary to
- answer, referring sources or additional reading.
- </p><p>
- <b>Answers should not start debates</b>
- This community Q&A is not a discussion group. Please avoid holding debates in
- your answers as they tend to dilute the essence of questions and answers. For
- brief discussions please use commenting facility.
- </p> <p>
- When a question or answer is upvoted, the user who posted them will gain some
- points, which are called "karma points". These points serve as a rough
- measure of the community trust to him/her. Various moderation tasks are
- gradually assigned to the users based on those points.
- </p> <p>
- For example, if you ask an interesting question or give a helpful answer, your
- input will be upvoted. On the other hand if the answer is misleading - it will
- be downvoted. Each vote in favor will generate 10 points, each vote against
- will subtract 10 points. There is a limit of 200 points that can be accumulated
- for a question or answer per day. The table below explains reputation point
- requirements for each type of moderation task.
- </p>
-
- <table class="table table-striped">
- <tbody>
- <tr>
- <td class="faq-rep-item"><strong>1</strong></td>
- <td>upvote, add comments</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>10</strong></td>
- <td>downvote</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>30</strong></td>
- <td>insert text link, upload files</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>50</strong></td>
- <td>insert clickable link, answer own question immediately</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>75</strong></td>
- <td>retag, edit wiki questions and answers</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>100</strong></td>
- <td>flag offensive, close own questions</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>200</strong></td>
- <td>answer/comment by email</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>300</strong></td>
- <td>edit any post, view offensive flags</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>400</strong></td>
- <td>delete any comment</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>500</strong></td>
- <td>accept any answer (after 1 week)</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>750</strong></td>
- <td>delete any comment</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>900</strong></td>
- <td>lock posts</td>
- </tr><tr>
- <td class="faq-rep-item"><strong>1000</strong></td>
- <td>delete any question or answer</td>
- </tr>
- </tbody>
- </table>
-
- <h2><a name="community_edit">Why can other people edit my questions/answers?</a></h2>
- <p>
- The goal of this site is create a relevant knowledge base that would answer
- questions related to OpenERP.
- </p><p>
- Therefore questions and answers can be edited like wiki pages by experienced users of
- this site in order to improve the overall quality of the knowledge base content.
- Such privileges are granted based on user karma level: you will be able to do the same
- once your karma gets high enough.
- </p><p>
- If this approach is not for you, please respect the community and use Google+
- communities instead.
- </p>
+ <div t-field="forum.faq"/>
</t>
</template>
</t>
</template>
- <template id="forum">
- <t t-call="website.layout">
- <!--TODO: Improve template -->
- <div class="row">
- <h1 class="text-center" t-attf-href="/forum/#{ slug(forum) }" t-field="forum.name"/>
- </div>
- <div class="row">
- <h1 class="text-center" t-attf-href="/forum/#{ slug(forum) }/faq" t-field="forum.faq"/>
- </div>
- </t>
- </template>
-
<template id="index">
<t t-call="website_forum.header">
<h1 class="page-header mt0">
<div class="mt16 clearfix">
<div class="pull-right">
- <t t-foreach="question.tags" t-as="tag">
- <a t-attf-href="/forum/#{ slug(forum) }/tag/#{ tag.id }" class="badge" t-field="tag.name"/>
- </t>
+ <div class="text-right">
+ <t t-foreach="question.tags" t-as="tag">
+ <a t-attf-href="/forum/#{ slug(forum) }/tag/#{ tag.id }" class="badge" t-field="tag.name"/>
+ </t>
+ </div>
+ <ul class="list-inline">
+ <li>
+ <a style="cursor: pointer" data-toggle="collapse" class="text-muted"
+ t-attf-data-target="#comment#{ question._name.replace('.','') + '-' + str(question.id) }">
+ comment
+ </a>
+ </li>
+ <li><a class="text-muted" href="">edit</a></li>
+ <li><a class="text-muted" href="">delete</a></li>
+ <li><a class="text-muted" href="">share</a></li>
+ </ul>
</div>
<t t-set="user" t-value="question.create_uid"/>
<t t-call="website_forum.user_detail">
<div style="margin-left: 95px;" class="clearfix">
<t t-raw="answer.content" />
<div class="mt16">
- <div class="pull-right">
- <a class="action-links" href="">
- <span class="fa fa-edit"></span>
- </a>
- <a class="action-links" href="">
- <span class="fa fa-flag"></span>
- </a>
- <a class="action-links" href="">
- <span class="fa-trash-o"></span>
- </a>
- <a class="action-links" href="">
- <span class="fa fa-link"></span>
- </a>
- </div>
+ <ul class="list-inline pull-right">
+ <li>
+ <a style="cursor: pointer" data-toggle="collapse" class="text-muted"
+ t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }">
+ comment
+ </a>
+ </li>
+ <li><a class="text-muted" href="">edit</a></li>
+ <li><a class="text-muted" href="">delete</a></li>
+ <li><a class="text-muted" href="">share</a></li>
+ </ul>
<t t-set="user" t-value="answer.create_uid"/>
<t t-call="website_forum.user_detail">
<span class="text-muted">Answered on <span t-field="answer.create_date"/></span>
</t>
</div>
-
<t t-call="website_forum.comments">
<t t-set="object" t-value="answer"/>
</t>
<template id="comments">
<div class="row clearfix">
<div class="col-sm-10 col-sm-offset-2">
- <div t-foreach="object.website_message_ids" t-as="message" class="oe_grey">
+ <div t-foreach="reversed(object.website_message_ids)" t-as="message" class="oe_grey" style="padding: 4px;">
<small class="text-muted">
<div t-field="message.body"/>
- <a t-attf-href="/forum/#{ slug(forum) }/user/#{ message.author_id.id }" t-field="message.author_id"/>
- on <span t-field="message.date" t-field-options='{"format":"short"}'/>
+ <a t-attf-href="/forum/#{ slug(forum) }/user/#{ message.author_id.id }" t-field="message.author_id"/>
+ on <span t-field="message.date" t-field-options='{"format":"short"}'/>
</small>
- <hr class="mt4 mb4"/>
</div>
- <div class="css_editable_mode_hidden">
- <a data-toggle="collapse" t-attf-data-target="#comment#{ object._name.replace('.','') + '-' + str(object.id) }" class="pull-right">
- add a comment
- </a>
+ <div class="css_editable_mode_hidden oe_grey">
<form t-attf-id="comment#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse" t-attf-action="/forum/#{ slug(forum) }/comment" method="POST">
<input name="post_id" t-att-value="object.id" type="hidden"/>
<textarea name="comment" class="form-control" placeholder="Comment this post..."/>