Bharat Devnani (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-mail-extra-vote-feature-bde
 into lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp.

Requested reviews:
  OpenERP R&D Team (openerp-dev)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-mail-extra-vote-feature-bde/+merge/109110

Hello Sir, 

I have improved the functionality for voting, once the user likes p
articular message, it displays the like status accordingly. And also 
set the title on Checklist image.

Thanks & Regards,
Devnani Bharat R.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-mail-extra-vote-feature-bde/+merge/109110
Your team OpenERP R&D Team is requested to review the proposed merge of 
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-mail-extra-vote-feature-bde
 into lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp.
=== modified file 'mail_extra/mail_vote.py'
--- mail_extra/mail_vote.py	2012-06-06 13:41:48 +0000
+++ mail_extra/mail_vote.py	2012-06-07 11:30:26 +0000
@@ -33,8 +33,22 @@
 
 class mail_message(osv.osv):
     _inherit = 'mail.message'
+
+    def get_vote_status(self, cr, uid, ids, name, args, context=None):
+        mail_vote_obj = self.pool.get('mail.vote')
+        res = {}
+        for id in ids: 
+            record = mail_vote_obj.search(cr, uid, [('msg_id', '=',id),('user_id', '=', uid)], context=context)
+            if record:
+                state = True
+            else:
+                state = False
+            res[id] = state
+        return res
+    
     _columns= {
            'vote_ids': fields.one2many('mail.vote', 'msg_id', 'Votes'),
+           'vote_status': fields.function(get_vote_status, string='Paid/Reconciled', type='boolean'),
        }
     
     def vote_subscribe(self, cr, uid, message_id, context=None):
@@ -43,7 +57,8 @@
         voters_id = vote_pool.search(cr, uid, [('msg_id', '=', message_id), ('user_id', '=', uid)], context=context)
         if not voters_id:
             new_vote_id =  vote_pool.create(cr, uid, {'msg_id': message_id, 'user_id': uid}, context=context)
-        message = self.browse(cr, uid, message_id, context)   
+        message = self.browse(cr, uid, message_id, context)  
+        vote_status = message.vote_status 
         if message.vote_ids:
-            vote_count = len(message.vote_ids)    
-        return vote_count
+            vote_count = len(message.vote_ids) 
+        return {'vote_count': vote_count, 'vote_status': vote_status}

=== modified file 'mail_extra/static/src/css/mail_extra.css'
--- mail_extra/static/src/css/mail_extra.css	2012-05-30 07:00:27 +0000
+++ mail_extra/static/src/css/mail_extra.css	2012-06-07 11:30:26 +0000
@@ -4,12 +4,14 @@
     height: 18px;
     margin: -5px;
     position: relative;
+    bottom: -3px;
 }
 
 span.oe_mail_vote_span
 {
     position: relative;
-    margin: 2%;
+    left: 10px;
+    bottom: -5px;
 }
 
 .openerp div.oe_mail_thread_subthread img 
@@ -46,5 +48,23 @@
 	background-color:white;
 	width:220px;
 	height:4px;
-	
+}
+
+label.oe_mail_vote_like {
+    padding: 20px;
+    cursor: pointer;
+    color: #8786B7;
+    position: relative;
+    bottom: -4px;
+}
+
+label.oe_mail_vote_like:hover{
+    text-decoration:underline;
+}
+
+label.oe_mail_vote_liked {
+    padding: 20px;
+    position: relative;
+    color: #8786B7;
+    bottom: -5px;
 }
\ No newline at end of file

=== modified file 'mail_extra/static/src/js/mail_extra.js'
--- mail_extra/static/src/js/mail_extra.js	2012-06-06 13:41:48 +0000
+++ mail_extra/static/src/js/mail_extra.js	2012-06-07 11:30:26 +0000
@@ -26,14 +26,13 @@
              });
         },
         add_vote_event: function(element){
-            vote_img = element.find('img.oe_mail_vote_image');
-            self = this;
-            if (vote_img)
-                vote_img.click(function(){
-                	self.subscribe_vote($(this).attr('data-id'));
+            var self = this;
+            vote_action = element.find('.oe_mail_vote_like');
+            if (vote_action)
+                vote_action.click(function(){
+                    self.subscribe_vote($(this).attr('data-id'));
                 });
             return
-                
         },
         init_comments: function(){
             res = this._super();
@@ -44,23 +43,23 @@
             });
         },
         do_render_vote: function(message_id, result){
-        	vote_msg = $(".oe_mail_msg_vote");
-        	self = this;
-        	if (vote_msg)
-        		vote_msg.each(function(){
-        			if($(this).attr('data-id')==message_id){
-        				$(this).replaceWith(QWeb.render('VoteDisplay', {'msg_id':message_id, 'vote_count': result}));
-        				self.add_vote_event($(this));
-        			}
-        		});
+            vote_msg = $(".oe_mail_msg_vote");
+            self = this;
+            if (vote_msg)
+                vote_msg.each(function(){
+                    if($(this).attr('data-id')==message_id){
+                        $(this).replaceWith(QWeb.render('VoteDisplay', {'msg_id':message_id, 'vote_count': result.vote_count, 'vote_status': result.vote_status}));
+                        self.add_vote_event($(this));
+                    }
+                });
         },
         
         subscribe_vote: function(message_id){
             var self = this;
             this.mail_message = new session.web.DataSet(this, 'mail.message');
             return this.mail_message.call('vote_subscribe', [parseInt(message_id)]).then(function(result){
-                    	self.do_render_vote(message_id, result);
-                  });
+                self.do_render_vote(message_id, result);
+            });
         },
         do_display_checklist: function (cur_msg_id,render_to) {
          	var self=this;

=== modified file 'mail_extra/static/src/xml/mail_extra.xml'
--- mail_extra/static/src/xml/mail_extra.xml	2012-06-06 13:41:48 +0000
+++ mail_extra/static/src/xml/mail_extra.xml	2012-06-07 11:30:26 +0000
@@ -6,19 +6,33 @@
         <t t-jquery=".oe_mail_msg_content" t-operation="append">
             <t t-if="record.type == 'comment'">
             	<span t-att-data-id="record.id" class="oe_mail_msg_vote"><t t-call="VoteDisplay"> 
-            	       <t t-set="vote_count" t-value="record.vote_ids.length"/>
-            	       <t t-set="msg_id" t-value="record.id"/>
-            	</t></span>
-            	<img class="oe_checklist_image"  src="/web/static/src/img/icons/gtk-index.png"></img>
+                    <t t-set="vote_count" t-value="record.vote_ids.length"/>
+                    <t t-set="msg_id" t-value="record.id"/>
+                    <t t-set="vote_status" t-value="record.vote_status"/>
+                </t></span>
+                <img class="oe_checklist_image" src="/web/static/src/img/icons/gtk-index.png" title="Add checklist on particular message"></img>
             </t>
         </t>
     </t>
     
     <t t-name="VoteDisplay">
-        <img src="/mail_extra/static/src/img/vote.png" t-att-data-id="msg_id" class="oe_mail_vote_image"></img>
-        <t t-if='vote_count'>
+        
+        <t t-if='(vote_status)'>
+            <img src="/mail_extra/static/src/img/vote.png" class="oe_mail_vote_image"></img>
             <span class="oe_mail_vote_span"><t t-esc="vote_count"/></span>
-        </t>
+            <label t-attf-data-id='msg_id' class="oe_mail_vote_liked">Liked</label>
+            <label t-attf-data-id='msg_id' class="oe_mail_vote_like" style="display:None;">Like</label>
+        </t>
+        
+        <t t-if='(!vote_status)'>
+            <t t-if='vote_count'>
+                <img src="/mail_extra/static/src/img/vote.png" class="oe_mail_vote_image"></img>
+                <span class="oe_mail_vote_span"><t t-esc="vote_count"/></span>
+            </t>
+            <label t-att-data-id="msg_id" class="oe_mail_vote_like">Like</label>
+            <label t-attf-data-id="msg_id" class="oe_mail_vote_liked" style="display:None;">Liked</label>
+        </t>
+        
     </t>
     
 	<t t-extend="NoteDisplay">

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to