diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 50af7e8a19f..98371012b7e 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -46,19 +46,14 @@ class website_forum(http.Controller): values = { 'forums': forums } return request.website.render("website_forum.forum_index", values) - @http.route(['/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//', '/forum//page/'], type='http', auth="public", website=True, multilang=True) + @http.route(['/forum/', '/forum//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'] @@ -124,6 +119,7 @@ class website_forum(http.Controller): 'question': question, 'searches': post, 'answer_done': answer_done, + 'reversed': reversed, 'forum': forum, } return request.website.render("website_forum.post_description_full", values) diff --git a/addons/website_forum/data/forum_default_faq.html b/addons/website_forum/data/forum_default_faq.html new file mode 100644 index 00000000000..30d8ecfbd92 --- /dev/null +++ b/addons/website_forum/data/forum_default_faq.html @@ -0,0 +1,150 @@ +

Guidelines

+

What kinds of questions can I ask here?

+

+ This community is for professional and enthusiast users, + partners and programmers. You can ask questions about: +

+
    +
  • how to install OpenERP on a specific infrastructure,
  • +
  • how to configure or customize OpenERP to specific business needs,
  • +
  • what's the best way to use OpenERP for a specific business need,
  • +
  • how to develop modules for your own need,
  • +
  • specific questions about OpenERP service offers, etc.
  • +
+

+ Before you ask - please make sure to search for a similar question. You can + search questions by their title or tags. It’s also OK to + answer your own question. +

+ Please avoid asking questions that are too subjective + and argumentative or not relevant to this community. +

+

What should I avoid in my questions?

+

+ 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. +

+ To prevent your question from being flagged and possibly removed, avoid asking + subjective questions where … +

+
    +
  • every answer is equally valid: “What’s your favorite ______?”
  • +
  • your answer is provided along with the question, and you expect more answers: “I use ______ for ______, what do you use?”
  • +
  • there is no actual problem to be solved: “I’m curious if other people feel like I do.”
  • +
  • we are being asked an open-ended, hypothetical question: “What if ______ happened?”
  • +
  • it is a rant disguised as a question: “______ sucks, am I right?”
  • +
+

+ 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. +

+ (The above section was adapted from Stackoverflow’s FAQ.) +

+ More over: +

+
    +
  • Answers should not add or expand questions. Instead either edit the question edit or add a question comment.
  • +
  • Answers should not comment other answers. Instead add a comment on the other answers.
  • +
  • Answers shouldn't just point to other Questions. 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.
  • +
  • Answers shouldn't just provide a link a solution. 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.
  • +
+ +

What should I avoid in my answers?

+

+ Answers should not add or expand questions. Instead + either edit the question or add a comment. +

+ Answers should not comment other answers. Instead + add a comment on the other answers. +

+ Answers shouldn't just point to other questions. + Instead add a comment indicating "Possible duplicate + of...". However, it's fine to include links to other + questions or answers providing relevant additional + information.

Answers shouldn't just provide a + link a solution. 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. +

+ Answers should not start debates + 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. +

+ 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. +

+ 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. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1upvote, add comments
10downvote
30insert text link, upload files
50insert clickable link, answer own question immediately
75retag, edit wiki questions and answers
100flag offensive, close own questions
200answer/comment by email
300edit any post, view offensive flags
400delete any comment
500accept any answer (after 1 week)
750delete any comment
900lock posts
1000delete any question or answer
+ +

Why can other people edit my questions/answers?

+

+ The goal of this site is create a relevant knowledge base that would answer + questions related to OpenERP. +

+ 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. +

+ If this approach is not for you, please respect the community and use Google+ + communities instead. +

diff --git a/addons/website_forum/models/website_forum.py b/addons/website_forum/models/website_forum.py index 80725e80aa3..f67ed82bf74 100644 --- a/addons/website_forum/models/website_forum.py +++ b/addons/website_forum/models/website_forum.py @@ -21,6 +21,7 @@ import re +import openerp from openerp import SUPERUSER_ID from openerp.osv import osv, fields from openerp.tools.translate import _ @@ -37,6 +38,15 @@ class Forum(osv.Model): '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' @@ -46,6 +56,7 @@ class Post(osv.Model): 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: @@ -68,9 +79,9 @@ class Post(osv.Model): 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 ), @@ -83,10 +94,10 @@ class Post(osv.Model): '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 @@ -98,9 +109,12 @@ class Post(osv.Model): 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', @@ -159,13 +173,12 @@ class Post(osv.Model): 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 diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index ee97f8f5a84..38f588605c8 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -77,12 +77,9 @@ - Help - + + +