# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
import itertools
import logging
import math
import re
import uuid
from datetime import datetime
from werkzeug.exceptions import Forbidden
from flectra import api, fields, models, modules, tools, SUPERUSER_ID, _
from flectra.exceptions import UserError, ValidationError
from flectra.tools import pycompat, misc
_logger = logging.getLogger(__name__)
class KarmaError(Forbidden):
""" Karma-related error, used for forum and posts. """
pass
class Forum(models.Model):
_name = 'forum.forum'
_description = 'Forum'
_inherit = ['mail.thread', 'website.seo.metadata']
@api.model_cr
def init(self):
""" Add forum uuid for user email validation.
TDE TODO: move me somewhere else, auto_init ? """
forum_uuids = self.env['ir.config_parameter'].search([('key', '=', 'website_forum.uuid')])
if not forum_uuids:
forum_uuids.set_param('website_forum.uuid', str(uuid.uuid4()))
@api.model
def _get_default_faq(self):
with misc.file_open('website_forum/data/forum_default_faq.html', 'r') as f:
return f.read()
# description and use
name = fields.Char('Forum Name', required=True, translate=True)
active = fields.Boolean(default=True)
faq = fields.Html('Guidelines', default=_get_default_faq, translate=True)
description = fields.Text(
'Description',
translate=True,
default=lambda s: _('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.'))
welcome_message = fields.Html(
'Welcome Message',
default = """
Welcome!
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.