ajay javiya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-user-profile-tpa-suggest-people-aja 
into lp:~openerp-dev/openobject-addons/trunk-user-profile-tpa.

Requested reviews:
  Turkesh Patel (openERP) (turkesh-tinyerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-user-profile-tpa-suggest-people-aja/+merge/145789

Hello,
Add 
-> suggested people with more tweet on user wall.
-> Allow a user to follow them.
Thank You.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-user-profile-tpa-suggest-people-aja/+merge/145789
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-user-profile-tpa.
=== modified file 'user_profile/static/src/css/user_profile.css'
--- user_profile/static/src/css/user_profile.css	2013-01-31 08:55:24 +0000
+++ user_profile/static/src/css/user_profile.css	2013-01-31 09:11:42 +0000
@@ -6,7 +6,7 @@
      height:auto;
      position: relative;
 }
-.openerp .oe_user_profile_detail,.oe_user_profile_group
+.openerp .oe_user_profile_detail,.oe_user_profile_group ,.oe_user_profile_people
 {
     background: #EDEDF6;
     height:auto;
@@ -23,26 +23,25 @@
      margin-left:10px;
      margin-top:4px;
 }
-.openerp .oe_suggested_groups{
+.openerp .oe_suggested_groups ,.oe_suggested_peoples {
     border-radius: 2px;
     margin-top:1px;
     width:100%;
     margin-left:10px;
     height:100px;
 }
-.openerp .oe_group_images{
+.openerp .oe_group_images ,.oe_people_images {
     width:30%;
     float:left;
 }
-.openerp .oe_group_image_content{
+.openerp .oe_group_image_content ,.oe_people_image_content{
     border-radius: 2px;
     border: solid 1px rgba(0,0,0,0.03);
 }
-.openerp .oe_group_content{
+.openerp .oe_group_content ,.oe_people_content {
     width:70%;
     float:right;
 }
-.openerp .oe_join_group
-{
+.openerp .oe_join_group ,.oe_follow_people {
     margin-top:10px;
 }

=== modified file 'user_profile/static/src/js/user_profile.js'
--- user_profile/static/src/js/user_profile.js	2013-01-31 08:55:24 +0000
+++ user_profile/static/src/js/user_profile.js	2013-01-31 09:11:42 +0000
@@ -11,14 +11,17 @@
             this.ds_todo = new session.web.DataSetSearch(this, 'ir.profile.todo');
             this.ds_mailgroup = new session.web.DataSetSearch(this, 'mail.group');
             this.res_user = new session.web.DataSetSearch(this, 'res.users');
+            this.ds_partner = new session.web.DataSetSearch(this, 'res.partner');
             this.get_user_info();
             this.get_suggested_group();
+            this.get_suggested_people();
             this.group = {};
         },
         bind_events: function() {
             var self = this;
             this.$('.oe_add_link').on('click', 'a', { uid: this.session.uid}, self.open_user_profile_view);
-            this.$el.on('click','button',{ uid: this.session.uid}, self.join_group);
+            this.$('.oe_suggest_groups').on('click','button',{ uid: this.session.uid,data:this}, self.join_group);
+            this.$('.oe_suggest_peoples').on('click','button',{ uid: this.session.uid,data:this}, self.follow_peoples);
         },
         get_user_info: function() {
             var self = this;
@@ -55,9 +58,8 @@
             });
         },
         join_group:function(event){
-            this.ds_mailgroup = new session.web.DataSetSearch(this, 'mail.group');
             var self= this;
-            return this.ds_mailgroup.call('search',[[ ['id','=',$(this).attr('id')] ]]).then(function(res){
+            return event.data.data.ds_mailgroup.call('search',[[ ['id','=',$(this).attr('id')] ]]).then(function(res){
                 self.ds_mailgroup.call('message_subscribe_users', [res,[event.data.uid]]);
             }).then(function(){
                 location.reload();
@@ -87,6 +89,37 @@
                 location.reload();
             });
             return false;
-        }
+        },
+        get_suggested_people: function() {
+            var self = this;
+            var show = 0;
+            var user_company='';
+            self.res_user.call('read',[self.session.uid]).then(function(company){
+                user_company=company.company_id;
+                return;
+            });
+            return self.ds_partner.read_slice([]).then(function(res){
+                _.chain(res)
+                .sortBy(function(result){return _.size(result.message_ids); }).reverse()
+                .filter(function(result){
+                    return  result.company_id[0] == user_company[0] && !result.message_is_follower;
+                })
+                .map(function(result){
+                  if(show>2) return;
+                  show+=1;
+                  //TODO: Store value in to widget and display using xml better then append.
+                  self.$('.oe_suggest_peoples').append('<div class="oe_suggested_peoples"><div class="oe_people_images"><img src="'+self.session.url('/web/binary/image', {model: 'res.partner', field: 'image_small', id:result.id, resize: ''})+'" class="oe_people_image_content"/></div><div class="oe_people_content"><a>'+result.name+'</a></br><button type="button" id="'+result.id+'" class="oe_follow_people">Follow</button></div></div>')
+                });
+                if(show<=0) self.$(".oe_user_profile_people").hide();
+            });
+        },
+        follow_peoples: function(event){
+            var self= this;
+            return event.data.data.ds_partner.call('search',[[ ['id','=',$(this).attr('id')] ]]).then(function(res){
+                self.ds_partner.call('message_subscribe_users', [res,[event.data.uid]]);
+            }).then(function(){
+                location.reload();
+            });
+        },
     });
 }

=== modified file 'user_profile/static/src/xml/user_profile.xml'
--- user_profile/static/src/xml/user_profile.xml	2013-01-30 10:18:53 +0000
+++ user_profile/static/src/xml/user_profile.xml	2013-01-31 09:11:42 +0000
@@ -12,6 +12,10 @@
                     <p class="oe_user_display">Suggested Groups</p>
                     <div class="oe_suggest_groups"/>
                 </div>
+                <div class="oe_user_profile_people">
+                    <p class="oe_user_display">Suggested People</p>
+                    <div class="oe_suggest_peoples"/>
+                </div>
             </div>
         </t>
     </t>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to