[IMP] improved code to add forum from top menu 'Content', remove static id of below link, show only related questions per forum
bzr revid: tpa@tinyerp.com-20140304124002-otl1wn10c6qcggbs
This commit is contained in:
parent
782b4acaf3
commit
5471b1ba96
|
@ -39,23 +39,38 @@ class website_forum(http.Controller):
|
|||
@http.route(['/forum/'], type='http', auth="public", website=True, multilang=True)
|
||||
def forum(self, **searches):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
forum_obj = request.registry['website.forum']
|
||||
obj_ids = forum_obj.search(cr, uid, [], context=context)
|
||||
forum_ids = forum_obj.browse(cr, uid, obj_ids, context=context)
|
||||
Forum = request.registry['website.forum']
|
||||
obj_ids = Forum.search(cr, uid, [], context=context)
|
||||
forum_ids = Forum.browse(cr, uid, obj_ids, context=context)
|
||||
|
||||
values = {
|
||||
'forum_ids': forum_ids,
|
||||
'searches': {},
|
||||
}
|
||||
|
||||
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):
|
||||
values = {
|
||||
'forum': forum,
|
||||
}
|
||||
return request.website.render("website_forum.forum", values)
|
||||
|
||||
@http.route('/forum/add_forum/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
|
||||
def add_forum(self, forum_name="New Forum", **kwargs):
|
||||
vals = {
|
||||
'name': forum_name,
|
||||
'faq': 'F.A.Q'
|
||||
}
|
||||
forum_id = request.registry['website.forum'].create(request.cr, request.uid, vals, context=request.context)
|
||||
return request.redirect("/forum/%s/view/?enable_editor=1" % 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)
|
||||
def questions(self, forum, page=1, **searches):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
forum_obj = request.registry['website.forum.post']
|
||||
user_obj = request.registry['res.users']
|
||||
domain = [('parent_id', '=', False)]
|
||||
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False)]
|
||||
search = searches.get('search',False)
|
||||
type = searches.get('type',False)
|
||||
if not type:
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
<field name="parent_id" ref="website.main_menu"/>
|
||||
<field name="sequence" type="int">40</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="forum_help" model="website.forum">
|
||||
<field name="name">Help</field>
|
||||
</record>
|
||||
|
||||
<!--record id="action_open_website" model="ir.actions.act_url">
|
||||
<field name="name">Website Home</field>
|
||||
<field name="target">self</field>
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
<data>
|
||||
|
||||
<!-- Tag -->
|
||||
<record id="forum_help" model="website.forum">
|
||||
<field name="name">Help</field>
|
||||
</record>
|
||||
|
||||
<record id="tags_0" model="website.forum.tag">
|
||||
<field name="name">Contract</field>
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
website.is_editable = true;
|
||||
website.EditorBar.include({
|
||||
start: function() {
|
||||
website.is_editable_button = website.is_editable_button || !!$("#wrap.js_event").size();
|
||||
website.is_editable_button = website.is_editable_button || !!$("#wrap").size();
|
||||
var res = this._super();
|
||||
this.$(".dropdown:has(.oe_content_menu)").removeClass("hidden");
|
||||
return res;
|
||||
|
@ -17,12 +17,12 @@
|
|||
'click a[data-action=new_question]': function (ev) {
|
||||
ev.preventDefault();
|
||||
website.prompt({
|
||||
id: "editor_new_question",
|
||||
window_title: _t("New Question"),
|
||||
input: "Question Name",
|
||||
}).then(function (question_name) {
|
||||
website.form('/forum/add_question', 'POST', {
|
||||
question_name: question_name
|
||||
id: "editor_new_forum",
|
||||
window_title: _t("New Forum"),
|
||||
input: "Forum Name",
|
||||
}).then(function (forum_name) {
|
||||
website.form('/forum/add_forum', 'POST', {
|
||||
forum_name: forum_name
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<templates id="template" xml:space="preserve">
|
||||
<t t-extend="website.editorbar">
|
||||
<t t-jquery="ul.oe_content_menu" t-operation="append">
|
||||
<li><a href="#" data-action="new_question">New Question</a></li>
|
||||
<li><a href="#" data-action="new_question">New Forum</a></li>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
|
@ -26,8 +26,7 @@
|
|||
name="Footer Questions Link">
|
||||
<xpath expr="//footer//ul[@name='products']" position="inside">
|
||||
<li>
|
||||
<!--TODO: remove static id -->
|
||||
<a href="/forum/1">Q&A</a>
|
||||
<a t-attf-href="/forum/%(website_forum.forum_help)d/">Q&A</a>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
@ -162,6 +161,18 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<template id="forum">
|
||||
<t t-call="website.layout">
|
||||
<!--TODO: Improve template -->
|
||||
<div class="row">
|
||||
<h1 class="text-center" t-attf-href="/forum/#{ forum.id }" t-field="forum.name"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h1 class="text-center" t-attf-href="/forum/#{ forum.id }/faq" t-field="forum.faq"/>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="index">
|
||||
<t t-call="website_forum.header">
|
||||
<h1 class="page-header mt0">
|
||||
|
|
Loading…
Reference in New Issue