def _user_dict(user):
    out = model_dictize.user_dictize(user, context={'model': model})
    out['ckan_url'] = h.url_for('user.read', id=user.name)
    out['gravatar'] = h.gravatar(user.email_hash, size=48)
    out['gravatar_url'] = '''//gravatar.com/avatar/%s?s=%d''' % (
        user.email_hash, 48)
    return out
Exemple #2
0
def test_gravatar():
    email = "*****@*****.**"
    expected = '<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=mm"'

    email_hash = hashlib.md5(six.ensure_binary(email)).hexdigest()
    res = h.gravatar(email_hash, 200, default="mm")
    assert expected in res
Exemple #3
0
 def test_gravatar_config_set_default(self):
     """Test when default gravatar is None, it is pulled from the config file"""
     email = "*****@*****.**"
     default = config.get("ckan.gravatar_default", "identicon")
     expected = '<img src="//gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&amp;d=%s"' % default
     email_hash = hashlib.md5(six.ensure_binary(email)).hexdigest()
     res = h.gravatar(email_hash, 200)
     assert expected in res
Exemple #4
0
def show_linked_user(user, maxlength=0, avatar=20):
    if not isinstance(user, model.User):
        user_name = text_type(user)
        user = model.User.get(user_name)
        if not user:
            return user_name
    if user:
        name = user.name if model.User.VALID_NAME.match(user.name) else user.id
        displayname = user.display_name

        if maxlength and len(user.display_name) > maxlength:
            displayname = displayname[:maxlength] + '...'

        return tags.literal(u'{icon} {link}'.format(
            icon=h.gravatar(
                email_hash=user.email_hash,
                size=avatar
            ),
            link=tags.link_to(
                displayname,
                ('/user/show/' + name)
            )
        ))
Exemple #5
0
def _user_dict(user):
    out = user.as_dict()
    out['ckan_url'] = h.url_for('user_datasets', id=user.name)
    out['gravatar'] = h.gravatar(user.email_hash, size=48)
    return out
def _user_dict(user):
    out = model_dictize.user_dictize(user, context={'model': model})
    out['ckan_url'] = h.url_for('user_datasets', id=user.name)
    out['gravatar'] = h.gravatar(user.email_hash, size=48)
    out['gravatar_url'] = '''//gravatar.com/avatar/%s?s=%d''' % (user.email_hash, 48)
    return out
def custom_gravatar(*pargs, **kargs):
    gravatar = h.gravatar(*pargs, **kargs)
    pos = gravatar.find('/>')
    gravatar = gravatar[:pos] + literal(' alt="User\'s profile gravatar" ') +\
        gravatar[pos:]
    return gravatar
def custom_gravatar(*pargs, **kargs):
    gravatar = h.gravatar(*pargs, **kargs)
    pos = gravatar.find('/>')
    gravatar = gravatar[:pos] + literal(' alt="User\'s profile gravatar" ') + gravatar[pos:]
    return gravatar
def _user_dict(user):
    out = user.as_dict()
    out['ckan_url'] = h.url_for('user_datasets', id=user.name)
    out['gravatar'] = h.gravatar(user.email_hash, size=48)
    return out