コード例 #1
0
ファイル: __init__.py プロジェクト: keitaroinc/ckanext-issues
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
コード例 #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
コード例 #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
コード例 #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)
            )
        ))
コード例 #5
0
ファイル: model.py プロジェクト: derilinx/ckanext-issues
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
コード例 #6
0
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
コード例 #7
0
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
コード例 #8
0
ファイル: plugin.py プロジェクト: datagovau/ckanext-ga-report
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
コード例 #9
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