[IMP] "website_forum" compatible with Multi-Website
This commit is contained in:
parent
f2eb0e33a2
commit
8f01116341
@ -81,7 +81,10 @@ class WebsiteForum(http.Controller):
|
||||
|
||||
@http.route(['/forum'], type='http', auth="public", website=True)
|
||||
def forum(self, **kwargs):
|
||||
forums = request.env['forum.forum'].search([])
|
||||
domain = []
|
||||
if not request.env.user.has_group('website.group_website_designer'):
|
||||
domain += [('website_ids', '!=', False), ('website_ids', 'in', request.website.id)]
|
||||
forums = request.env['forum.forum'].search(domain)
|
||||
return request.render("website_forum.forum_all", {'forums': forums})
|
||||
|
||||
@http.route('/forum/new', type='json', auth="user", methods=['POST'], website=True)
|
||||
@ -117,7 +120,7 @@ class WebsiteForum(http.Controller):
|
||||
def questions(self, forum, tag=None, page=1, filters='all', sorting=None, search='', post_type=None, **post):
|
||||
Post = request.env['forum.post']
|
||||
|
||||
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active')]
|
||||
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active'), ('website_id', '=', request.website.id)]
|
||||
if search:
|
||||
domain += ['|', ('name', 'ilike', search), ('content', 'ilike', search)]
|
||||
if tag:
|
||||
@ -408,6 +411,7 @@ class WebsiteForum(http.Controller):
|
||||
'name': kwargs.get('post_name'),
|
||||
'content': kwargs.get('content'),
|
||||
'content_link': kwargs.get('content_link'),
|
||||
'website_id': request.website.id,
|
||||
}
|
||||
post.write(vals)
|
||||
question = post.parent_id if post.parent_id else post
|
||||
@ -551,9 +555,9 @@ class WebsiteForum(http.Controller):
|
||||
def users(self, forum, page=1, **searches):
|
||||
User = request.env['res.users']
|
||||
step = 30
|
||||
tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True)])
|
||||
tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True), (('website_ids', '!=', False), ('website_ids', 'in', request.website.id))])
|
||||
pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30)
|
||||
user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True)], limit=step, offset=pager['offset'], order='karma DESC')
|
||||
user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True), (('website_ids', '!=', False), ('website_ids', 'in', request.website.id))], limit=step, offset=pager['offset'], order='karma DESC')
|
||||
# put the users in block of 3 to display them as a table
|
||||
users = [[] for i in range(len(user_obj) // 3 + 1)]
|
||||
for index, user in enumerate(user_obj):
|
||||
@ -723,7 +727,10 @@ class WebsiteForum(http.Controller):
|
||||
values['image'] = base64.b64encode(image)
|
||||
|
||||
if request.uid == user.id: # the controller allows to edit only its own privacy settings; use partner management for other cases
|
||||
values['website_published'] = kwargs.get('website_published') == 'True'
|
||||
if kwargs.get('website_published') == 'True':
|
||||
values['website_ids'] = [(4, request.website.id)]
|
||||
else:
|
||||
values['website_ids'] = [(3, request.website.id)]
|
||||
user.write(values)
|
||||
return werkzeug.utils.redirect("/forum/%s/user/%d" % (slug(forum), user.id))
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
<!-- Questions -->
|
||||
<record id="question_0" model="forum.post">
|
||||
<field name="name">How to configure alerts for employee contract expiration</field>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="post_type">question</field>
|
||||
<field name="views">3</field>
|
||||
@ -35,6 +36,7 @@
|
||||
</record>
|
||||
<record id="question_1" model="forum.post">
|
||||
<field name="name">CMS replacement for ERP and eCommerce</field>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="views">8</field>
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="content"><![CDATA[<p>I use Wordpress as a CMS and eCommerce platform. The developing in Wordpress is quite easy and solid but it missing ERP feature (there is single plugin to integrate with Frontaccounting) so I wonder:
|
||||
@ -49,6 +51,7 @@ In simple words does Flectra became CMS+ERP platform?</p>]]></field>
|
||||
<!-- Answer -->
|
||||
<record id="answer_0" model="forum.post">
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="content"><![CDATA[<p>Just for posterity so other can see. Here are the steps to set automatic alerts on any contract.. i.e. HR Employee, or Fleet for example. I will use fleet as an example.</p>
|
||||
<ul>
|
||||
<li>Step 1. As a user who has access rights to Technical Features, go to Settings --> Automated Actions. Create A new Automated Action. For the Related Document Model choose.. Contract information on a vehicle (you can also type in the actual model name.. fleet.vehicle.log.contract ) . Set the trigger date to ... Contract Expiration Date. The Next Field (Delay After Trigger Date) is a bit ridiculous. Who wants to be reminded of a contract expiration AFTER the fact? The field should say Days Before Date to Fire Action and the number should be converted to a negative. IMHO. Any way... to get a workable solution you must enter in the number in the negative. So for instance like me if you want to be warned 35 days BEFORE the expiration... put in Delay After Trigger Date.. the number -35 But the sake of testing, right now just put in -1 for 1 day before. Save the Action.
|
||||
@ -61,6 +64,7 @@ In simple words does Flectra became CMS+ERP platform?</p>]]></field>
|
||||
</record>
|
||||
<record id="answer_1" model="forum.post">
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="content"><![CDATA[
|
||||
<p>Flectra v8 (next release) provides a web module and an e-commerce module: www.flectra.com/page/website-builder
|
||||
The CMS editor in Flectra web is nice but I prefer Drupal for customization and there is a Drupal module for Flectra. I think WP is better than Flectra web too.
|
||||
@ -73,6 +77,7 @@ The CMS editor in Flectra web is nice but I prefer Drupal for customization and
|
||||
<record id="article_0" model="forum.post">
|
||||
<field name="content_link">https://www.flectra.com</field>
|
||||
<field name="name">Discover Flectra, an open source ERP.</field>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="post_type">link</field>
|
||||
<field name="views">6</field>
|
||||
@ -82,6 +87,7 @@ The CMS editor in Flectra web is nice but I prefer Drupal for customization and
|
||||
<!-- Discussion-->
|
||||
<record id="discussion_0" model="forum.post">
|
||||
<field name="name">How to setup a regular PostgreSQL database backup</field>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="content">I'm not familiar with PostgreSQL database administration , so I figured I might ask for help from someone more knowledgeable on the subject.
|
||||
|
||||
What would you recommend in order to setup a regular (daily) OpenERP database backup?
|
||||
@ -98,6 +104,7 @@ Are there any automation scripts available I might use?
|
||||
|
||||
<record id="reply_1" model="forum.post">
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="content"><![CDATA[<p>I use the following setup:</p>
|
||||
<ol>
|
||||
<li>Backup-Script</li>
|
||||
|
@ -25,7 +25,7 @@ class KarmaError(Forbidden):
|
||||
class Forum(models.Model):
|
||||
_name = 'forum.forum'
|
||||
_description = 'Forum'
|
||||
_inherit = ['mail.thread', 'website.seo.metadata']
|
||||
_inherit = ['mail.thread', 'website.seo.metadata', 'website.published.mixin']
|
||||
|
||||
@api.model_cr
|
||||
def init(self):
|
||||
@ -128,6 +128,11 @@ class Forum(models.Model):
|
||||
karma_user_bio = fields.Integer(string='Display detailed user biography', default=750)
|
||||
karma_post = fields.Integer(string='Ask questions without validation', default=100)
|
||||
karma_moderate = fields.Integer(string='Moderate posts', default=1000)
|
||||
website_ids = fields.Many2many('website', 'website_forum_pub_rel',
|
||||
'website_id', 'forum_id',
|
||||
string='Websites', copy=False,
|
||||
help='List of websites in which '
|
||||
'Forum is published.')
|
||||
|
||||
@api.one
|
||||
@api.constrains('allow_question', 'allow_discussion', 'allow_link', 'default_post_type')
|
||||
@ -272,6 +277,8 @@ class Post(models.Model):
|
||||
can_flag = fields.Boolean('Can Flag', compute='_get_post_karma_rights')
|
||||
can_moderate = fields.Boolean('Can Moderate', compute='_get_post_karma_rights')
|
||||
|
||||
website_id = fields.Many2one('website', string="Website")
|
||||
|
||||
def _search_can_view(self, operator, value):
|
||||
if operator not in ('=', '!=', '<>'):
|
||||
raise ValueError('Invalid operator: %s' % (operator,))
|
||||
|
@ -41,6 +41,7 @@
|
||||
<page string="Options">
|
||||
<group string="Post Types">
|
||||
<field name="allow_question"/>
|
||||
<field name="website_ids" widget="many2many_tags"/>
|
||||
<field name="allow_link"/>
|
||||
<field name="allow_discussion"/>
|
||||
<field name="default_post_type"/>
|
||||
@ -162,6 +163,7 @@
|
||||
</group><group>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
|
||||
<field name="state"/>
|
||||
<field name="website_id"/>
|
||||
<field name="closed_reason_id"/>
|
||||
<field name="closed_uid"/>
|
||||
<field name="closed_date"/>
|
||||
|
Loading…
Reference in New Issue
Block a user