[MERGE] Mailing List Archives for Website
bzr revid: fp@tinyerp.com-20140316123800-bqbk34ixeiure75d
This commit is contained in:
commit
f497f319a0
|
@ -89,7 +89,7 @@ def slug(value):
|
|||
else:
|
||||
# assume name_search result tuple
|
||||
id, name = value
|
||||
slugname = slugify(name)
|
||||
slugname = slugify(name or '')
|
||||
if not slugname:
|
||||
return str(id)
|
||||
return "%s-%d" % (slugname, id)
|
||||
|
|
|
@ -509,10 +509,10 @@
|
|||
class="js_follow_email form-control"
|
||||
placeholder="your email..."/>
|
||||
<span class="input-group-btn">
|
||||
<a href="#" class="btn btn-default js_unfollow_btn">Unsubscribe</a>
|
||||
<a href="#" class="btn btn-primary js_follow_btn">Subscribe</a>
|
||||
<a href="#" class="btn btn-default js_unfollow_btn">unsubscribe</a>
|
||||
<a href="#" class="btn btn-primary js_follow_btn">subscribe</a>
|
||||
</span>
|
||||
<div class="alert alert-success hidden">Thanks for your subscription!</div>
|
||||
<div class="alert alert-success hidden">thanks for your subscription!</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
import controllers
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
'name': 'Mailing List Archive',
|
||||
'category': 'Website',
|
||||
'summary': '',
|
||||
'version': '1.0',
|
||||
'description': """
|
||||
OpenERP Mail Group : Mailing List Archives
|
||||
==========================================
|
||||
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website_mail'],
|
||||
'data': [
|
||||
'views/website_mail_group.xml'
|
||||
],
|
||||
'demo': [
|
||||
'data/website_mail_group_demo.xml'
|
||||
],
|
||||
'qweb': [],
|
||||
'installable': True,
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import main
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,91 @@
|
|||
# -*- 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="user")
|
||||
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>/<any(thread,list):mode>",
|
||||
"/groups/<model('mail.group'):group>/<any(thread,list):mode>/page/<int:page>"
|
||||
], type='http', auth="public", website=True)
|
||||
def thread(self, group, mode='thread', page=1, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
|
||||
thread_obj = request.registry.get('mail.message')
|
||||
domain = [('model','=','mail.group'), ('res_id','=',group.id)]
|
||||
if mode=='thread':
|
||||
domain.append(('parent_id','=',False))
|
||||
thread_count = thread_obj.search_count(cr, uid, domain, context=context)
|
||||
pager = request.website.pager(
|
||||
url='/groups/%s/%s' % (group.id, mode),
|
||||
total=thread_count,
|
||||
page=page,
|
||||
step=self._thread_per_page,
|
||||
)
|
||||
thread_ids = thread_obj.search(cr, uid, domain, limit=self._thread_per_page, offset=pager['offset'])
|
||||
|
||||
messages = thread_obj.browse(cr, uid, thread_ids, context)
|
||||
for m in messages:
|
||||
print m.subject
|
||||
values = {
|
||||
'messages': messages,
|
||||
'group': group,
|
||||
'pager': pager,
|
||||
'mode': mode
|
||||
}
|
||||
return request.website.render('website_mail_group.group_messages', 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, mode='thread', page=1, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
values = {
|
||||
'message': message,
|
||||
'group': group,
|
||||
'mode': mode,
|
||||
'page': page,
|
||||
}
|
||||
return request.website.render('website_mail_group.group_message', values)
|
|
@ -0,0 +1,182 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="footer_mailing_list" inherit_id="website.layout" name="Footer Mailing List Link">
|
||||
<xpath expr="//footer//div[@name='info']/ul" position="inside">
|
||||
<li><a t-attf-href="/groups">Mailing List</a></li>
|
||||
</xpath>
|
||||
</template>
|
||||
<template id="mail_groups" name="Mailing Lists">
|
||||
<t t-call="website.layout">
|
||||
<div class="container">
|
||||
<h1>
|
||||
Our Mailing Lists
|
||||
</h1>
|
||||
<div class="row">
|
||||
<div class="col-sm-4" style="height: 140px" t-foreach="groups" t-as="group">
|
||||
<img t-att-src="'/website/image?model=mail.group&field=image_small&id='+str(group['id'])" class="pull-left"/>
|
||||
<div>
|
||||
<strong><a t-attf-href="/groups/#{ slug(group) }/thread" t-esc="group.name"/></strong>
|
||||
<div t-esc="group.description" class="text-muted"/>
|
||||
|
||||
<div class="input-group js_follow"
|
||||
t-att-data-id="group.id"
|
||||
data-object="mail.group"
|
||||
data-follow="off">
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="js_follow_email form-control"
|
||||
placeholder="your email..."/>
|
||||
<span class="input-group-btn">
|
||||
<a href="#" class="btn btn-default js_unfollow_btn">unsubscribe</a>
|
||||
<a href="#" class="btn btn-primary js_follow_btn">subscribe</a>
|
||||
</span>
|
||||
<div class="alert alert-success hidden">You have been subscribed!</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="group_messages" name="Message Threads">
|
||||
<t t-call="website.layout">
|
||||
<section class="container">
|
||||
<div class="row mt8">
|
||||
<div class="col-md-5">
|
||||
<ol class="breadcrumb mb8">
|
||||
<li><a href="/groups">Mailing Lists</a></li>
|
||||
<li class="active" t-esc="group.name"/>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<t t-call="website.pager"/>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="mt8 mb32">
|
||||
<span t-field="group.name"/>
|
||||
<small>List Archive</small>
|
||||
</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<ul class="nav nav-pills nav-stacked" id="group_mode">
|
||||
<li t-attf-class="#{mode=='thread' and 'active' or ''}">
|
||||
<a t-attf-href="/groups/#{ slug(group) }/thread">By thread</a>
|
||||
</li>
|
||||
<li t-attf-class="#{mode=='list' and 'active' or ''}">
|
||||
<a t-attf-href="/groups/#{ slug(group) }/list">By date</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<t t-call="website_mail_group.messages_short"/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="group_message">
|
||||
<t t-call="website.layout">
|
||||
<div class="container">
|
||||
<div class="row mt8">
|
||||
<div class="col-md-5">
|
||||
<ol class="breadcrumb mb8">
|
||||
<li><a href="/groups">Mailing Lists</a></li>
|
||||
<li>
|
||||
<a t-attf-href="/groups/#{ slug(group) }/#{mode}/page/#{str(page)}">
|
||||
<span t-field="group.name"/>
|
||||
</a>
|
||||
</li>
|
||||
<li class="active" t-esc="message.subject or 'Message'"/>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1 t-field="message.subject"/>
|
||||
<img class="img-rounded pull-left" t-att-src="'/website/image?model=mail.message&field=author_avatar&id='+str(message.id)" style="width : 30px"/>
|
||||
<h4 class="mt0 mb32">
|
||||
<span t-field="message.author_id.name"/>
|
||||
on <span t-field="message.date"/>
|
||||
</h4>
|
||||
<div t-raw="message.body"/>
|
||||
|
||||
<div class="row" t-if="message.attachment_ids">
|
||||
<h3 class="col-sm-12">Attachment(s):</h3>
|
||||
<div class="col-md-2 col-sm-3 text-center" t-foreach='message.attachment_ids' t-as='attachment'>
|
||||
<a t-att-href="'/mail/download_attachment?model=mail.message&id='+str(message.id)+'&method=download_attachment&attachment_id='+str(attachment.id)" target="_blank">
|
||||
<t t-if="attachment.file_type == 'webimage'">
|
||||
<img t-att-src="'/web/binary/image?model=ir.attachment&field=datas&id=' + str(attachment.id) + '&resize=100,80'"
|
||||
class='oe_attachment_embedded'></img>
|
||||
</t>
|
||||
<t t-if="attachment.file_type != 'webimage'">
|
||||
<img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.file_type + '.png'"
|
||||
class='oe_attachment_webimage'></img>
|
||||
</t>
|
||||
<div class='oe_attachment_name'><t t-raw='attachment.name' /></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="message.child_ids">
|
||||
<h2 class="page-header">Follow ups</h2>
|
||||
<t t-set="messages" t-value="message.child_ids"/>
|
||||
<t t-call="website_mail_group.messages_short"/>
|
||||
</div>
|
||||
<div t-if="message.parent_id">
|
||||
<h2 class="page-header">Reference</h2>
|
||||
<t t-set="messages" t-value="[message.parent_id]"/>
|
||||
<t t-call="website_mail_group.messages_short"/>
|
||||
</div>
|
||||
|
||||
<div class="jumbotron mt64">
|
||||
<h1>Join the discussion</h1>
|
||||
<p>
|
||||
Join this mailing list to follow or participate to this discussion.<br/>
|
||||
<span t-field="group.name"/>: <i t-field="group.description"/>
|
||||
</p>
|
||||
|
||||
<div style="max-width: 400px">
|
||||
<div class="input-group js_follow"
|
||||
t-att-data-id="group.id"
|
||||
data-object="mail.group"
|
||||
data-follow="off">
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="js_follow_email form-control"
|
||||
placeholder="your email..."/>
|
||||
<span class="input-group-btn">
|
||||
<a href="#" class="btn btn-default js_unfollow_btn">unsubscribe</a>
|
||||
<a href="#" class="btn btn-primary js_follow_btn">subscribe</a>
|
||||
</span>
|
||||
<div class="alert alert-success hidden">You have been subscribed!</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="messages_short">
|
||||
<ul class="media-list">
|
||||
<li t-foreach="messages" t-as="thread" class="media">
|
||||
<a t-attf-href="/groups/#{group.id}/message/#{ slug(thread) }?mode=#{mode}" class="pull-left">
|
||||
<img class="img-rounded pull-right mt0" style="height: 40px"
|
||||
t-att-src="'/website/image?model=mail.message&field=author_avatar&id='+str(thread.id)"/>
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading">
|
||||
<a t-attf-href="/groups/#{ slug(group) }/message/#{ slug(thread) }" 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>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue