Add a configurable avatar system and add an internal avatar system for enterprise
This commit is contained in:
parent
f6dd8b0a4d
commit
e9cac407df
36 changed files with 241 additions and 92 deletions
|
@ -2,7 +2,7 @@ import logging
|
|||
|
||||
from flask import request
|
||||
|
||||
from app import billing as stripe
|
||||
from app import billing as stripe, avatar
|
||||
from endpoints.api import (resource, nickname, ApiResource, validate_json_request, request_error,
|
||||
related_user_resource, internal_only, Unauthorized, NotFound,
|
||||
require_user_admin, log_action, show_if)
|
||||
|
@ -13,7 +13,6 @@ from auth.permissions import (AdministerOrganizationPermission, OrganizationMem
|
|||
from auth.auth_context import get_authenticated_user
|
||||
from data import model
|
||||
from data.billing import get_plan
|
||||
from util.gravatar import compute_hash
|
||||
|
||||
import features
|
||||
|
||||
|
@ -28,7 +27,7 @@ def org_view(o, teams):
|
|||
view = {
|
||||
'name': o.username,
|
||||
'email': o.email if is_admin else '',
|
||||
'gravatar': compute_hash(o.email),
|
||||
'avatar': avatar.compute_hash(o.email, name=o.username),
|
||||
'teams': {t.name : team_view(o.username, t) for t in teams},
|
||||
'is_admin': is_admin
|
||||
}
|
||||
|
@ -274,14 +273,16 @@ class ApplicationInformation(ApiResource):
|
|||
if not application:
|
||||
raise NotFound()
|
||||
|
||||
org_hash = compute_hash(application.organization.email)
|
||||
gravatar = compute_hash(application.gravatar_email) if application.gravatar_email else org_hash
|
||||
org_hash = avatar.compute_hash(application.organization.email,
|
||||
name=application.organization.username)
|
||||
app_hash = (avatar.compute_hash(application.avatar_email, name=application.name) if
|
||||
application.avatar_email else org_hash)
|
||||
|
||||
return {
|
||||
'name': application.name,
|
||||
'description': application.description,
|
||||
'uri': application.application_uri,
|
||||
'gravatar': gravatar,
|
||||
'avatar': app_hash,
|
||||
'organization': org_view(application.organization, [])
|
||||
}
|
||||
|
||||
|
@ -297,7 +298,7 @@ def app_view(application):
|
|||
'client_id': application.client_id,
|
||||
'client_secret': application.client_secret if is_admin else None,
|
||||
'redirect_uri': application.redirect_uri if is_admin else None,
|
||||
'gravatar_email': application.gravatar_email if is_admin else None,
|
||||
'avatar_email': application.avatar_email if is_admin else None,
|
||||
}
|
||||
|
||||
|
||||
|
@ -330,9 +331,9 @@ class OrganizationApplications(ApiResource):
|
|||
'type': 'string',
|
||||
'description': 'The human-readable description for the application',
|
||||
},
|
||||
'gravatar_email': {
|
||||
'avatar_email': {
|
||||
'type': 'string',
|
||||
'description': 'The e-mail address of the gravatar to use for the application',
|
||||
'description': 'The e-mail address of the avatar to use for the application',
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -371,7 +372,7 @@ class OrganizationApplications(ApiResource):
|
|||
app_data.get('application_uri', ''),
|
||||
app_data.get('redirect_uri', ''),
|
||||
description = app_data.get('description', ''),
|
||||
gravatar_email = app_data.get('gravatar_email', None),)
|
||||
avatar_email = app_data.get('avatar_email', None),)
|
||||
|
||||
|
||||
app_data.update({
|
||||
|
@ -416,9 +417,9 @@ class OrganizationApplicationResource(ApiResource):
|
|||
'type': 'string',
|
||||
'description': 'The human-readable description for the application',
|
||||
},
|
||||
'gravatar_email': {
|
||||
'avatar_email': {
|
||||
'type': 'string',
|
||||
'description': 'The e-mail address of the gravatar to use for the application',
|
||||
'description': 'The e-mail address of the avatar to use for the application',
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -462,7 +463,7 @@ class OrganizationApplicationResource(ApiResource):
|
|||
application.application_uri = app_data['application_uri']
|
||||
application.redirect_uri = app_data['redirect_uri']
|
||||
application.description = app_data.get('description', '')
|
||||
application.gravatar_email = app_data.get('gravatar_email', None)
|
||||
application.avatar_email = app_data.get('avatar_email', None)
|
||||
application.save()
|
||||
|
||||
app_data.update({
|
||||
|
|
Reference in a new issue