• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_gravatar函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中userena.utils.get_gravatar函数的典型用法代码示例。如果您正苦于以下问题:Python get_gravatar函数的具体用法?Python get_gravatar怎么用?Python get_gravatar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_gravatar函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_gravatar

    def test_get_gravatar(self):
        template = '//www.gravatar.com/avatar/%(hash)s?s=%(size)s&d=%(type)s'

        # The hash for [email protected]
        hash = hashlib.md5('[email protected]').hexdigest()

        # Check the defaults.
        self.failUnlessEqual(get_gravatar('[email protected]'),
                             template % {'hash': hash,
                                         'size': 80,
                                         'type': 'identicon'})

        # Check different size
        self.failUnlessEqual(get_gravatar('[email protected]', size=200),
                             template % {'hash': hash,
                                         'size': 200,
                                         'type': 'identicon'})

        # Check different default
        http_404 = get_gravatar('[email protected]', default='404')
        self.failUnlessEqual(http_404,
                             template % {'hash': hash,
                                         'size': 80,
                                         'type': '404'})

        # Is it really a 404?
        response = self.client.get(http_404)
        self.failUnlessEqual(response.status_code, 404)
开发者ID:adamjberg,项目名称:finna-be-octo-ninja,代码行数:28,代码来源:utils.py


示例2: test_get_gravatar

    def test_get_gravatar(self):
        template = "http://www.gravatar.com/avatar/%(hash)s?s=%(size)s&d=%(type)s"

        # The hash for [email protected]
        hash = hashlib.md5("[email protected]").hexdigest()

        # Check the defaults.
        self.failUnlessEqual(
            get_gravatar("[email protected]"), template % {"hash": hash, "size": 80, "type": "identicon"}
        )

        # Check different size
        self.failUnlessEqual(
            get_gravatar("[email protected]", size=200), template % {"hash": hash, "size": 200, "type": "identicon"}
        )

        # Check different default
        http_404 = get_gravatar("[email protected]", default="404")
        self.failUnlessEqual(http_404, template % {"hash": hash, "size": 80, "type": "404"})

        # Is it really a 404?
        response = self.client.get(http_404)
        self.failUnlessEqual(response.status_code, 404)

        # Test the switch to HTTPS
        userena_settings.USERENA_MUGSHOT_GRAVATAR_SECURE = True

        template = "https://secure.gravatar.com/avatar/%(hash)s?s=%(size)s&d=%(type)s"
        self.failUnlessEqual(
            get_gravatar("[email protected]"), template % {"hash": hash, "size": 80, "type": "identicon"}
        )

        # And set back to default
        userena_settings.USERENA_MUGSHOT_GRAVATAR_SECURE = False
开发者ID:gobelins,项目名称:django-userena,代码行数:34,代码来源:utils.py


示例3: get_mugshot_url

    def get_mugshot_url(self):
        """
        Returns the image containing the mugshot for the user.

        The mugshot can be a uploaded image or a Gravatar.

        Gravatar functionality will only be used when
        ``USERENA_MUGSHOT_GRAVATAR`` is set to ``True``.

        :return:
            ``None`` when Gravatar is not used and no default image is supplied
            by ``USERENA_MUGSHOT_DEFAULT``.

        """
        # First check for a mugshot and if any return that.
        if self.mugshot:
            return self.mugshot.url

        # Use Gravatar if the user wants to.
        if userena_settings.USERENA_MUGSHOT_GRAVATAR:
            return get_gravatar(self.user.email,
                                userena_settings.USERENA_MUGSHOT_SIZE,
                                userena_settings.USERENA_MUGSHOT_DEFAULT)

        # Gravatar not used, check for a default image.
        else:
            if userena_settings.USERENA_MUGSHOT_DEFAULT not in ['404', 'mm',
                                                                'identicon',
                                                                'monsterid',
                                                                'wavatar']:
                return userena_settings.USERENA_MUGSHOT_DEFAULT
            else: return None
开发者ID:nuannuanwu,项目名称:weixiao,代码行数:32,代码来源:models.py


示例4: get_mugshot_url

 def get_mugshot_url(self, width=0):
     if self.image:
         url = self.image.url
     else:
         if width <= 0:
             width = userena_settings.USERENA_MUGSHOT_SIZE
         url = get_gravatar(self.user.email,
                            width,
                            userena_settings.USERENA_MUGSHOT_DEFAULT)
     return url
开发者ID:ksuralta,项目名称:phlist_rest,代码行数:10,代码来源:models.py


示例5: test_get_gravatar

    def test_get_gravatar(self):
        template = 'http://www.gravatar.com/avatar/%(hash)s?s=%(size)s&d=%(type)s'

        # The hash for [email protected]
        hash = hashlib.md5('[email protected]').hexdigest()

        # Check the defaults.
        self.failUnlessEqual(get_gravatar('[email protected]'),
                             template % {'hash': hash,
                                         'size': 80,
                                         'type': 'identicon'})

        # Check different size
        self.failUnlessEqual(get_gravatar('[email protected]', size=200),
                             template % {'hash': hash,
                                         'size': 200,
                                         'type': 'identicon'})

        # Check different default
        http_404 = get_gravatar('[email protected]', default='404')
        self.failUnlessEqual(http_404,
                             template % {'hash': hash,
                                         'size': 80,
                                         'type': '404'})

        # Is it really a 404?
        response = self.client.get(http_404)
        self.failUnlessEqual(response.status_code, 404)

        # Test the switch to HTTPS
        userena_settings.USERENA_MUGSHOT_GRAVATAR_SECURE = True

        template = 'https://secure.gravatar.com/avatar/%(hash)s?s=%(size)s&d=%(type)s'
        self.failUnlessEqual(get_gravatar('[email protected]'),
                             template % {'hash': hash,
                                         'size': 80,
                                         'type': 'identicon'})

        # And set back to default
        userena_settings.USERENA_MUGSHOT_GRAVATAR_SECURE = False
