Changeset 1560 in products


Ignore:
Timestamp:
Jan 15, 2010 7:48:36 AM (11 years ago)
Author:
mylan
Message:

Update commentor's photo logic - 1st - get member's photo if no - from gravatar service, if no - return default plone member photo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonecomments/trunk/quintagroup/plonecomments/browser/comments.py

    r1201 r1560  
    3636    def getGravatar(self, reply): 
    3737        purl = getToolByName(self.context, 'portal_url') 
    38         default = purl() + '/defaultUser.gif'  
     38        mtool = getToolByName(self.context, 'portal_membership')             
     39        portrait_url = purl() + '/defaultUser.gif'  
    3940        email = '' 
    4041 
     
    4445            member = mtool.getMemberById(creator) 
    4546            email = member and member.getProperty('email','') or '' 
     47            mem_id = getattr(member,'getId',lambda:'Anonymous User')() 
     48            portrait = mtool.getPersonalPortrait(mem_id) 
     49            portrait_url =  portrait.absolute_url() 
    4650        else: 
    4751            email = reply.getProperty('email',d='') 
    48         if not email: 
    49             return default 
     52 
     53        if not email or not 'defaultUser.gif' in portrait_url: 
     54            return portrait_url 
    5055 
    5156        size = 40 
    5257        gravatar_url = "http://www.gravatar.com/avatar.php?" 
    5358        # construct the url 
    54         gravatar_url += urllib.urlencode({'gravatar_id':md5.md5(email).hexdigest(),  
    55             'default':default, 'size':str(size)}) 
    56  
     59        gravatar_url += urllib.urlencode({'gravatar_id':md5.md5(email).hexdigest(), 
     60            'default':portrait_url, 'size':str(size)}) 
    5761        return gravatar_url 
     62         
    5863 
    5964    def authenticated_report_abuse_enabled(self): 
Note: See TracChangeset for help on using the changeset viewer.