[ADD] : module website_mail_group

bzr revid: aja@tinyerp.com-20140307132449-zy216yv5kmt3o0zw
This commit is contained in:
ajay javiya (OpenERP) 2014-03-07 18:54:49 +05:30
parent d448a63c26
commit a6fdc988ec
14 changed files with 295 additions and 2 deletions

View File

@ -181,6 +181,7 @@ class mail_message(osv.Model):
'subject': fields.char('Subject'),
'date': fields.datetime('Date'),
'message_id': fields.char('Message-Id', help='Message unique identifier', select=1, readonly=1),
'parent_message': fields.char('Immediate Parent', select=1, readonly=1),
'body': fields.html('Contents', help='Automatically sanitized HTML contents'),
'to_read': fields.function(_get_to_read, fnct_search=_search_to_read,
type='boolean', string='To read',
@ -834,7 +835,6 @@ class mail_message(osv.Model):
if context is None:
context = {}
default_starred = context.pop('default_starred', False)
if 'email_from' not in values: # needed to compute reply_to
values['email_from'] = self._get_default_from(cr, uid, context=context)
if 'message_id' not in values:

View File

@ -1259,6 +1259,7 @@ class mail_thread(osv.AbstractModel):
parent_ids = self.pool.get('mail.message').search(cr, uid, [('message_id', '=', decode(message['In-Reply-To']))])
if parent_ids:
msg_dict['parent_id'] = parent_ids[0]
msg_dict['parent_message'] = message.get('In-Reply-To')
if message.get('References') and 'parent_id' not in msg_dict:
parent_ids = self.pool.get('mail.message').search(cr, uid, [('message_id', 'in',
@ -1866,4 +1867,4 @@ class mail_thread(osv.AbstractModel):
message_obj.write(cr, uid, msg_ids_comment, {"res_id" : new_res_id, "model" : new_model}, context=context)
message_obj.write(cr, uid, msg_ids_not_comment, {"res_id" : new_res_id, "model" : new_model, "subtype_id" : None}, context=context)
return True
return True

View File

@ -0,0 +1,2 @@
import controllers
import models

View File

@ -0,0 +1,23 @@
{
'name': 'Mailing List Archive',
'category': 'Website',
'summary': '',
'version': '1.0',
'description': """
OpenERP Mail Group : Mailing List Archive
==================
""",
'author': 'OpenERP SA',
'depends': ['website','mail'],
'data': [
'views/website_mail_group.xml',
'views/website_mail_group_backend.xml',
'data/website_mail_group_data.xml',
],
'demo': [
'data/website_mail_group_demo.xml'
],
'qweb': ['static/src/xml/*.xml'],
'installable': True,
}

View File

@ -0,0 +1,3 @@
import main
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,104 @@
# -*- 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 import SUPERUSER_ID
from openerp.addons.web import http
from openerp.addons.web.http import request
import werkzeug
import datetime
import time
from openerp.tools.translate import _
class MailGroup(http.Controller):
_thread_per_page = 10
@http.route([
"/groups",
], type='http', auth="public", website=True)
def view(self, **post):
cr, uid, context = request.cr , request.uid, request.context
group_obj = request.registry.get('mail.group')
user_obj = request.registry.get('res.users')
group_ids = group_obj.search(cr, SUPERUSER_ID, [], context=context)
values = {
'groups': group_obj.browse(cr, uid, group_ids, context),
}
return request.website.render('website_mail_group.mail_groups', values)
@http.route([
"/groups/follow/<int:group_id>",
], type='http', auth="public", website=True)
def follow(self, group_id, **post):
cr, uid, context = request.cr , request.uid, request.context
group_obj = request.registry.get('mail.group')
group_obj.message_subscribe_users(cr, uid, [group_id], context=context)
return werkzeug.utils.redirect('/groups')
@http.route([
"/groups/unfollow/<int:group_id>",
], type='http', auth="public", website=True)
def unfollow(self, group_id, **post):
cr, uid, context = request.cr , request.uid, request.context
group_obj = request.registry.get('mail.group')
group_obj.message_unsubscribe_users(cr, uid, [group_id], context=context)
return werkzeug.utils.redirect('/groups')
@http.route([
"/groups/<int:group_id>/",
"/groups/<int:group_id>/page/<int:page>/"
], type='http', auth="public", website=True)
def thread(self, group_id, page=1, **post):
cr, uid, context = request.cr , request.uid, request.context
group_obj = request.registry.get('mail.group')
thread_obj = request.registry.get('mail.message')
thread_ids = thread_obj.search(cr, uid, [('type','=','email'),('model','=','mail.group'),('res_id','=',group_id),('parent_message','=',False)])
group_ids = group_obj.search(cr, SUPERUSER_ID, [])
pager = request.website.pager(
url='/groups/%s/' % group_id,
total=len(thread_ids),
page=page,
step=self._thread_per_page,
)
pager_begin = (page - 1) * self._thread_per_page
pager_end = page * self._thread_per_page
thread_ids = thread_ids[pager_begin:pager_end]
values = {
'groups': group_obj.browse(cr, uid, group_ids, context),
'thread_list': thread_obj.browse(cr, uid, thread_ids, context),
'active_group': group_obj.browse(cr, uid, group_id, context),
'pager': pager,
}
return request.website.render('website_mail_group.group_thread_list', values)
@http.route([
"/groups/thread/<int:message_id>",
], type='http', auth="public", website=True)
def get_thread(self, message_id, **post):
cr, uid, context = request.cr , request.uid, request.context
group_obj = request.registry.get('mail.group')
thread_obj = request.registry.get('mail.message')
child_ids = thread_obj.search(cr, uid, [('parent_id','=',message_id)])
values = {
'main_thread' : thread_obj.browse(cr, uid, message_id, context),
'child_thread' : thread_obj.browse(cr, uid, child_ids, context),
}
return request.website.render('website_mail_group.group_thread', values)

View File

@ -0,0 +1,4 @@
<openerp>
<data>
</data>
</openerp>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
</data>
</openerp>

View File

@ -0,0 +1 @@
import mail_group

View File

@ -0,0 +1,25 @@
# -*- 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
import uuid
import time
import datetime

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="header" inherit_id="website.layout" name="Header Mail Groups Link">
<xpath expr="//header//ul[@id='top_menu']/li" position="before">
<li>
<a href="/groups">Mail Groups</a>
</li>
</xpath>
</template>
<template id="mail_groups" name="My Groups">
<t t-call="website.layout">
<div class="row">
<div class="container">
<div class="col-md-3 col-md-push-1">
<t t-call="website_mail_group.navigation_menu"/>
</div>
<div class="col-md-8">
<t t-foreach="groups" t-as="group">
<div class="col-md-6" style="min-height: 150px">
<div class="col-md-3 col-md-pull-1">
<img t-att-src="'/website/image?model=mail.group&amp;field=image_small&amp;id='+str(group['id'])"/>
</div>
<div class="col-md-8">
<a t-attf-href="/groups/#{group.id}" t-esc="group.name"/>
<br/>
<small t-esc="group.description"/>
<br/>
<t t-if="group.message_is_follower">
<a class="btn btn-primary" t-attf-href="/groups/unfollow/#{ group.id }">UnFollow</a>
</t>
<t t-if="not group.message_is_follower">
<a class="btn btn-default" t-attf-href="/groups/follow/#{ group.id }">Join Group</a>
</t>
</div>
</div>
</t>
</div>
</div>
</div>
</t>
</template>
<template id="navigation_menu">
<ul class="nav nav-pills nav-stacked">
<t t-foreach="groups" t-as="group">
<li t-if="group.message_is_follower"><a t-attf-href="/groups/#{group.id}" t-esc="group.name"/></li>
</t>
</ul>
</template>
<template id="group_thread_list">
<t t-call="website.layout">
<section class="container">
<div class="row">
<div class="col-md-12 col-md-push-3">
<t t-call="website.pager"/>
</div>
</div>
</section>
<section class="container">
<div class="row">
<div class="col-md-3">
<t t-call="website_mail_group.navigation_menu"/>
</div>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading" t-esc="active_group.name"/>
<table class="table table-bordered">
<tbody>
<t t-foreach="thread_list" t-as="thread">
<tr>
<td>
<a t-attf-href="/groups/thread/#{thread.id}" t-esc="thread.subject"></a>
<img class="img-rounded pull-right mt0" t-att-src="'/website/image?model=mail.message&amp;field=author_avatar&amp;id='+str(thread.id)" style="width : 30px"/>
<p><small>by <t t-esc="thread.author_id.name and thread.author_id.name or thread.email_from"/> on <t t-esc="thread.date"/></small></p>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</div>
</div>
</section>
</t>
</template>
<template id="group_thread">
<t t-call="website.layout">
<t t-set="head">
<link rel='stylesheet' href='/website_mail_group/static/src/css/website_mail_group.css'/>
</t>
<div class="row mt32">
<div class="container">
<div class="col-md-1 mt0">
<img class="img-rounded pull-right mt0" t-att-src="'/website/image?model=mail.message&amp;field=author_avatar&amp;id='+str(main_thread.id)" style="width : 30px"/>
</div>
<div class="col-md-11">
<div class="panel panel-default">
<div class="panel-heading" t-esc="main_thread.subject"/>
<div class="panel-body">
<t t-raw="main_thread.body"/>
</div>
</div>
</div>
<t t-foreach="child_thread" t-as="message">
<div class="col-md-1 mt0">
<img class="img-rounded pull-right mt0" t-att-src="'/website/image?model=mail.message&amp;field=author_avatar&amp;id='+str(message.id)" style="width : 30px"/>
</div>
<div class="col-md-11">
<div class="panel panel-default">
<div class="panel-heading panel-line" t-esc="message.subject"/>
<t t-raw="message.body"/>
</div>
</div>
</t>
</div>
</div>
</t>
</template>
</data>
</openerp>

View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<openerp>
<data>
</data>
</openerp>