开发者ID:Abzhora,项目名称:django-userena,代码行数:40,代码来源:utils.py


示例6: test_get_gravatar

    def test_get_gravatar(self):
        template = 's=%(size)s&d=%(type)s'

        # Check the defaults.
        parsed = urlparse(get_gravatar('[email protected]'))
        self.failUnlessEqual(
            parse_qs(parsed.query),
            parse_qs(template % {'size': 80, 'type': 'identicon'})
        )

        # Check different size
        parsed = urlparse(get_gravatar('[email protected]', size=200))
        self.failUnlessEqual(
            parse_qs(parsed.query),
            parse_qs(template % {'size': 200, 'type': 'identicon'})
        )

        # Check different default
        parsed = urlparse(get_gravatar('[email protected]', default='404'))
        self.failUnlessEqual(
            parse_qs(parsed.query),
            parse_qs(template % {'size': 80, 'type': '404'})
        )
开发者ID:bagbirs,项目名称:django-userena,代码行数:23,代码来源:tests_utils.py


示例7: get_mugshot_url

    def get_mugshot_url(self, custom_size = userena_settings.USERENA_MUGSHOT_SIZE):
        """
        Returns the image containing the mugshot for the user.

        The mugshot can be a uploaded image or a Gravatar.

        Gravatar functionality will only be used when
        ``USERENA_MUGSHOT_GRAVATAR`` is set to ``True``.

        :return:
            ``None`` when Gravatar is not used and no default image is supplied
            by ``USERENA_MUGSHOT_DEFAULT``.

        """
        # First check for a mugshot and if any return that.
        if self.mugshot:
            return settings.MEDIA_URL +\
                   settings.MUGSHOTS_DIR +\
                   self.mugshot.name.split("/")[-1]

        # Use Gravatar if the user wants to.
        if userena_settings.USERENA_MUGSHOT_GRAVATAR:
            if userena_settings.USERENA_MUGSHOT_DEFAULT == 'blank-unitials-ssl':
                d = 'https://unitials.com/mugshot/%s/%s.png' % (
                    custom_size, self.get_initials()
                )
            elif userena_settings.USERENA_MUGSHOT_DEFAULT == 'blank-unitials':
                d = 'http://unitials.com/mugshot/%s/%s.png' % (
                    custom_size, self.get_initials()
                )
            return get_gravatar(self.user.email, custom_size, d)

        # Gravatar not used, check for a default image.
        else:
            if userena_settings.USERENA_MUGSHOT_DEFAULT not in ['404', 'mm',
                                                                'identicon',
                                                                'monsterid',
                                                                'wavatar',
                                                                'blank']:
                return userena_settings.USERENA_MUGSHOT_DEFAULT
            else: return None
开发者ID:FranciscoJRA,项目名称:agora-ciudadana,代码行数:41,代码来源:models.py


示例8: get_mugshot_url

 def get_mugshot_url(self):
     """
         (Basada en la funcion de userena)
         Devuelve la url donde esta la imagen que tenga seleccionada el usuario
         
         El usuario puede subir imagenes, usar gravatar, facebook o twitter
     """
     # First check for a mugshot and if any return that.
     if self.sync_avatar_with == 0 and self.mugshot:
         return self.mugshot.url
     elif self.sync_avatar_with == 1:
         return get_gravatar(self.user.email,
                             settings.USERENA_MUGSHOT_SIZE,
                             settings.USERENA_MUGSHOT_DEFAULT)
     elif self.sync_avatar_with == 2:
         facebook = FacebookProfile.objects.get(user=self.user)
         if facebook is not None:
             return facebook.get_avatar_url()
     elif self.sync_avatar_with == 3:
         twitter = TwitterProfile.objects.get(user=self.user)
         if twitter is not None:
             return twitter.get_avatar_url()
     return #settings.DEFAULT_AVATAR
开发者ID:GeoRemindMe,项目名称:GeoRemindMe_Platform,代码行数:23,代码来源:models.py


示例9: get_gravatar_mugshot

 def get_gravatar_mugshot(self, custom_size = userena_settings.USERENA_MUGSHOT_SIZE):
     d = self.get_initials_mugshot(custom_size)
     return get_gravatar(self.user.email, custom_size, d)
开发者ID:FranciscoJRA,项目名称:agora-ciudadana,代码行数:3,代码来源:__init__.py


示例10: get_avatar_url

 def get_avatar_url(self):
     if len(self.avatar.name) > 0:
         return os.path.join(settings.MEDIA_URL, self.avatar.name)
     else:
         from userena.utils import get_gravatar
         return get_gravatar(self.user.email, 200, 'monsterid')
开发者ID:dustinmm80,项目名称:zedtrip,代码行数:6,代码来源:models.py



注:本文中的userena.utils.get_gravatar函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_profile_model函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_datetime_now函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap