2014-02-21 13:16:08 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
from openerp.osv import osv, fields
|
|
|
|
from openerp import SUPERUSER_ID
|
|
|
|
|
|
|
|
from openerp.tools.translate import _
|
|
|
|
import re
|
|
|
|
|
|
|
|
from openerp.addons.website.models.website import slug
|
|
|
|
|
2014-02-22 06:27:15 +00:00
|
|
|
#TODO: Do we need a forum object like blog object ? Need to check with BE team
|
2014-02-22 06:02:01 +00:00
|
|
|
# class Forum(osv.Model):
|
|
|
|
# _name = 'blog.blog'
|
|
|
|
# _description = 'Blogs'
|
|
|
|
# _inherit = ['mail.thread', 'website.seo.metadata']
|
|
|
|
# _order = 'name'
|
|
|
|
#
|
|
|
|
# _columns = {
|
|
|
|
# 'name': fields.char('Name', required=True),
|
|
|
|
# 'description': fields.text('Description'),
|
|
|
|
# 'forum_post_ids': fields.one2many(
|
|
|
|
# 'website.forum.post', 'forum_id',
|
|
|
|
# 'Posts',
|
|
|
|
# ),
|
|
|
|
# }
|
2014-02-21 13:16:08 +00:00
|
|
|
|
2014-02-22 06:27:15 +00:00
|
|
|
#TODO: Need to implement badges and user profile
|
|
|
|
|
2014-02-22 06:02:01 +00:00
|
|
|
class Post(osv.Model):
|
2014-02-21 13:16:08 +00:00
|
|
|
_name = "website.forum.post"
|
2014-02-22 06:02:01 +00:00
|
|
|
_description = "Question"
|
2014-02-21 13:16:08 +00:00
|
|
|
_inherit = ['mail.thread', 'website.seo.metadata']
|
|
|
|
|
|
|
|
_columns = {
|
2014-02-22 06:02:01 +00:00
|
|
|
#TODO: do we need a forum object like blog object Need to check with BE team?
|
|
|
|
#'forum_id': fields.many2one('website.forum', 'Forum'),
|
|
|
|
|
2014-02-21 13:16:08 +00:00
|
|
|
'name': fields.char('Topic', size=64),
|
|
|
|
'body': fields.html('Contents', help='Automatically sanitized HTML contents'),
|
2014-02-22 06:02:01 +00:00
|
|
|
|
|
|
|
'create_date': fields.datetime('Asked on', select=True, readonly=True),
|
|
|
|
'create_uid': fields.many2one('res.users', 'Asked by', select=True, readonly=True ),
|
|
|
|
'write_date': fields.datetime('Update on', select=True, readonly=True ),
|
|
|
|
'write_uid': fields.many2one('res.users', 'Update by', select=True, readonly=True),
|
|
|
|
|
2014-02-21 13:16:08 +00:00
|
|
|
'tags': fields.many2many('website.forum.tag', 'forum_tag_rel', 'forum_id', 'forum_tag_id', 'Tag'),
|
2014-02-22 06:02:01 +00:00
|
|
|
'vote_ids':fields.one2many('website.forum.post.vote', 'Vote'),
|
|
|
|
|
|
|
|
'favourite_ids': fields.many2many('res.users', 'forum_favourite_rel', 'forum_id', 'user_id', 'Favourite'),
|
|
|
|
|
2014-02-21 13:16:08 +00:00
|
|
|
'state': fields.selection([('active', 'Active'),('close', 'Close'),('offensive', 'Offensive')], 'Status'),
|
2014-02-22 06:02:01 +00:00
|
|
|
'active': fields.boolean('Active'),
|
|
|
|
'views': fields.integer('Views'),
|
|
|
|
|
2014-02-21 13:16:08 +00:00
|
|
|
'parent_id': fields.many2one('website.forum.post', 'Parent'),
|
|
|
|
'child_ids': fields.one2many('website.forum.post', 'parent_id', 'Child'),
|
2014-02-22 06:02:01 +00:00
|
|
|
|
2014-02-21 13:16:08 +00:00
|
|
|
# TODO FIXME: when website_mail/mail_thread.py inheritance work -> this field won't be necessary
|
|
|
|
'website_message_ids': fields.one2many(
|
|
|
|
'mail.message', 'res_id',
|
|
|
|
domain=lambda self: [
|
|
|
|
'&', ('model', '=', self._name), ('type', '=', 'comment')
|
|
|
|
],
|
2014-02-22 06:02:01 +00:00
|
|
|
string='Post Messages',
|
|
|
|
help="Comments on forum post",
|
2014-02-21 13:16:08 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
_defaults = {
|
|
|
|
'state': 'active',
|
2014-02-22 06:02:01 +00:00
|
|
|
'active': True
|
2014-02-21 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 06:27:15 +00:00
|
|
|
class Users(osv.Model):
|
|
|
|
_inherit = 'res.users'
|
|
|
|
_columns = {
|
|
|
|
'question_ids':fields.one2many('website.forum.post', 'create_uid', 'Questions', domain=[('parent_id','=',False)]),
|
|
|
|
'answer_ids':fields.one2many('website.forum.post', 'create_uid', 'Answers', domain=[('parent_id','=',False), ('child_ids','=',True)]),
|
|
|
|
'vote_ids': fields.one2many('website.forum.post.vote', 'user_id', 'Votes'),
|
|
|
|
#TODO: 'tag_ids':fields.function()
|
|
|
|
|
|
|
|
#Badges : we will use the groups to define badges, two purpose will get solved
|
|
|
|
# - Define Groups as Badges with Forum as an Application
|
|
|
|
# - Access control
|
|
|
|
}
|
|
|
|
|
2014-02-22 06:02:01 +00:00
|
|
|
class PostHistory(osv.Model):
|
|
|
|
_name = 'website.forum.post.history'
|
2014-02-22 06:27:15 +00:00
|
|
|
_description = 'Post History'
|
2014-02-22 06:02:01 +00:00
|
|
|
_inherit = ['website.seo.metadata']
|
|
|
|
_columns = {
|
|
|
|
'post_id': fields.many2one('website.forum.post', 'Post'),
|
2014-02-22 06:27:15 +00:00
|
|
|
'create_date': fields.datetime('Created on', select=True, readonly=True),
|
|
|
|
'create_uid': fields.many2one('res.users', 'Created by', select=True, readonly=True),
|
|
|
|
'version': fields.integer('Version'),
|
2014-02-22 06:02:01 +00:00
|
|
|
'name': fields.char('Update Notes', size=64, required=True),
|
|
|
|
'body': fields.html('Contents', help='Automatically sanitized HTML contents'),
|
|
|
|
'tags': fields.many2many('website.forum.tag', 'forum_tag_rel', 'forum_id', 'forum_tag_id', 'Tag'),
|
|
|
|
}
|
|
|
|
|
|
|
|
class Vote(osv.Model):
|
2014-02-22 06:27:15 +00:00
|
|
|
_name = 'website.forum.post.vote'
|
2014-02-22 06:02:01 +00:00
|
|
|
_description = "Vote"
|
|
|
|
_column = {
|
|
|
|
'post_id': fields.many2one('website.forum.post', 'Post'),
|
|
|
|
'user_id': fields.many2one('res.users', 'User'),
|
|
|
|
'vote': fields.integer('rate'), #Value in between wither +1 or -1
|
|
|
|
}
|
|
|
|
|
|
|
|
class Tags(osv.Model):
|
2014-02-21 13:16:08 +00:00
|
|
|
_name = "website.forum.tag"
|
2014-02-22 06:27:15 +00:00
|
|
|
_description = "Tag"
|
2014-02-21 13:16:08 +00:00
|
|
|
_inherit = ['website.seo.metadata']
|
|
|
|
_columns = {
|
|
|
|
'name': fields.char('Order Reference', size=64, required=True),
|
2014-02-22 06:27:15 +00:00
|
|
|
'post_ids': fields.many2many('website.forum.post', 'forum_tag_que_rel', 'tag_id', 'forum_id', 'Questions', readonly=True),
|
2014-02-22 06:02:01 +00:00
|
|
|
}
|