本文整理汇总了Python中sentry.utils.avatar.get_gravatar_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_gravatar_url函数的具体用法?Python get_gravatar_url怎么用?Python get_gravatar_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_gravatar_url函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_activity
def render_activity(item):
if not item.group:
# not implemented
return
action_str = ACTIVITY_ACTION_STRINGS[item.type]
if item.type == Activity.CREATE_ISSUE:
action_str = action_str.format(**item.data)
output = ''
if item.user:
user = item.user
name = user.first_name or user.email
output += '<span class="avatar"><img src="%s"></span> ' % (get_gravatar_url(user.email, size=20),)
output += '<strong>%s</strong> %s' % (escape(name), action_str)
else:
output += '<span class="avatar sentry"></span> '
output += 'The system %s' % (action_str,)
output += ' <span class="sep">—</span> <span class="time">%s</span>' % (timesince(item.datetime),)
if item.type == Activity.NOTE:
output += linebreaks(urlize(escape(item.data['text'])))
return mark_safe(output)
示例2: serialize
def serialize(self, obj, attrs, user):
d = {
'id': str(obj.id),
'name': obj.get_display_name(),
'username': obj.username,
'email': obj.email,
'avatarUrl': get_gravatar_url(obj.email, size=32),
}
if obj == user:
options = {
o.key: o.value
for o in UserOption.objects.filter(
user=user,
project__isnull=True,
)
}
stacktrace_order = int(options.get('stacktrace_order', -1) or -1)
if stacktrace_order == -1:
stacktrace_order = 'default'
elif stacktrace_order == 2:
stacktrace_order = 'newestFirst'
elif stacktrace_order == 1:
stacktrace_order = 'newestLast'
d['options'] = {
'language': options.get('language') or 'en',
'stacktraceOrder': stacktrace_order,
'timezone': options.get('timezone') or settings.SENTRY_DEFAULT_TIME_ZONE,
'clock24Hours': options.get('clock_24_hours') or False,
}
return d
示例3: serialize
def serialize(self, obj, attrs, user):
d = {
'id': str(obj.id),
'name': obj.get_display_name(),
'username': obj.username,
'email': obj.email,
'avatarUrl': get_gravatar_url(obj.email, size=32),
'isActive': obj.is_active,
'isManaged': obj.is_managed,
'dateJoined': obj.date_joined,
'has2fa': attrs['has2fa'],
}
if obj == user:
options = {
o.key: o.value
for o in UserOption.objects.filter(
user=user,
project__isnull=True,
)
}
stacktrace_order = int(options.get('stacktrace_order', -1) or -1)
if stacktrace_order == -1:
stacktrace_order = 'default'
elif stacktrace_order == 2:
stacktrace_order = 'newestFirst'
elif stacktrace_order == 1:
stacktrace_order = 'newestLast'
d['options'] = {
'language': options.get('language') or 'en',
'stacktraceOrder': stacktrace_order,
'timezone': options.get('timezone') or settings.SENTRY_DEFAULT_TIME_ZONE,
'clock24Hours': options.get('clock_24_hours') or False,
}
if attrs.get('avatar'):
avatar = {
'avatarType': attrs['avatar'].get_avatar_type_display(),
'avatarUuid': attrs['avatar'].ident if attrs['avatar'].file else None
}
else:
avatar = {'avatarType': 'letter_avatar', 'avatarUuid': None}
d['avatar'] = avatar
if attrs['identities'] is not None:
d['identities'] = [{
'id': i.ident,
'organization': {
'slug': i.auth_provider.organization.slug,
'name': i.auth_provider.organization.name,
},
'provider': {
'id': i.auth_provider.provider,
'name': i.auth_provider.get_provider().name,
},
'dateSynced': i.last_synced,
'dateVerified': i.last_verified,
} for i in attrs['identities']]
return d
示例4: serialize
def serialize(self, obj, attrs, user):
d = {
'id': str(obj.id),
'name': obj.get_full_name(),
'email': obj.email,
'avatarUrl': get_gravatar_url(obj.email, size=32),
}
return d
示例5: serialize
def serialize(self, obj, attrs, user):
return {
'id': str(obj.id),
'identifier': obj.ident,
'username': obj.username,
'email': obj.email,
'ipAddress': obj.ip_address,
'avatarUrl': get_gravatar_url(obj.email, size=32),
}
示例6: serialize
def serialize(self, obj, attrs, user):
d = {
'id': str(obj.id),
'email': obj.email or obj.user.email,
'access': obj.get_type_display(),
'pending': obj.is_pending,
'dateCreated': obj.date_added,
'avatarUrl': get_gravatar_url(obj.email, size=32),
}
return d
示例7: serialize
def serialize(self, obj, attrs, user):
return {
'id': six.text_type(obj.id),
'hash': obj.hash,
'tagValue': obj.tag_value,
'identifier': obj.ident,
'username': obj.username,
'email': obj.email,
'name': obj.get_display_name(),
'ipAddress': obj.ip_address,
'dateCreated': obj.date_added,
'avatarUrl': get_gravatar_url(obj.email, size=32),
}
示例8: serialize
def serialize(self, obj, attrs, user):
d = {
'id': str(obj.id),
'name': obj.get_display_name(),
'username': obj.username,
'email': obj.email,
'avatarUrl': get_gravatar_url(obj.email, size=32),
'isActive': obj.is_active,
'dateJoined': obj.date_joined,
}
if obj == user:
options = {
o.key: o.value
for o in UserOption.objects.filter(
user=user,
project__isnull=True,
)
}
stacktrace_order = int(options.get('stacktrace_order', -1) or -1)
if stacktrace_order == -1:
stacktrace_order = 'default'
elif stacktrace_order == 2:
stacktrace_order = 'newestFirst'
elif stacktrace_order == 1:
stacktrace_order = 'newestLast'
d['options'] = {
'language': options.get('language') or 'en',
'stacktraceOrder': stacktrace_order,
'timezone': options.get('timezone') or settings.SENTRY_DEFAULT_TIME_ZONE,
'clock24Hours': options.get('clock_24_hours') or False,
}
if attrs.get('avatar'):
avatar = {
'avatarType': attrs['avatar'].get_avatar_type_display(),
'avatarUuid': attrs['avatar'].ident if attrs['avatar'].file else None
}
else:
avatar = {'avatarType': 'letter_avatar', 'avatarUuid': None}
d['avatar'] = avatar
return d
示例9: render_activity
def render_activity(item):
if not item.group:
# not implemented
return
try:
action_str = ACTIVITY_ACTION_STRINGS[item.type]
except KeyError:
logging.warning('Unknown activity type present: %s', item.type)
return
if item.type == Activity.CREATE_ISSUE:
action_str = action_str.format(**item.data)
elif item.type == Activity.ASSIGNED:
if item.data['assignee'] == item.user_id:
assignee_name = 'themselves'
else:
try:
assignee = User.objects.get(id=item.data['assignee'])
except User.DoesNotExist:
assignee_name = 'unknown'
else:
assignee_name = assignee.get_display_name()
action_str = action_str.format(user=assignee_name)
output = ''
if item.user:
user = item.user
name = user.first_name or user.email
output += '<span class="avatar"><img src="%s"></span> ' % (get_gravatar_url(user.email, size=20),)
output += '<strong>%s</strong> %s' % (escape(name), action_str)
else:
output += '<span class="avatar sentry"></span> '
output += 'The system %s' % (action_str,)
output += ' <span class="sep">—</span> <span class="time">%s</span>' % (timesince(item.datetime),)
if item.type == Activity.NOTE:
output += linebreaks(urlize(escape(item.data['text'])))
return mark_safe(output)
示例10: render_activity
def render_activity(item):
if not item.group:
# not implemented
return
action_str = ACTIVITY_ACTION_STRINGS[item.type]
output = ""
if item.user:
user = item.user
name = user.first_name or user.email
output += '<span class="avatar"><img src="%s"></span> ' % (get_gravatar_url(user.email, size=20),)
output += "<strong>%s</strong> %s" % (escape(name), action_str)
else:
output += '<span class="avatar sentry"></span> '
output += "The system %s" % (action_str,)
output += ' <span class="sep">—</span> <span class="time">%s</span>' % (timesince(item.datetime),)
if item.type == Activity.COMMENT:
output += linebreaks(item.data["body"])
return mark_safe(output)
示例11: gravatar_url
def gravatar_url(context, email, size=None, default='mm'):
return get_gravatar_url(email, size, default)
示例12: serialize
def serialize(self, obj, attrs, user):
d = {
'id': six.text_type(obj.id),
'name': obj.get_display_name(),
'username': obj.username,
'email': obj.email,
'avatarUrl': get_gravatar_url(obj.email, size=32),
'isActive': obj.is_active,
'hasPasswordAuth': obj.password not in ('!', ''),
'isManaged': obj.is_managed,
'dateJoined': obj.date_joined,
'lastLogin': obj.last_login,
'has2fa': attrs['has2fa'],
'lastActive': obj.last_active,
}
if obj == user:
options = {
o.key: o.value for o in UserOption.objects.filter(
user=user,
project__isnull=True,
)
}
stacktrace_order = int(options.get('stacktrace_order', -1) or -1)
d['options'] = {
'language': options.get('language') or 'en',
'stacktraceOrder': stacktrace_order,
'timezone': options.get('timezone') or settings.SENTRY_DEFAULT_TIME_ZONE,
'clock24Hours': options.get('clock_24_hours') or False,
'seenReleaseBroadcast': options.get('seen_release_broadcast'),
}
d['permissions'] = list(UserPermission.for_user(obj.id))
d['flags'] = {
'newsletter_consent_prompt': bool(obj.flags.newsletter_consent_prompt),
}
if attrs.get('avatar'):
avatar = {
'avatarType': attrs['avatar'].get_avatar_type_display(),
'avatarUuid': attrs['avatar'].ident if attrs['avatar'].file_id else None
}
else:
avatar = {'avatarType': 'letter_avatar', 'avatarUuid': None}
d['avatar'] = avatar
if attrs['identities'] is not None:
d['identities'] = [
{
'id': six.text_type(i.id),
'name': i.ident,
'organization': {
'slug': i.auth_provider.organization.slug,
'name': i.auth_provider.organization.name,
},
'provider': {
'id': i.auth_provider.provider,
'name': i.auth_provider.get_provider().name,
},
'dateSynced': i.last_synced,
'dateVerified': i.last_verified,
} for i in attrs['identities']
]
d['emails'] = [
{
'id': six.text_type(e.id),
'email': e.email,
'is_verified': e.is_verified,
} for e in attrs['emails']
]
return d