summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParth Gajjar <pga@openerp.com>2015-01-29 16:59:25 +0100
committerJérome Maes <jem@openerp.com>2015-03-12 15:41:10 +0100
commitf76ca21b15cfa67c04d5931efb4ac53a34a33e71 (patch)
treea9c80e8da7682d960d898775c2edf5d0cad7648f
parent9804ee91c5fa503b7a3397337777c2ecb5689a6e (diff)
[IMP] website_forum : improve tag ordering, add 'in menu' checkox when create a forum, customize welcome_message on a forum, better fetch link title when insert it, display answers of a question on form view, ans some changes in faq
-rw-r--r--addons/website_forum/controllers/main.py56
-rw-r--r--addons/website_forum/data/forum_default_faq.html44
-rw-r--r--addons/website_forum/models/forum.py36
-rw-r--r--addons/website_forum/static/src/css/website_forum.css12
-rw-r--r--addons/website_forum/static/src/css/website_forum.sass6
-rw-r--r--addons/website_forum/static/src/js/website_forum.editor.js20
-rw-r--r--addons/website_forum/static/src/js/website_forum.js38
-rw-r--r--addons/website_forum/views/forum.xml48
-rw-r--r--addons/website_forum/views/website_forum.xml152
9 files changed, 272 insertions, 140 deletions
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index 828bcbbfa98..5daa2ddfb7c 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
from datetime import datetime
import werkzeug.exceptions
import werkzeug.urls
@@ -8,15 +7,12 @@ import simplejson
import lxml
from urllib2 import urlopen, URLError
-from openerp import tools
+from openerp import tools, _
from openerp.addons.web import http
from openerp.addons.web.controllers.main import login_redirect
from openerp.addons.web.http import request
-from openerp.addons.website.controllers.main import Website as controllers
from openerp.addons.website.models.website import slug
-controllers = controllers()
-
class WebsiteForum(http.Controller):
_post_per_page = 10
@@ -37,7 +33,7 @@ class WebsiteForum(http.Controller):
'notifications': self._get_notifications(),
'header': kwargs.get('header', dict()),
'searches': kwargs.get('searches', dict()),
- 'no_introduction_message': request.httprequest.cookies.get('no_introduction_message', False),
+ 'forum_welcome_message': request.httprequest.cookies.get('forum_welcome_message', False),
'validation_email_sent': request.session.get('validation_email_sent', False),
'validation_email_done': request.session.get('validation_email_done', False),
}
@@ -86,8 +82,15 @@ class WebsiteForum(http.Controller):
return request.website.render("website_forum.forum_all", {'forums': forums})
@http.route('/forum/new', type='http', auth="user", methods=['POST'], website=True)
- def forum_create(self, forum_name="New Forum", **kwargs):
+ def forum_create(self, forum_name="New Forum", add_menu=False):
forum_id = request.env['forum.forum'].create({'name': forum_name})
+ if add_menu:
+ request.env['website.menu'].create({
+ 'name': forum_name,
+ 'url': "/forum/%s" % slug(forum_id),
+ 'parent_id': request.website.menu_id.id,
+ 'website_id': request.website.id,
+ })
return request.redirect("/forum/%s" % slug(forum_id))
@http.route('/forum/notification_read', type='json', auth="user", methods=['POST'], website=True)
@@ -166,16 +169,37 @@ class WebsiteForum(http.Controller):
)
return simplejson.dumps(data)
- @http.route(['/forum/<model("forum.forum"):forum>/tag'], type='http', auth="public", website=True)
- def tags(self, forum, page=1, **post):
- tags = request.env['forum.tag'].search([('forum_id', '=', forum.id), ('posts_count', '>', 0)], limit=None, order='posts_count DESC')
+ @http.route(['/forum/<model("forum.forum"):forum>/tag', '/forum/<model("forum.forum"):forum>/tag/<string:tag_char>'], type='http', auth="public", website=True)
+ def tags(self, forum, tag_char=None, **post):
+ # build the list of tag first char, with their value as tag_char param Ex : [('All', 'all'), ('C', 'c'), ('G', 'g'), ('Z', z)]
+ first_char_tag = forum.get_tags_first_char()
+ first_char_list = [(t, t.lower()) for t in first_char_tag]
+ first_char_list.insert(0, (_('All'), 'all'))
+ # get active first char tag
+ active_char_tag = first_char_list[1][1] if len(first_char_list) > 1 else 'all'
+ if tag_char:
+ active_char_tag = tag_char.lower()
+ # generate domain for searched tags
+ domain = [('forum_id', '=', forum.id), ('posts_count', '>', 0)]
+ order_by = 'name'
+ if active_char_tag and active_char_tag != 'all':
+ domain.append(('name', '=ilike', active_char_tag+'%'))
+ order_by = 'posts_count DESC'
+ tags = request.env['forum.tag'].search(domain, limit=None, order=order_by)
+ # prepare values and render template
values = self._prepare_forum_values(forum=forum, searches={'tags': True}, **post)
values.update({
'tags': tags,
- 'main_object': forum,
+ 'pager_tag_chars': first_char_list,
+ 'active_char_tag': active_char_tag,
})
return request.website.render("website_forum.tag", values)
+
+ @http.route('/forum/<model("forum.forum"):forum>/edit_welcome_message', auth="user", website=True)
+ def edit_welcome_message(self, forum, **kw):
+ return request.website.render("website_forum.edit_welcome_message", {'forum': forum})
+
# Questions
# --------------------------------------------------
@@ -339,17 +363,21 @@ class WebsiteForum(http.Controller):
'tags': tags,
'post': post,
'is_answer': bool(post.parent_id),
- 'searches': kwargs
+ 'searches': kwargs,
+ 'post_name': post.content_link,
+ 'content': post.name,
})
- return request.website.render("website_forum.edit_post", values)
+ template = "website_forum.new_link" if post.post_type == 'link' and not post.parent_id else "website_forum.edit_post"
+ return request.website.render(template, values)
@http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/save', type='http', auth="user", methods=['POST'], website=True)
def post_save(self, forum, post, **kwargs):
- post_tags = forum._tag_to_write_vals(kwargs.get('post_tag', ''))
+ post_tags = forum._tag_to_write_vals(kwargs.get('post_tags', ''))
vals = {
'tag_ids': post_tags,
'name': kwargs.get('post_name'),
'content': kwargs.get('content'),
+ 'content_link': kwargs.get('content_link'),
}
post.write(vals)
question = post.parent_id if post.parent_id else post
diff --git a/addons/website_forum/data/forum_default_faq.html b/addons/website_forum/data/forum_default_faq.html
index 9891c930a21..f2169cd2616 100644
--- a/addons/website_forum/data/forum_default_faq.html
+++ b/addons/website_forum/data/forum_default_faq.html
@@ -86,52 +86,10 @@
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
+ for a question or answer per day. The table given at the end 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>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 class="faq-question">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
diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py
index db57629611c..10fc95d3c3b 100644
--- a/addons/website_forum/models/forum.py
+++ b/addons/website_forum/models/forum.py
@@ -46,12 +46,25 @@ class Forum(models.Model):
# description and use
name = fields.Char('Forum Name', required=True, translate=True)
faq = fields.Html('Guidelines', default=_get_default_faq, translate=True)
- description = fields.Html(
+ description = fields.Text(
'Description',
translate=True,
- default='<p> This community is for professionals and enthusiasts of our products and services.'
+ default='This community is for professionals and enthusiasts of our products and services.'
'Share and discuss the best content and new marketing ideas,'
- 'build your professional profile and become a better marketer together.</p>')
+ 'build your professional profile and become a better marketer together.')
+ welcome_message = fields.Html(
+ 'Welcome Message',
+ default = """<section class="bg-info" style="height: 168px;"><div class="container">
+ <div class="row">
+ <div class="col-md-12">
+ <h1 class="text-center" style="text-align: left;">Welcome!</h1>
+ <p class="text-muted text-center" style="text-align: left;">This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.</p>
+ </div>
+ <div class="col-md-12">
+      <a href="#" class="js_close_intro">Hide Intro</a>    <a class="btn btn-primary forum_register_url" href="/web/login">Register</a> </div>
+ </div>
+ </div>
+ </section>""")
default_order = fields.Selection([
('create_date desc', 'Newest'),
('write_date desc', 'Last Updated'),
@@ -59,7 +72,7 @@ class Forum(models.Model):
('relevancy desc', 'Relevancy'),
('child_count desc', 'Answered')],
string='Default Order', required=True, default='write_date desc')
- relevancy_post_vote = fields.Float('First Relevancy Parameter', default=0.8)
+ relevancy_post_vote = fields.Float('First Relevancy Parameter', default=0.8, help="This formula is used in order to sort by relevancy. The variable 'votes' represents number of votes for a post, and 'days' is number of days since the post creation")
relevancy_time_decay = fields.Float('Second Relevancy Parameter', default=1.8)
default_post_type = fields.Selection([
('question', 'Question'),
@@ -119,6 +132,13 @@ class Forum(models.Model):
or (self.default_post_type == 'link' and not self.allow_link):
raise UserError(_('You cannot choose %s as default post since the forum does not allow it.' % self.default_post_type))
+ @api.one
+ @api.constrains('allow_link', 'allow_question', 'allow_discussion', 'default_post_type')
+ def _check_default_post_type(self):
+ if self.default_post_type == 'link' and not self.allow_link or self.default_post_type == 'question' and not self.allow_question or self.default_post_type == 'discussion' and not self.allow_discussion:
+ raise Warning(_('Post type in "Default post" must be activated'))
+
+
@api.model
def create(self, values):
return super(Forum, self.with_context(mail_create_nolog=True)).create(values)
@@ -145,8 +165,14 @@ class Forum(models.Model):
post_tags.insert(0, [6, 0, existing_keep])
return post_tags
+ def get_tags_first_char(self):
+ """ get set of first letter of forum tags """
+ tags = self.env['forum.tag'].search([('forum_id', '=', self.id), ('posts_count', '>', 0)])
+ return sorted(set([tag.name[0].upper() for tag in tags]))
+
class Post(models.Model):
+
_name = 'forum.post'
_description = 'Forum Post'
_inherit = ['mail.thread', 'website.seo.metadata']
@@ -210,7 +236,7 @@ class Post(models.Model):
vote.user_vote = mapped_vote.get(vote.id, 0)
@api.multi
- @api.depends('vote_ids')
+ @api.depends('vote_ids.vote')
def _get_vote_count(self):
read_group_res = self.env['forum.post.vote'].read_group([('post_id', 'in', self._ids)], ['post_id', 'vote'], ['post_id', 'vote'], lazy=False)
result = dict.fromkeys(self._ids, 0)
diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css
index 79fd7dd330c..395167cf615 100644
--- a/addons/website_forum/static/src/css/website_forum.css
+++ b/addons/website_forum/static/src/css/website_forum.css
@@ -50,9 +50,17 @@ img.img-avatar {
.oe_answer_true {
color: #3c763d; }
+.forum_answer .oe_answer_true:hover {
+ color: #4D964E;
+}
+
.oe_answer_false {
color: #bbbbbb; }
+.oe_answer_false:hover {
+ color: #9E9C9C;
+}
+
.favourite_question {
color: #bbbbbb !important; }
@@ -100,4 +108,6 @@ a.no-decoration {
z-index: 5; }
button.btn-link.text-muted {
- color: #999999; }
+ color: #999999;
+}
+
diff --git a/addons/website_forum/static/src/css/website_forum.sass b/addons/website_forum/static/src/css/website_forum.sass
index 8ade74975ea..1313516a084 100644
--- a/addons/website_forum/static/src/css/website_forum.sass
+++ b/addons/website_forum/static/src/css/website_forum.sass
@@ -51,9 +51,15 @@ img.img-avatar
.oe_answer_true
color: #3c763d
+ &:hover {
+ color: #4D964E;
+ }
.oe_answer_false
color: #bbbbbb
+ &:hover {
+ color: #9E9C9C;
+ }
.favourite_question
color: #bbbbbb !important
diff --git a/addons/website_forum/static/src/js/website_forum.editor.js b/addons/website_forum/static/src/js/website_forum.editor.js
index 6687ed5e3f2..b14191b3557 100644
--- a/addons/website_forum/static/src/js/website_forum.editor.js
+++ b/addons/website_forum/static/src/js/website_forum.editor.js
@@ -9,10 +9,24 @@
website.prompt({
id: "editor_new_forum",
window_title: _t("New Forum"),
- input: "Forum Name",
- }).then(function (forum_name) {
+ input: "Forum Name",init: function () {
+ var $group = this.$dialog.find("div.form-group");
+ $group.removeClass("mb0");
+
+ var $add = $(
+ '<div class="form-group mb0">'+
+ '<label class="col-sm-offset-3 col-sm-9 text-left">'+
+ ' <input type="checkbox" required="required"/> '+
+ '</label>'+
+ '</div>');
+ $add.find('label').append(_t("Add page in menu"));
+ $group.after($add);
+ }
+ }).then(function (forum_name, field, $dialog) {
+ var add_menu = ($dialog.find('input[type="checkbox"]').is(':checked'));
website.form('/forum/new', 'POST', {
- forum_name: forum_name
+ forum_name: forum_name,
+ add_menu: add_menu || ""
});
});
},
diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js
index 3d7ec8c8559..6abe4b97ffc 100644
--- a/addons/website_forum/static/src/js/website_forum.js
+++ b/addons/website_forum/static/src/js/website_forum.js
@@ -1,4 +1,6 @@
+
openerp.website.if_dom_contains('.website_forum', function () {
+ var _t = openerp._t;
$("[data-toggle='popover']").popover();
$('.karma_required').on('click', function (ev) {
var karma = $(ev.currentTarget).data('karma');
@@ -6,8 +8,8 @@
ev.preventDefault();
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="karma_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
- karma + ' karma is required to perform this action. You can earn karma by having '+
- 'your answers upvoted by the community.</div>');
+ karma + _t(' karma is required to perform this action. You can earn karma by having your answers upvoted by the community.')+
+ '</div>');
var vote_alert = $(ev.currentTarget).parent().find("#vote_alert");
if (vote_alert.length == 0) {
$(ev.currentTarget).parent().append($warning);
@@ -24,12 +26,12 @@
if (data['error'] == 'own_post'){
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
- 'Sorry, you cannot vote for your own posts'+
+ _t('Sorry, you cannot vote for your own posts')+
'</div>');
} else if (data['error'] == 'anonymous_user'){
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
- 'Sorry you must be logged to vote'+
+ _t('Sorry you must be logged to vote')+
'</div>');
}
vote_alert = $link.parent().find("#vote_alert");
@@ -37,7 +39,7 @@
$link.parent().append($warning);
}
} else {
- $link.parent().find("#vote_count").html(data['vote_count']);
+ $link.parent().find(".vote_count").html(data['vote_count']);
if (data['user_vote'] == 0) {
$link.parent().find(".text-success").removeClass("text-success");
$link.parent().find(".text-warning").removeClass("text-warning");
@@ -60,7 +62,7 @@
if (data['error'] == 'anonymous_user') {
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
- 'Sorry, anonymous users cannot choose correct answer.'+
+ _t('Sorry, anonymous users cannot choose correct answer.')+
'</div>');
}
correct_answer_alert = $link.parent().find("#correct_answer_alert");
@@ -69,6 +71,7 @@
}
} else {
if (data) {
+ $(".oe_answer_true").addClass('oe_answer_false').removeClass("oe_answer_true");
$link.addClass("oe_answer_true").removeClass('oe_answer_false');
} else {
$link.removeClass("oe_answer_true").addClass('oe_answer_false');
@@ -120,15 +123,22 @@
openerp.jsonRpc("/forum/validate_email/close", 'call', {});
});
+ // welcome message action button
+ var forum_login = _.string.sprintf('%s/web?redirect=%s',
+ window.location.origin, escape(window.location.href));
+ $('.forum_register_url').attr('href',forum_login);
$('.js_close_intro').on('click', function (ev) {
ev.preventDefault();
- document.cookie = "no_introduction_message = false";
+ document.cookie = "forum_welcome_message = false";
+ $('.forum_intro').slideUp();
return true;
});
+
$('.link_url').on('change', function (ev) {
ev.preventDefault();
+ var $link = $(ev.currentTarget);
var display_error = function(){
var $warning = $('<div class="alert alert-danger alert-dismissable" style="position:absolute; margin-top: -180px; margin-left: 90px;">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
@@ -137,11 +147,13 @@
$link.parent().append($warning);
$("button#btn_post_your_article")[0].disabled = true;
};
- var $link = $(ev.currentTarget);
- if ($link.val().search("^http(s?)://.*")) {
- display_error();
- } else {
- openerp.jsonRpc("/forum/get_url_title", 'call', {'url': $link.val()}).then(function (data) {
+ var url = $link.val();
+ if (url.search("^http(s?)://.*")) {
+ url = 'http://'+url;
+ }
+ var regex = new RegExp("(http(s)?://.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)");
+ if(regex.test(url)){
+ openerp.jsonRpc("/forum/get_url_title", 'call', {'url': url}).then(function (data) {
if(data){
$("input[name='post_name']")[0].value = data;
$('button#btn_post_your_article').prop('disabled', false);
@@ -149,6 +161,8 @@
display_error();
}
});
+ }else{
+ display_error();
}
});
diff --git a/addons/website_forum/views/forum.xml b/addons/website_forum/views/forum.xml
index d9cbde28bd2..fd90550dd9d 100644
--- a/addons/website_forum/views/forum.xml
+++ b/addons/website_forum/views/forum.xml
@@ -32,27 +32,19 @@
<field name="description"/>
<notebook>
<page string="Options">
- <group>
- <group string="Post">
- <field name="allow_question"/>
- <field name="allow_link"/>
- <field name="allow_discussion"/>
- <field name="default_post_type"/>
- </group>
- <div>
- <group string="Social">
- <field name="allow_bump"/>
- <field name="allow_share"/>
- </group>
- <group string="Orders">
- <field name="default_order"/>
- <label for="relevancy_post_vote" string="Relevancy Computation"/>
- <div>
- (votes - 1) ** <field name="relevancy_post_vote" class="oe_inline"/> / (days + 2) ** <field name="relevancy_time_decay" class="oe_inline"/>
- </div>
- </group>
- </div>
- </group>
+ <group string="Post Types">
+ <field name="allow_question"/>
+ <field name="allow_link"/>
+ <field name="allow_discussion"/>
+ <field name="default_post_type"/>
+ </group>
+ <group string="Orders">
+ <field name="default_order"/>
+ <label for="relevancy_post_vote" string="Relevancy Computation" groups="base.group_no_one"/>
+ <div groups="base.group_no_one">
+ (votes - 1) ** <field name="relevancy_post_vote" class="oe_inline"/> / (days + 2) ** <field name="relevancy_time_decay" class="oe_inline"/>
+ </div>
+ </group>
</page>
<page string='Karma Gains'>
<group>
@@ -158,6 +150,16 @@
<field name="relevancy"/>
</group>
</group>
+ <group string="Answers" attrs="{'invisible':[('parent_id','!=',False)]}">
+ <field name="child_ids" nolabel="1">
+ <tree>
+ <field name="create_uid" string="Answered by"/>
+ <field name="vote_count"/>
+ <field name="state"/>
+ <field name="is_correct"/>
+ </tree>
+ </field>
+ </group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
@@ -176,13 +178,14 @@
<field name="create_uid"/>
<field name="forum_id"/>
<field name="tag_ids" string="Tag"/>
- <filter string="Question" domain="[('parent_id', '=', False)]" />
+ <filter string="Questions" name="questions" domain="[('parent_id', '=', False)]" />
<filter string="Answers" domain="[('parent_id', '!=', False)]" />
<filter string="Accepted Answer" domain="[('is_correct' , '!=', False), ('parent_id', '!=', False)]" />
<filter string="Answered Questions" domain="[('child_count', '!=', 0), ('parent_id', '=', False)]" />
<group expand="0" string="Group By">
<filter string="Forum" domain="[]" context="{'group_by': 'forum_id'}"/>
<filter string="Author" domain="[]" context="{'group_by': 'create_uid'}"/>
+ <filter string="Post" domain="[]" context="{'group_by': 'parent_id'}"/>
</group>
</search>
</field>
@@ -206,6 +209,7 @@
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="view_forum_post_list"/>
<field name="search_view_id" ref="view_forum_post_search"/>
+ <field name="context">{'search_default_questions':1}</field>
</record>
<menuitem id="menu_forum_posts" parent="menu_website_forum" name="Posts" action="action_forum_post" sequence="20"/>
diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml
index 0ef3bb3d71c..b5c0615a2e1 100644
--- a/addons/website_forum/views/website_forum.xml
+++ b/addons/website_forum/views/website_forum.xml
@@ -45,15 +45,10 @@
<!-- Page Index -->
<template id="header" name="Forum Index">
<t t-call="website.layout">
- <div t-if="is_public_user and not no_introduction_message" class="alert alert-success alert-dismissible" id="oe_forum_intro">
- <div class="container">
- <h1 class="mt0">Welcome!</h1>
- <div t-field="forum.description"/>
- <a class='btn btn-primary' t-attf-href="/web?redirect=#{ request.httprequest.url }">Register</a>
- <button type="button" href="#oe_forum_intro" class="btn btn-link js_close_intro" data-dismiss="alert" aria-label="Close" aria-hidden="true">Hide Intro</button>
- </div>
+ <div t-if="is_public_user and not forum_welcome_message" class="forum_intro">
+ <div t-field="forum.welcome_message"/>
</div>
-
+
<div class="container mt16 website_forum">
<div class="navbar navbar-default">
<div class="navbar-header">
@@ -96,6 +91,15 @@
<button type="submit" class="btn btn-default">Search</button>
</span>
</div>
+ <span class="dropdown" groups="base.group_erp_manager">
+ <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
+ <i class="fa fa-cog"/>
+ </button>
+ <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
+ <li role="presentation"><a role="menuitem" tabindex="-1" t-attf-href="/forum/#{slug(forum)}/edit_welcome_message?enable_editor=1">Design Welcome Message</a></li>
+ <li role="presentation"><a role="menuitem" tabindex="-1" t-attf-href="/web#id=#{forum.id}&amp;view_type=form&amp;model=forum.forum">Forum Settings</a></li>
+ </ul>
+ </span>
</form>
</div>
</div>
@@ -127,21 +131,24 @@
<t t-raw="0"/>
</div>
<div class="col-sm-3" id="right-column">
- <div t-if="not header.get('ask_hide')" t-attf-class="btn-group btn-block mb16 #{(user.karma &lt; forum.karma_ask) and 'karma_required' or ''}" t-attf-data-karma="#{forum.karma_ask}">
- <a type="button" class="btn btn-primary btn-lg col-sm-10" t-attf-href="/forum/#{slug(forum)}/ask?post_type=#{forum.default_post_type}">
+ <div t-if="not header.get('ask_hide')" t-attf-class="btn-group btn-block mb16 #{(user.karma &lt; forum.karma_ask) and not is_public_user and 'karma_required' or ''}" t-attf-data-karma="#{forum.karma_ask}">
+ <t t-set="multi_type" t-value="(forum.allow_link and forum.allow_question) or (forum.allow_link and forum.allow_discussion) or (forum.allow_question and forum.allow_discussion)"/>
+ <a type="button" t-attf-class="btn btn-primary btn-lg #{'col-sm-10' if multi_type else 'col-sm-12'}" t-attf-href="/forum/#{slug(forum)}/ask?post_type=#{forum.default_post_type}">
<t t-if="forum.default_post_type == 'question'">Ask a Question</t>
<t t-if="forum.default_post_type == 'link'">Submit a Link</t>
<t t-if="forum.default_post_type == 'discussion'">New Discussion</t>
</a>
- <button type="button" class="btn btn-primary btn-lg col-sm-2 dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- <span class="sr-only">Select Post</span>
- </button>
- <ul class="dropdown-menu" role="menu">
- <li t-if="forum.allow_question"><a t-attf-href="/forum/#{slug(forum)}/ask?post_type=question">Ask a Question</a></li>
- <li t-if="forum.allow_link"><a t-attf-href="/forum/#{slug(forum)}/ask?post_type=link">Submit a Link</a></li>
- <li t-if="forum.allow_discussion"><a t-attf-href="/forum/#{slug(forum)}/ask?post_type=discussion">New Discussion</a></li>
- </ul>
+ <t t-if="multi_type">
+ <button type="button" class="btn btn-primary btn-lg col-sm-2 dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ <span class="sr-only">Select Post</span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ <li t-if="forum.allow_question"><a t-attf-href="/forum/#{slug(forum)}/ask?post_type=question">Ask a Question</a></li>
+ <li t-if="forum.allow_link"><a t-attf-href="/forum/#{slug(forum)}/ask?post_type=link">Submit a Link</a></li>
+ <li t-if="forum.allow_discussion"><a t-attf-href="/forum/#{slug(forum)}/ask?post_type=discussion">New Discussion</a></li>
+ </ul>
+ </t>
</div>
<div class="panel panel-default">
<div class="panel-heading">
@@ -159,7 +166,7 @@
<h3 class="panel-title">About This Community</h3>
</div>
<div class="panel-body">
- <t t-raw="forum.description"/>
+ <span t-field="forum.description"/>
<a t-if="not header.get('is_guidelines')" t-attf-href="/forum/#{slug(forum)}/faq" class="fa fa-arrow-right"> Read Guidelines</a>
<a t-if="header.get('is_guidelines')" t-attf-href="/forum/#{slug(forum)}" class="fa fa-arrow-right"> Back to <span t-field="forum.name"/></a>
</div>
@@ -197,6 +204,13 @@
</t>
</template>
+<!-- Template use to edit the welcome_message -->
+<template id="edit_welcome_message">
+ <t t-call="website.layout">
+ <div t-field="forum.welcome_message"/>
+ </t>
+</template>
+
<!-- Display a post -->
<template id="display_post">
<div class="question">
@@ -207,21 +221,15 @@
</div>
<div class="question-block">
<div class="question-name">
- <t t-if="question.post_type == 'link'">
- <a t-att-href="question.content_link" target="_blank">
- <span class="fa fa-link" t-if="forum.default_post_type != 'link'"/>
- <t t-esc="question.name"/>
- </a>
- </t>
- <t t-if="question.post_type in ('question', 'discussion')">
- <a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }">
- <span class="fa fa-info-circle" t-if="question.post_type=='question' and forum.default_post_type != 'question'"/>
- <span class="fa fa-comment" t-if="question.post_type=='discussion' and forum.default_post_type != 'discussion'"/>
- <t t-esc="question.name"/>
- </a>
- </t>
+ <a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }">
+ <span t-field="question.name"/>
+ </a>
<span t-if="not question.active"><b> [Deleted]</b></span>
<span t-if="question.state == 'close'"><b> [Closed]</b></span>
+ <t t-if="question.post_type == 'link'" >
+ <a title="Redirect to external link" t-att-href="question.content_link" class="text-muted"><i class="fa fa-external-link forum_link"/></a>
+ </t>
+ <span t-if="question.has_validated_answer" title="Question has accepted answer"><i class="fa fa-check-circle oe_answer_true"/></span>
</div>
<t t-foreach="question.tag_ids" t-as="question_tag">
<a t-attf-href="/forum/#{ slug(forum) }/tag/#{slug(question_tag)}/questions">
@@ -230,12 +238,21 @@
</a>
</t>
<small class="text-muted">
+ <i t-if="question.post_type == 'question'" t-attf-class="fa fa-question-circle" t-att-title="question.post_type.capitalize()" />
+ <i t-if="question.post_type == 'discussion'" t-attf-class="fa fa-comments-o" t-att-title="question.post_type.capitalize()" />
+ <i t-if="question.post_type == 'link'" t-attf-class="fa fa-link" t-att-title="question.post_type.capitalize()" />
By <span t-field="question.create_uid" t-field-options='{"widget": "contact", "country_image": true, "fields": ["name", "country_id"]}' style="display: inline-block;"/>
• <span t-field="question.write_date" t-field-options='{"format":"short"}'/>
+ • <span t-field="question.views" /> View<t t-if="question.views&gt;1">s</t>
• <a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }">
+
<t t-esc="question.child_count"/>
- <t t-if="question.child_count&gt;1">comments</t>
- <t t-if="question.child_count&lt;=1">comment</t>
+ <t t-if="question.post_type == 'question'">
+ Answer<t t-if="question.child_count&gt;1">s</t>
+ </t>
+ <t t-if="question.post_type != 'question'">
+ Comment<t t-if="question.child_count&gt;1">s</t>
+ </t>
</a>
</small>
</div>
@@ -263,6 +280,41 @@
<template id="faq">
<t t-call="website_forum.header">
<div t-field="forum.faq"/>
+ <table class="table table-striped">
+ <tbody>
+ <tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_upvote"/></td>
+ <td>upvote, add comments</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_downvote"/></td>
+ <td>downvote</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_editor"/></td>
+ <td>insert text link, upload files</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_comment_unlink_own"/></td>
+ <td>delete own comment</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_close_own"/></td>
+ <td>flag offensive, close own questions</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_edit_all"/></td>
+ <td>edit any post, view offensive flags</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_answer_accept_all"/></td>
+ <td>accept any answer</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_comment_unlink_all"/></td>
+ <td>delete any comment</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_close_all"/></td>
+ <td>close any posts</td>
+ </tr><tr>
+ <td class="faq-rep-item"><strong t-field="forum.karma_unlink_all"/></td>
+ <td>delete any question or answer</td>
+ </tr>
+ </tbody>
+ </table>
</t>
</template>
@@ -360,7 +412,15 @@
<!-- Edition: Post Article -->
<template id="new_link">
<t t-call="website_forum.header">
- <h1 class="mt0">Submit a Link</h1>
+ <t t-set="link_create" t-value="False if post_name else True"/>
+ <t t-if="link_create">
+ <h1 class="mt0" >Submit a Link</h1>
+ <t t-set ="action_url" t-value="'/forum/' + slug(forum) +'/new?post_type=link'"/>
+ </t>
+ <t t-if="not link_create">
+ <h1 class="mt0" t-if="not link_create">Edit your Link</h1>
+ <t t-set ="action_url" t-value="'/forum/' + slug(forum) +'/post/' + slug(post) + '/save'"/>
+ </t>
<p class="mb32">
Share an awesome link. Your post will appear in the 'Newest' top-menu.
If the community vote on your post, it will get traction by being promoted
@@ -369,8 +429,9 @@
We keep a high level of quality in showcased posts, around 20% of the submited
posts will be featured.
</p>
- <form t-attf-action="/forum/#{ slug(forum) }/new?post_type=link" method="post" role="form" class="tag_text form-horizontal">
+ <form t-att-action="action_url" method="post" role="form" class="post_link tag_text form-horizontal">
<input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
+ <input type="hidden" name="karma_retag" t-attf-value="#{forum.karma_retag}" id="karma_retag"/>
<div class="form-group">
<label class="col-sm-2 control-label" for="content_link">URL to Share</label>
<div class="col-sm-8">
@@ -485,7 +546,7 @@
<div t-if="not is_answer">
<br/>
<input type="hidden" name="karma_retag" t-attf-value="#{forum.karma_retag}" id="karma_retag"/>
- <input type="text" name="post_tag" class="form-control col-md-9 js_select2" placeholder="Tags" t-attf-data-init-value="#{tags}" value="Tags"/>
+ <input type="text" name="post_tags" class="form-control col-md-9 js_select2" placeholder="Tags" t-attf-data-init-value="#{tags}" value="Tags"/>
<br/>
</div>
<button class="btn btn-primary btn-lg">Save</button>
@@ -614,6 +675,9 @@
</div>
</div>
<div class="text-muted mb16">
+ <i t-if="question.post_type == 'question'" t-attf-class="fa fa-question-circle" t-att-title="question.post_type.capitalize()" />
+ <i t-if="question.post_type == 'discussion'" t-attf-class="fa fa-comments-o" t-att-title="question.post_type.capitalize()" />
+ <i t-if="question.post_type == 'link'" t-attf-class="fa fa-link" t-att-title="question.post_type.capitalize()" />
By
<a t-attf-href="/forum/#{ slug(forum) }/user/#{ question.create_uid.id }"
t-field="question.create_uid"
@@ -750,7 +814,7 @@
t-field-options='{"widget": "contact", "country_image": true, "fields": ["name", "country_id"]}'
style="display: inline-block;"/>
<div class="text-muted">
- <a t-attf-href="/forum/#{slug(question.forum_id)}/question/#{slug(question)}#answer_#{answer.id}">On</a>
+ <a t-attf-href="/forum/#{slug(question.forum_id)}/question/#{slug(question)}#answer_#{answer.id}">On</a>
<span t-field="answer.create_date" t-field-options='{"format":"short"}'/>
</div>
</div>
@@ -872,6 +936,14 @@
similar questions. Using the right tags makes it easier for
others to find and answer your question.
</p>
+ <nav t-if="pager_tag_chars">
+ <ul class="pagination mt0 mb0">
+ <li class="disabled"><a><i class="fa fa-filter"></i></a></li>
+ <t t-foreach="pager_tag_chars" t-as="tuple_char">
+ <li t-attf-class="#{'active' if active_char_tag == tuple_char[1] else ''}"><a t-attf-href="/forum/#{slug(forum)}/tag/#{tuple_char[1]}"><t t-esc="tuple_char[0]"/></a></li>
+ </t>
+ </ul>
+ </nav>
<div class="row">
<div class="col-sm-3 mt16" t-foreach="tags" t-as="tag">
<a t-attf-href="/forum/#{ slug(forum) }/tag/#{ slug(tag) }/questions?{{ keep_query( filters='tag') }}" class="label label-default">
@@ -1047,7 +1119,7 @@
<div class="form-group">
<label class="col-md-2 control-label mb16" for="description">Biography</label>
<div class="col-md-8 mb16">
- <textarea name="description" id="description" style="min-height: 120px" required="True"
+ <textarea name="description" id="description" style="min-height: 120px" required="True"
class="form-control load_editor"><t t-esc="user.partner_id.website_description"/></textarea>
</div>
</div>