[ADD] suggested groups

bzr revid: mat@openerp.com-20130328161634-1fcmj0s67bofc6ra
This commit is contained in:
Martin Trigaux 2013-03-28 17:16:34 +01:00
parent 1ce5eaaff0
commit 5a112d8fa2
6 changed files with 98 additions and 4 deletions

View File

@ -87,10 +87,12 @@ Main Features
'static/src/js/mail.js',
'static/src/js/mail_followers.js',
'static/src/js/many2many_tags_email.js',
'static/src/js/suggestions.js',
],
'qweb': [
'static/src/xml/mail.xml',
'static/src/xml/mail_followers.xml',
'static/src/xml/suggestions.xml',
],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -24,6 +24,7 @@ import openerp.tools as tools
from openerp.osv import osv
from openerp.osv import fields
from openerp import SUPERUSER_ID
import operator
class mail_group(osv.Model):
@ -200,3 +201,30 @@ class mail_group(osv.Model):
""" Wrapper because message_unsubscribe_users take a user_ids=None
that receive the context without the wrapper. """
return self.message_unsubscribe_users(cr, uid, ids, context=context)
#------------------------------------------------------
# Thread suggestion
#------------------------------------------------------
def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None):
if context is None:
context = {}
own_messages = context.get("own_messages", False)
threads = []
message_obj = self.pool.get('mail.message')
if removed_suggested_threads is None:
removed_suggested_threads = []
if own_messages:
user_id = self.pool.get('res.users').browse(cr, uid, uid, context)
removed_suggested_threads.append(user_id.partner_id.id)
threads_ids = self.search(cr, uid, [('id', 'not in', removed_suggested_threads)], context=context)
for data in self.read(cr, uid, threads_ids, ['message_is_follower', 'message_ids', 'name', 'image_small'], context):
if not data['message_is_follower']:
if own_messages:
message_ids = message_obj.search(cr, uid, [('author_id', '=', data['id'])])
else:
message_ids = data['message_ids']
data['tweet'] = len(message_ids)
threads.append(data)
threads.sort(key=operator.itemgetter('tweet'), reverse=True)
return threads[0:3]

View File

@ -664,8 +664,71 @@
.openerp .oe_mail_wall .oe_mail{
margin: 16px;
width: 600px;
display: inline-block;
}
.openerp .oe_mail .oe_view_nocontent > p {
padding-left: 15px;
}
/* ------------- WALL SIDEBAR ------------- */
.openerp .oe_mail_wall .oe_mail_wall_aside {
margin-left: 20px;
margin-top: 20px;
position: relative;
display: inline-block;
vertical-align: top;
width: 300px;
}
.openerp .oe_mail_wall_aside > div {
background-color: #EDEDF6;
border-radius: 2px;
padding: 10px;
}
.openerp .oe_mail_wall_aside .oe_user_display {
font-size: 14px;
font-weight: bold;
margin-left: 10px;
color: #7C7BAD;
}
.openerp .oe_mail_wall_aside .oe_suggested_groups {
border-radius: 2px;
width: 100%;
margin-left: 10px;
height: 90px;
}
.openerp .oe_mail_wall_aside .oe_group_images {
width: 20%;
float: left;
padding-right: 20px;
}
.openerp .oe_mail_wall_aside .oe_group_image_content {
border-radius: 2px;
border: solid 1px rgba(0,0,0,0.03);
}
.openerp .oe_mail_wall_aside .oe_join_group {
margin-top: 10px;
}
.openerp .oe_mail_wall_aside .oe_follow_people {
margin-top: 10px;
}
.openerp .oe_mail_wall_aside .oe_remove_suggested_group {
visibility:hidden;
width:3%;
float:right;
margin-right:20px;
}
.openerp .oe_mail_wall_aside .oe_suggested_groups:hover .oe_remove_suggested_group > span {
visibility: visible;
}
.openerp .oe_mail_wall_aside .oe_suggest_groups .oe_group {
width: 80%;
}
.openerp .oe_mail_wall_aside .oe_suggest_groups .oe_group .oe_group_name {
text-overflow: ellipsis;
overflow: hidden;
width: 90%;
}

View File

@ -6,6 +6,7 @@ openerp.mail = function (session) {
openerp_mail_followers(session, mail); // import mail_followers.js
openerp_FieldMany2ManyTagsEmail(session); // import manyy2many_tags_email.js
/**
* ------------------------------------------------------------
@ -1991,4 +1992,6 @@ openerp.mail = function (session) {
});
},
});
openerp.mail.suggestions(session, mail);
};

View File

@ -3,7 +3,7 @@ openerp_mail_followers = function(session, mail) {
_lt = session.web._lt;
var mail_followers = session.mail_followers = {};
/**
* ------------------------------------------------------------
* mail_followers Widget

View File

@ -195,6 +195,7 @@
</tbody>
</table>
<div class="oe_mail-placeholder"></div>
<aside class="oe_mail_wall_aside"></aside>
</div>
<!--
@ -320,7 +321,4 @@
</a>
</span>
<!-- mail.thread.message.star
Template used to display stared/unstared message in a mail.message
-->
</template>