[IMP] layout

bzr revid: fp@tinyerp.com-20140312211726-wnho0pedhl4u1qv8
This commit is contained in:
Fabien Pinckaers 2014-03-12 22:17:26 +01:00
commit a8f130a2a8
16 changed files with 506 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,24 @@
{
'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',
'security/website_mail_group.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,92 @@
# -*- 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.addons.web import http
from openerp.addons.web.http import request
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')
group_ids = group_obj.search(cr, uid, [], 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/subscription/",
], type='json', auth="public", website=True)
def subscription(self, group_id=0, action=False ,**post):
cr, uid, context = request.cr, request.uid, request.context
group_obj = request.registry.get('mail.group')
if action:
group_obj.message_subscribe_users(cr, uid, [group_id], context=context)
else:
group_obj.message_unsubscribe_users(cr, uid, [group_id], context=context)
return []
@http.route([
"/groups/<model('mail.group'):group>/",
"/groups/<model('mail.group'):group>/page/<int:page>/"
], type='http', auth="public", website=True)
def thread(self, group, 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, [('model','=','mail.group'), ('res_id','=',group.id), ('parent_id','=',False)])
group_ids = group_obj.search(cr, uid, [])
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,
'pager': pager,
}
return request.website.render('website_mail_group.group_thread_list', values)
@http.route([
"/groups/<model('mail.group'):group>/message/<model('mail.message'):message>",
], type='http', auth="public", website=True)
def get_thread(self, group, message, **post):
cr, uid, context = request.cr, request.uid, request.context
thread_obj = request.registry.get('mail.message')
child_ids = thread_obj.search(cr, uid, [('parent_id','=',message.id)], order='date')
values = {
'main_thread': message,
'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,204 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="mail.group" id="group_community">
<field name="name">Community</field>
<field name="description">Community team</field>
</record>
<record model="mail.group" id="group_community">
<field name="message_follower_ids" eval="[(6, 0, [ref('base.partner_demo')])]"/>
</record>
<record id="msg_group_community_1" model="mail.message">
<field name="model">mail.group</field>
<field name="res_id" ref="group_community"/>
<field name="subject">Discover OpenERP V8</field>
<field name="body"><![CDATA[
<section data-snippet-id='text-block'>
<p>
Dear community,
</p><p>
We are organizing a serie of events to showcase the new
features of OpenERP v8.The events are visible on
http://openerp.com/events
</p><p>
The America Tour:
</p><p>
3/11: New York:
<a href="http://www.eventbrite.com/event/10576455463">
http://www.eventbrite.com/event/10576455463
</a>
</p><p>
3/13: Montreal:
<a href="http://www.eventbrite.com/event/10577717237">
http://www.eventbrite.com/event/10577717237
</a>
</p><p>
3/18: Los Angeles:
<a href="http://www.eventbrite.com/event/10577185647">
http://www.eventbrite.com/event/10577185647
</a>
</p><p>
3/20: San Francisco:
<a href="http://www.eventbrite.com/event/10577185647">
http://www.eventbrite.com/event/10577185647
</a>
</p><p>
4/10: Chicago:
<a href="http://www.eventbrite.com/event/10577414331">
http://www.eventbrite.com/event/10577414331
</a>
</p><p>
4/17: Miami:
<a href="http://www.eventbrite.com/event/10577616937">
http://www.eventbrite.com/event/10577616937
</a>
</p><p>
The European Tour:
</p><p>
2/20: Gosselies - Belgium:
<a href="http://www.eventbrite.com/e/inscription-avant-premiere-openerp-presentation-du-cms-ecommerce-gosselies-be-10408392783">
http://www.eventbrite.com/e/inscription-avant-premiere-openerp-presentation-du-cms-ecommerce-gosselies-be-10408392783
</a>
</p><p>
2/21: Brussels - Belgium:
<a href="http://www.eventbrite.com/e/presentation-of-the-website-builder-ecommerce-brussels-belgium-tickets-10313228143">
http://www.eventbrite.com/e/presentation-of-the-website-builder-ecommerce-brussels-belgium-tickets-10313228143
</a>
</p><p>
3/10: Germany:
<a href="http://www.eventbrite.com/e/exhibition-en-cebit-hannover-germany-registration-10615107071">
http://www.eventbrite.com/e/exhibition-en-cebit-hannover-germany-registration-10615107071
</a>
</p><p>
3/18: Lisbon, Portugal:
<a href="https://www.eventbrite.com/e/openerp-tour-discover-openerp-with-cms-ecommerce-lisbon-portugal-registration-10552736519">
https://www.eventbrite.com/e/openerp-tour-discover-openerp-with-cms-ecommerce-lisbon-portugal-registration-10552736519
</a>
</p><p>
Please spread the news and lets meet there.
</p><p>
Thanks,
</p>
</section>
]]></field>
<field name="type">email</field>
<field name="author_id" ref="base.partner_root"/>
<field name="date" eval="(DateTime.today() - timedelta(days=4)).strftime('%Y-%m-%d %H:%M')"/>
</record>
<record id="msg_group_community_2" model="mail.message">
<field name="model">mail.group</field>
<field name="res_id" ref="group_community"/>
<field name="subject">Re: Discover OpenERP V8</field>
<field name="body"><![CDATA[
<section data-snippet-id='text-block'>
<p>
Hi,
</p><p>
is there any event scheduled for Africa in near future?
</p><p>
Regards
</p>
</section>
]]></field>
<field name="type">email</field>
<field name="parent_id" ref="msg_group_community_1"></field>
<field name="author_id" ref="base.partner_demo"/>
<field name="date" eval="(DateTime.today() - timedelta(days=4)).strftime('%Y-%m-%d %H:%M')"/>
</record>
<record id="msg_group_community_3" model="mail.message">
<field name="model">mail.group</field>
<field name="res_id" ref="group_community"/>
<field name="subject">Re: Discover OpenERP V8</field>
<field name="body"><![CDATA[
<section data-snippet-id='text-block'>
<p>Yes,<p>
<p>in Moroco. You can contact Yves-Pascal (ypm@xxxxxxxxxxx) for morinformation.</p>
</section>
]]></field>
<field name="type">email</field>
<field name="parent_id" ref="msg_group_community_1"></field>
<field name="author_id" ref="base.partner_root"/>
<field name="date" eval="(DateTime.today() - timedelta(days=3)).strftime('%Y-%m-%d %H:%M')"/>
</record>
<record id="msg_group_community_4" model="mail.message">
<field name="model">mail.group</field>
<field name="res_id" ref="group_community"/>
<field name="subject">OpenERP Marketing</field>
<field name="body"><![CDATA[
<section data-snippet-id='text-block'>
<p>Dear community,</p>
<p>
Over the past years, we did not invest a lot in marketing. We put most
our efforts in R&D and Sales departements (starting from 2010) and
services (started in 2012).
</p><p>
Things are changing and we are now ready to invest a lot in marketing
activities. I just wrote a "very draft" internal document to discuss the
brand positioning of OpenERP:
<a href="http://pad.openerp.com/p/r.Zzg7LhlqI7elyigb">http://pad.openerp.com/p/r.Zzg7LhlqI7elyigb</a>
</p><p>
I would like to have your point of view on these marketing thoughts for
OpenERP.
</p><p>
Thanks,
</p>
</section>
]]></field>
<field name="type">email</field>
<field name="author_id" ref="base.partner_root"/>
<field name="date" eval="(DateTime.today() - timedelta(days=4)).strftime('%Y-%m-%d %H:%M')"/>
</record>
<record id="msg_group_community_5" model="mail.message">
<field name="model">mail.group</field>
<field name="res_id" ref="group_community"/>
<field name="subject">Re: OpenERP Marketing</field>
<field name="body"><![CDATA[
<section data-snippet-id='text-block'>
<p>
I just posted my feedback request
about the OpenERP brand positioning on
HN, you can react there:
<a href="https://news.ycombinator.com/item?id=7243726">
https://news.ycombinator.com/item?id=7243726
</a>
</p>
</section>
]]></field>
<field name="type">email</field>
<field name="author_id" ref="base.partner_demo"/>
<field name="parent_id" ref="msg_group_community_4"></field>
<field name="date" eval="(DateTime.today() - timedelta(days=4)).strftime('%Y-%m-%d %H:%M')"/>
</record>
<record id="msg_group_community_6" model="mail.message">
<field name="model">mail.group</field>
<field name="res_id" ref="group_community"/>
<field name="subject">Re: OpenERP Marketing</field>
<field name="body"><![CDATA[
<section data-snippet-id='text-block'>
<p>
Hello,
</p><p>
I don't think there can be only one positioning for OpenERP.
</p><p>
Depending on the customer in front of me, I will present OpenERP as :
</p>
<ol>
<li>an Apps-consuming platform (like a cell phone)</li>
<li>an ERP (in its traditional meaning)</li>
<li>a business apps development framework</li>
</ol>
<p>
OpenERP answers a wide range of needs, so you need to differentiate
the positioning based on the 3 axis above. In each of those axis,
the competition is different and arguments toward OpenERP will be
different as well.
</p>
</section>
]]></field>
<field name="type">email</field>
<field name="author_id" ref="base.partner_demo"/>
<field name="parent_id" ref="msg_group_community_4"></field>
<field name="date" eval="(DateTime.today() - timedelta(days=3)).strftime('%Y-%m-%d %H:%M')"/>
</record>
</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,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.rule" id="mail.mail_group_public_and_joined">
<field name="name">Mail.group: access only public and joined groups</field>
<field name="model_id" ref="mail.model_mail_group"/>
<field name="domain_force">['|', '|', ('public', '=', 'public'), ('message_follower_ids', 'in', [user.partner_id.id]), '&amp;', ('public','=','groups'), ('group_public_id','in', [g.id for g in user.groups_id])]</field>
<field name="perm_read" eval="False"/>
<field name="perm_create" eval="False"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,26 @@
$(document).ready(function () {
$('a.js_group').on('click', function (ev) {
ev.preventDefault();
var $link = $(ev.currentTarget);
var href = $link.attr("href");
var group_id = href.match(/subscription\/([0-9]+)/)[1];
var action = href.match(/action=(.*)/)[1] == 'follow' ? true : false;
openerp.jsonRpc("/groups/subscription/", 'call', {
'group_id': parseInt(group_id),
'action' : action,
})
.then(function (data) {
if (action){
$('li#'+ group_id).toggleClass('hidden visible');
$('.unfollow_' + group_id).toggleClass('visible hidden');
$('.follow_' + group_id).toggleClass('hidden visible');
}
else {
$('li#'+ group_id).toggleClass('visible hidden');
$('.unfollow_' + group_id).toggleClass('hidden visible');
$('.follow_' + group_id).toggleClass('visible hidden');
}
});
return false;
});
});

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="mail_groups" name="My Groups">
<t t-call="website.layout">
<t t-set="head">
<script type="text/javascript" src="/website_mail_group/static/src/js/website_mail_group.js"></script>
</t>
<div class="container">
<h1>
Our Mailing Lists
</h1>
<div class="row">
<div class="col-md-3 mt32 mb64" t-foreach="groups" t-as="group">
<img t-att-src="'/website/image?model=mail.group&amp;field=image_small&amp;id='+str(group['id'])" class="pull-left"/>
<div>
<a t-attf-href="/groups/#{group.id}" t-esc="group.name"/>
<div t-esc="group.description" class="text-muted"/>
<a groups="base.group_user" t-attf-class="btn btn-default js_group #{group.message_is_follower and 'hidden' or 'visible'} follow_#{group.id}" t-attf-href="/groups/subscription/#{ group.id }/?action=follow" t-attf-id="#{group.id}">Join Group</a>
<a groups="base.group_user" t-attf-class="btn btn-primary js_group #{group.message_is_follower and 'visible' or 'hidden'} unfollow_#{group.id}" t-attf-href="/groups/subscription/#{ group.id }/?action=unfollow" t-attf-id="#{group.id}">UnFollow</a>
</div>
</div>
</div>
</div>
</t>
</template>
<template id="group_thread_list">
<t t-call="website.layout">
<section class="container">
<div class="row">
<div class="col-md-5">
<t t-call="website.pager"/>
</div>
</div>
</section>
<section class="container">
<div class="row">
<div class="col-md-3">
<ul class="nav nav-pills nav-stacked" id="group_follows">
<t t-foreach="groups" t-as="group">
<li t-attf-class="#{group.message_is_follower and 'visible' or 'hidden'}" t-att-id="group.id">
<a t-attf-href="/groups/#{group.id}" t-esc="group.name"/>
</li>
</t>
</ul>
</div>
<div class="col-md-9">
<ul class="media-list">
<li t-foreach="thread_list" t-as="thread" class="media">
<a t-attf-href="/groups/#{active_group.id}/message/#{thread.id}" class="pull-left">
<img class="img-rounded pull-right mt0" style="height: 40px"
t-att-src="'/website/image?model=mail.message&amp;field=author_avatar&amp;id='+str(thread.id)"/>
</a>
<div class="media-body">
<h4 class="media-heading">
<a t-attf-href="/groups/#{active_group.id}/message/#{thread.id}" t-esc="thread.subject"/>
<br/>
<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>
</h4>
</div>
</li>
</ul>
</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="row">
<div class="col-md-1">
<img class="img-rounded pull-right" 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-raw="main_thread.body"/>
</div>
</div>
</div>
<div class="row" t-foreach="child_thread" t-as="message">
<div class="col-md-1">
<img class="img-rounded pull-right" 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" t-esc="message.subject"/>
<div class="panel-body" t-raw="message.body"/>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</data>
</openerp>

View File

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