[IMP] Cleaning Archives
bzr revid: fp@tinyerp.com-20140316104022-fps64jlo8rpssf9m
This commit is contained in:
parent
633ceff7fc
commit
fb64b578e8
|
@ -1,2 +1 @@
|
|||
import controllers
|
||||
import models
|
||||
|
|
|
@ -4,15 +4,14 @@
|
|||
'summary': '',
|
||||
'version': '1.0',
|
||||
'description': """
|
||||
OpenERP Mail Group : Mailing List Archive
|
||||
==================
|
||||
OpenERP Mail Group : Mailing List Archives
|
||||
==========================================
|
||||
|
||||
""",
|
||||
'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',
|
||||
],
|
||||
|
|
|
@ -32,22 +32,14 @@ class MailGroup(http.Controller):
|
|||
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),
|
||||
}
|
||||
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)
|
||||
@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')
|
||||
public_uid = request.registry['website'].get_public_user(cr , uid, context)
|
||||
if uid == public_uid:
|
||||
return ['is_public']
|
||||
if action:
|
||||
group_obj.message_subscribe_users(cr, uid, [group_id], context=context)
|
||||
else:
|
||||
|
@ -55,41 +47,42 @@ class MailGroup(http.Controller):
|
|||
return []
|
||||
|
||||
@http.route([
|
||||
"/groups/<model('mail.group'):group>/",
|
||||
"/groups/<model('mail.group'):group>/page/<int:page>/"
|
||||
"/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, page=1, **post):
|
||||
def thread(self, group, mode='thread', 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, [])
|
||||
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/' % group.id,
|
||||
total=len(thread_ids),
|
||||
url='/groups/%s/%s' % (group.id, mode),
|
||||
total=thread_count,
|
||||
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]
|
||||
thread_ids = thread_obj.search(cr, uid, domain, limit=self._thread_per_page, offset=pager['offset'])
|
||||
|
||||
values = {
|
||||
'groups': group_obj.browse(cr, uid, group_ids, context),
|
||||
'thread_list': thread_obj.browse(cr, uid, thread_ids, context),
|
||||
'active_group': group,
|
||||
'messages': thread_obj.browse(cr, uid, thread_ids, context),
|
||||
'group': group,
|
||||
'pager': pager,
|
||||
'mode': mode
|
||||
}
|
||||
return request.website.render('website_mail_group.group_thread_list', values)
|
||||
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, **post):
|
||||
def get_thread(self, group, message, mode='thread', page=1, **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),
|
||||
'message': message,
|
||||
'group': group,
|
||||
'mode': mode,
|
||||
'page': page,
|
||||
}
|
||||
return request.website.render('website_mail_group.group_thread', values)
|
||||
return request.website.render('website_mail_group.group_message', values)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
import mail_group
|
|
@ -1,25 +0,0 @@
|
|||
# -*- 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
|
|
@ -6,7 +6,7 @@
|
|||
<li><a t-attf-href="/groups">Mailing List</a></li>
|
||||
</xpath>
|
||||
</template>
|
||||
<template id="mail_groups" name="My Groups">
|
||||
<template id="mail_groups" name="Mailing Lists">
|
||||
<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>
|
||||
|
@ -19,7 +19,7 @@
|
|||
<div class="col-md-3 mt32 mb64" 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>
|
||||
<a t-attf-href="/groups/#{group.id}" t-esc="group.name"/>
|
||||
<a t-attf-href="/groups/#{ slug(group) }/thread" t-esc="group.name"/>
|
||||
<div t-esc="group.description" class="text-muted"/>
|
||||
<a t-attf-class="btn btn-primary js_group #{group.message_is_follower and 'hidden' or 'visible'} follow_#{group.id}" t-attf-href="/groups/subscription/#{ group.id }/?action=subscribe" t-attf-id="#{group.id}">Join Group</a>
|
||||
<a t-attf-class="btn btn-default js_group #{group.message_is_follower and 'visible' or 'hidden'} unfollow_#{group.id}" t-attf-href="/groups/subscription/#{ group.id }/?action=unsubscribe" t-attf-id="#{group.id}">Unsubscribe</a>
|
||||
|
@ -30,81 +30,103 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<template id="group_thread_list">
|
||||
<template id="group_messages" name="Message Threads">
|
||||
<t t-call="website.layout">
|
||||
<section class="container">
|
||||
<div class="row">
|
||||
<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>
|
||||
</section>
|
||||
|
||||
<section class="container">
|
||||
<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_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/#{ slug(group) }" t-esc="group.name"/>
|
||||
</li>
|
||||
</t>
|
||||
<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">
|
||||
<ul class="media-list">
|
||||
<li t-foreach="thread_list" t-as="thread" class="media">
|
||||
<a t-attf-href="/groups/#{active_group.id}/message/#{ slug(thread) }" 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(active_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>
|
||||
<t t-call="website_mail_group.messages_short"/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="group_thread">
|
||||
<template id="group_message">
|
||||
<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&field=author_avatar&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&field=author_avatar&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 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 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="text-center mb32 mt32">
|
||||
<a t-attf-href="/groups/#{ slug(group) }/#{mode}/page/#{str(page)}" class="btn btn-lg btn-info">
|
||||
Back To List: <span t-field="group.name"/>
|
||||
</a>
|
||||
</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>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue