[IMP] better layout and options
authorFabien Pinckaers <fp@openerp.com>
Sat, 4 Oct 2014 19:19:46 +0000 (21:19 +0200)
committerFabien Pinckaers <fp@openerp.com>
Sat, 4 Oct 2014 19:19:46 +0000 (21:19 +0200)
addons/website_forum/controllers/main.py
addons/website_forum/models/forum.py
addons/website_forum/static/src/js/website_forum.js
addons/website_forum/views/forum.xml
addons/website_forum/views/website_forum.xml

index 95d5395..68fae56 100644 (file)
@@ -113,7 +113,7 @@ class WebsiteForum(http.Controller):
             order = 'create_date desc'
         else:
             sorting == 'relevancy'
-            order = 'relevancy desc'
+            order = 'relevancy'
 
         question_count = Post.search(cr, uid, domain, count=True, context=context)
         if tag:
index f9f55cb..2a8b934 100644 (file)
@@ -23,44 +23,53 @@ class Forum(osv.Model):
     _inherit = ['mail.thread', 'website.seo.metadata']
 
     _columns = {
-        'name': fields.char('Name', required=True, translate=True),
+        'name': fields.char('Forum Name', required=True, translate=True),
         'faq': fields.html('Guidelines'),
         'description': fields.html('Description'),
         'introduction_message': fields.html('Introduction Message'),
         'relevancy_option_first': fields.float('First Relevancy Parameter'),
         'relevancy_option_second': fields.float('Second Relevancy Parameter'),
+        'default_order': fields.selection([
+            ('creation','Newest'),
+            ('date','Last Updated'),
+            ('vote','Most Voted'),
+            ('relevancy','Relevancy'),
+            ], 'Default Order', required=True),
+        'allow_link': fields.boolean('Links', help="When clicking on the post, it redirects to an external link"),
+        'allow_question': fields.boolean('Questions', help="Users can answer only once per question. Contributors can edit answers and mark the right ones."),
+        'allow_discussion': fields.boolean('Discussions'),
         # karma generation
-        'karma_gen_question_new': fields.integer('Karma earned for new questions'),
-        'karma_gen_question_upvote': fields.integer('Karma earned for upvoting a question'),
-        'karma_gen_question_downvote': fields.integer('Karma earned for downvoting a question'),
-        'karma_gen_answer_upvote': fields.integer('Karma earned for upvoting an answer'),
-        'karma_gen_answer_downvote': fields.integer('Karma earned for downvoting an answer'),
-        'karma_gen_answer_accept': fields.integer('Karma earned for accepting an anwer'),
-        'karma_gen_answer_accepted': fields.integer('Karma earned for having an answer accepted'),
-        'karma_gen_answer_flagged': fields.integer('Karma earned for having an answer flagged'),
+        'karma_gen_question_new': fields.integer('Post a Questions'),
+        'karma_gen_question_upvote': fields.integer('Upvote a Question'),
+        'karma_gen_question_downvote': fields.integer('Downvote a Question'),
+        'karma_gen_answer_upvote': fields.integer('Upvote an Answer'),
+        'karma_gen_answer_downvote': fields.integer('Downvote an answer'),
+        'karma_gen_answer_accept': fields.integer('Accept an Answer'),
+        'karma_gen_answer_accepted': fields.integer('Have Your Answer Accepted'),
+        'karma_gen_answer_flagged': fields.integer('Have Your Answer Flagged'),
         # karma-based actions
-        'karma_ask': fields.integer('Karma to ask a new question'),
-        'karma_answer': fields.integer('Karma to answer a question'),
-        'karma_edit_own': fields.integer('Karma to edit its own posts'),
-        'karma_edit_all': fields.integer('Karma to edit all posts'),
-        'karma_close_own': fields.integer('Karma to close its own posts'),
-        'karma_close_all': fields.integer('Karma to close all posts'),
-        'karma_unlink_own': fields.integer('Karma to delete its own posts'),
-        'karma_unlink_all': fields.integer('Karma to delete all posts'),
-        'karma_upvote': fields.integer('Karma to upvote'),
-        'karma_downvote': fields.integer('Karma to downvote'),
-        'karma_answer_accept_own': fields.integer('Karma to accept an answer on its own questions'),
-        'karma_answer_accept_all': fields.integer('Karma to accept an answers to all questions'),
-        'karma_editor_link_files': fields.integer('Karma for linking files (Editor)'),
-        'karma_editor_clickable_link': fields.integer('Karma for clickable links (Editor)'),
-        'karma_comment_own': fields.integer('Karma to comment its own posts'),
-        'karma_comment_all': fields.integer('Karma to comment all posts'),
-        'karma_comment_convert_own': fields.integer('Karma to convert its own answers to comments and vice versa'),
-        'karma_comment_convert_all': fields.integer('Karma to convert all answers to answers and vice versa'),
-        'karma_comment_unlink_own': fields.integer('Karma to unlink its own comments'),
-        'karma_comment_unlink_all': fields.integer('Karma to unlinnk all comments'),
-        'karma_retag': fields.integer('Karma to change question tags'),
-        'karma_flag': fields.integer('Karma to flag a post as offensive'),
+        'karma_ask': fields.integer('Ask a new question'),
+        'karma_answer': fields.integer('Answer a question'),
+        'karma_edit_own': fields.integer('Edit its own posts'),
+        'karma_edit_all': fields.integer('Edit all posts'),
+        'karma_close_own': fields.integer('Close its own posts'),
+        'karma_close_all': fields.integer('Close all posts'),
+        'karma_unlink_own': fields.integer('Delete its own posts'),
+        'karma_unlink_all': fields.integer('Delete all posts'),
+        'karma_upvote': fields.integer('Upvote'),
+        'karma_downvote': fields.integer('Downvote'),
+        'karma_answer_accept_own': fields.integer('Accept an answer on its own questions'),
+        'karma_answer_accept_all': fields.integer('Accept an answers to all questions'),
+        'karma_editor_link_files': fields.integer('Linking files (Editor)'),
+        'karma_editor_clickable_link': fields.integer('Add clickable links (Editor)'),
+        'karma_comment_own': fields.integer('Comment its own posts'),
+        'karma_comment_all': fields.integer('Comment all posts'),
+        'karma_comment_convert_own': fields.integer('Convert its own answers to comments and vice versa'),
+        'karma_comment_convert_all': fields.integer('Convert all answers to answers and vice versa'),
+        'karma_comment_unlink_own': fields.integer('Unlink its own comments'),
+        'karma_comment_unlink_all': fields.integer('Unlink all comments'),
+        'karma_retag': fields.integer('Change question tags'),
+        'karma_flag': fields.integer('Flag a post as offensive'),
     }
 
     def _get_default_faq(self, cr, uid, context=None):
@@ -70,6 +79,10 @@ class Forum(osv.Model):
         return False
 
     _defaults = {
+        'default_order': 'date',
+        'allow_question': True,
+        'allow_link': False,
+        'allow_discussion': False,
         'description': 'This community is for professionals and enthusiasts of our products and services.',
         'faq': _get_default_faq,
         'introduction_message': """<h1>Welcome to Odoo Forum</h1>
index eed0c52..cf93590 100644 (file)
@@ -109,7 +109,7 @@ $(document).ready(function () {
             return true;
         });
 
-        $('.close_introduction_message').on('click', function (ev) {
+        $('.js_close_intro').on('click', function (ev) {
             ev.preventDefault();
             document.cookie = "no_introduction_message = false";
             return true;
index 33d246b..ff1a10b 100644 (file)
@@ -12,6 +12,9 @@
             <field name="arch" type="xml">
                 <tree string="Forums">
                     <field name="name"/>
+                    <field name="allow_question"/>
+                    <field name="allow_link"/>
+                    <field name="allow_discussion"/>
                 </tree>
             </field>
         </record>
             <field name="arch" type="xml">
                 <form string="Forum">
                     <sheet>
-                        <group>
+                        <label for="name" class="oe_edit_only"/>
+                        <h1>
                             <field name="name"/>
-                            <field name="relevancy_option_first"/>
-                            <field name="relevancy_option_second"/>
-                            <field name="karma_ask"/>
-                            <field name="karma_edit_own"/>
-                            <field name="karma_edit_all"/>
-                            <field name="karma_close_own"/>
-                            <field name="karma_close_all"/>
-                            <field name="karma_unlink_own"/>
-                            <field name="karma_unlink_all"/>
+                        </h1>
+                        <group>
+                            <group string="Post Types">
+                                <field name="allow_question"/>
+                                <field name="allow_link"/>
+                                <field name="allow_discussion"/>
+                            </group>
+                            <group string="Orders">
+                                <field name="default_order"/>
+                                <label for="relevancy_option_first" string="Relevancy Computation"/>
+                                <div>
+                                    (votes - 1) ** <field name="relevancy_option_first" class="oe_inline"/> / (days + 2) ** <field name="relevancy_option_second" class="oe_inline"/>
+                                </div>
+                            </group>
                         </group>
                         <group>
-                            <field name="karma_upvote"/>
-                            <field name="karma_downvote"/>
-                            <field name="karma_answer_accept_own"/>
-                            <field name="karma_answer_accept_all"/>
-                            <field name="karma_editor_link_files"/>
-                            <field name="karma_editor_clickable_link"/>
-                            <field name="karma_comment_own"/>
-                            <field name="karma_comment_all"/>
-                            <field name="karma_comment_convert_own"/>
-                            <field name="karma_comment_convert_all"/>
-                            <field name="karma_comment_unlink_own"/>
-                            <field name="karma_comment_unlink_all"/>
+                            <group string="Earn Karma">
+                                <field name="karma_gen_question_new"/>
+                                <field name="karma_gen_question_upvote"/>
+                                <field name="karma_gen_question_downvote"/>
+                                <field name="karma_gen_answer_upvote"/>
+                                <field name="karma_gen_answer_downvote"/>
+                                <field name="karma_gen_answer_accept"/>
+                                <field name="karma_gen_answer_accepted"/>
+                                <field name="karma_gen_answer_flagged"/>
+                            </group>
+                            <group string="Karma Related Rights">
+                                <field name="karma_ask"/>
+                                <field name="karma_edit_own"/>
+                                <field name="karma_edit_all"/>
+                                <field name="karma_close_own"/>
+                                <field name="karma_close_all"/>
+                                <field name="karma_unlink_own"/>
+                                <field name="karma_unlink_all"/>
+                                <field name="karma_upvote"/>
+                                <field name="karma_downvote"/>
+                                <field name="karma_answer_accept_own"/>
+                                <field name="karma_answer_accept_all"/>
+                                <field name="karma_editor_link_files"/>
+                                <field name="karma_editor_clickable_link"/>
+                                <field name="karma_comment_own"/>
+                                <field name="karma_comment_all"/>
+                                <field name="karma_comment_convert_own"/>
+                                <field name="karma_comment_convert_all"/>
+                                <field name="karma_comment_unlink_own"/>
+                                <field name="karma_comment_unlink_all"/>
+                            </group>
                         </group>
                     </sheet>
                     <div class="oe_chatter">
index 3452417..b0a4871 100644 (file)
         <t t-set="head">
             <t t-call-assets="website_forum.assets_forum"/>
         </t>
-        <div class="container mt16 website_forum">
-            <div class="row" t-if="is_public_user and not no_introduction_message">
-                <div class="alert alert-success alert-dismissable">
-                    <button type="button" class="close close_introduction_message" data-dismiss="alert" aria-hidden="true">&amp;times;</button>
-                    <div>
-                        <div t-field="forum.introduction_message"/>
-                        <a class='btn btn-primary' t-attf-href="/web?redirect=#{ request.httprequest.url }">Sign in</a>
-                    </div>
-                </div>
+        <div t-if="is_public_user and not no_introduction_message" class="alert alert-success alert-dismissable">
+            <div class="container">
+                <div t-field="forum.introduction_message"/>
+                <a class='btn btn-primary' t-attf-href="/web?redirect=#{ request.httprequest.url }">Register</a>
+                <button type="button" class="btn btn-link js_close_intro" data-dismiss="alert" aria-hidden="true">Hide Intro</button>
             </div>
+        </div>
+        <div class="container mt16 website_forum">
             <div class="navbar navbar-default">
                 <div class="navbar-header">
                     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#oe-help-navbar-collapse">
                 <div class="collapse navbar-collapse" id="oe-help-navbar-collapse">
                     <ul class="nav navbar-nav">
                         <li t-att-class="post_type == 'question' and 'active' or '' ">
-                            <a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( 'search', 'sorting', 'filters', post_type='question') }}">Question</a>
+                            <a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( 'search', 'post_type', 'filters', sorting='question') }}">Trending</a>
                         </li>
                         <li t-att-class="post_type == 'link' and 'active' or '' ">
-                            <a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( 'search', 'sorting', 'filters', post_type='link') }}">Articles</a>
-                        </li>
-                        <li t-att-class="post_type == 'discussion' and 'active' or '' ">
-                            <a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( 'search', 'sorting', 'filters', post_type='discussion') }}">Discussions</a>
+                            <a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( 'search', 'post_type', 'filters', sorting='link') }}">Newest</a>
                         </li>
                         <li t-att-class="searches.get('users') and 'active' or '' ">
                             <a t-attf-href="/forum/#{ slug(forum) }/users">People</a>
                             New <span class="caret"></span>
                         </a>
                         <ul class="dropdown-menu" role="menu">
-                            <li><a t-attf-href="/forum/#{slug(forum)}/ask_question">Question</a></li>
-                            <li><a t-attf-href="/forum/#{slug(forum)}/post_link">Article</a></li>
-                            <li><a t-attf-href="/forum/#{slug(forum)}/post_discussion">Discussion</a></li>
+                            <li><a t-attf-href="/forum/#{slug(forum)}/post_link">Share a Link</a></li>
+                            <li><a t-attf-href="/forum/#{slug(forum)}/ask_question">Ask a Question</a></li>
+                            <li><a t-attf-href="/forum/#{slug(forum)}/post_discussion">Launch a Discussion</a></li>
                         </ul>
                     </div>
                     <div class="panel panel-default">
             <t t-esc="question_count"/>
                 <span t-if="post_type == 'all'">Posts</span>
                 <span t-if="post_type == 'question'">Questions</span>
-                <span t-if="post_type == 'link'">Articles</span>
+                <span t-if="post_type == 'link'">Posts</span>
                 <span t-if="post_type == 'discussion'">Discussions</span>
             <t t-esc="search"/>
             <small class="dropdown" t-if="filters in ('all', 'unanswered','followed', 'tag')">