[IMP] improved code to use cookie instead of session to show introduction message...
authortpa-odoo <tpa@tinyerp.com>
Tue, 23 Sep 2014 10:14:32 +0000 (15:44 +0530)
committertpa-odoo <tpa@tinyerp.com>
Tue, 23 Sep 2014 10:14:32 +0000 (15:44 +0530)
addons/website_forum/controllers/main.py
addons/website_forum/static/src/js/website_forum.js
addons/website_forum/views/website_forum.xml

index b263cd9..95d5395 100644 (file)
@@ -42,7 +42,7 @@ class WebsiteForum(http.Controller):
                   'notifications': self._get_notifications(),
                   'header': kwargs.get('header', dict()),
                   'searches': kwargs.get('searches', dict()),
-                  'no_introduction_message': request.session.get('no_introduction_message', False),
+                  'no_introduction_message': request.httprequest.cookies.get('no_introduction_message', False),
                   }
         if forum:
             values['forum'] = forum
@@ -181,11 +181,6 @@ class WebsiteForum(http.Controller):
         arch = lxml.html.parse(urlopen(kwargs.get('url')))
         return arch.find(".//title").text
 
-    @http.route('/forum/remove_introduction_message', type='json', auth="public", methods=['POST'], website=True)
-    def remove_introduction_message(self, **kwargs):
-        request.session['no_introduction_message'] = True
-        return True
-
     @http.route(['''/forum/<model("forum.forum"):forum>/question/<model("forum.post", "[('forum_id','=',forum[0]),('parent_id','=',False)]"):question>'''], type='http', auth="public", website=True)
     def question(self, forum, question, **post):
         cr, uid, context = request.cr, request.uid, request.context
index 6e9ab6b..eed0c52 100644 (file)
@@ -111,8 +111,7 @@ $(document).ready(function () {
 
         $('.close_introduction_message').on('click', function (ev) {
             ev.preventDefault();
-            var $link = $(ev.currentTarget);
-            openerp.jsonRpc("/forum/remove_introduction_message", 'call', {})
+            document.cookie = "no_introduction_message = false";
             return true;
         });
 
index 860ce81..3452417 100644 (file)
                             t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }"> Comment
                         </a>
                     </li>
-                    <li t-if="question.type != 'question'">
+                    <li t-if="question.type != 'question' and not answer.parent_id or answer.parent_id and not answer.parent_id.parent_id">
                         <a t-attf-class="fa fa-comment-o #{not answer.can_comment and 'karma_required text-muted' or ''}"
                             t-attf-data-karma="#{not answer.can_comment and answer.karma_comment or 0}"
                             style="cursor: pointer" data-toggle="collapse"