Exemplo n.º 1
0
    def profile_picture(self, default_icon='identicon'):
        if self.image:
            try:
                return settings.MEDIA_URL + getattr(
                    self.image, 'thumbnail_colorspace_80x80smartcrop')
            except:
                self.image = None
                self.save()

        key = "profile_picture_%s" % self.user.id
        cache_hit = cache.get(key)
        if cache_hit:
            return cache_hit
        else:
            try:
                profile_picture = facebook_profile(self.user, "square")
            except:
                profile_picture = None

            if not profile_picture:
                profile_picture = 'http://www.gravatar.com/avatar/%s?r=g&d=%s&s=52' % (self._email_hash(), default_icon)

            # Cache the profile picture url for 6 hours
            cache.set(key, profile_picture, 60 * 60 * 6)
            return profile_picture
Exemplo n.º 2
0
    def profile_picture_large(self, default_icon='identicon'):
        if self.image:
            return settings.MEDIA_URL + getattr(
                self.image, 'thumbnail_colorspace_160x160smartcrop')

        facebook_picture = facebook_profile(self.user, "large")
        if facebook_picture:
            return facebook_picture
        return 'http://www.gravatar.com/avatar/%s?r=g&d=%s&s=200' % (self._email_hash(), default_icon)
    def profile_picture(self, default_icon='identicon'):
        key = "profile_picture_%s" % self.user.id
        cache_hit = cache.get(key)
        if cache_hit:
            return cache_hit
        else:
            try:
                profile_picture = facebook_profile(self.user, "square")
            except:
                pass

            if not profile_picture:
                profile_picture = 'http://www.gravatar.com/avatar/%s?r=g&d=%s&s=52' % (self._email_hash(), default_icon)

            # Cache the profile picture url for 6 hours
            cache.set(key, profile_picture, 60 * 60 * 6)
            return profile_picture
    def profile_picture(self, default_icon='identicon'):
        key = "profile_picture_%s" % self.user.id
        cache_hit = cache.get(key)
        if cache_hit:
            return cache_hit
        else:
            try:
                profile_picture = facebook_profile(self.user, "square")
            except:
                pass

            if not profile_picture:
                profile_picture = 'http://www.gravatar.com/avatar/%s?r=g&d=%s&s=52' % (
                    self._email_hash(), default_icon)

            # Cache the profile picture url for 6 hours
            cache.set(key, profile_picture, 60 * 60 * 6)
            return profile_picture
 def profile_picture_large(self, default_icon='identicon'):
     facebook_picture = facebook_profile(self.user, "large")
     if facebook_picture:
         return facebook_picture
     return 'http://www.gravatar.com/avatar/%s?r=g&d=%s&s=200' % (self._email_hash(), default_icon)
 def profile_picture_large(self, default_icon='identicon'):
     facebook_picture = facebook_profile(self.user, "large")
     if facebook_picture:
         return facebook_picture
     return 'http://www.gravatar.com/avatar/%s?r=g&d=%s&s=200' % (
         self._email_hash(), default_icon)