Add hierarchical geography and cloud-hosted profile images
This commit is contained in:
@@ -31,10 +31,12 @@ import onvif
|
||||
import playback
|
||||
import identity
|
||||
import genealogy
|
||||
import geography
|
||||
import households
|
||||
import inventory
|
||||
import heritage
|
||||
import appearance
|
||||
import cloud_images
|
||||
import backups
|
||||
import baidu
|
||||
import journal
|
||||
@@ -87,6 +89,7 @@ APPEARANCE = appearance.Appearance(sys.modules[__name__])
|
||||
BACKUPS = backups.Backups(sys.modules[__name__])
|
||||
BAIDU = baidu.Baidu(sys.modules[__name__])
|
||||
JOURNAL = journal.Journal(sys.modules[__name__])
|
||||
CLOUD_IMAGES = cloud_images.CloudImages(sys.modules[__name__])
|
||||
|
||||
|
||||
def setting(key, default=None):
|
||||
@@ -190,6 +193,7 @@ def save_site(body, actor=None):
|
||||
required=k == 'name') for k in SITE_FIELDS}
|
||||
item.update(id=key, kind=body.get('kind', 'home'), familyId=family, parentId=parent,
|
||||
category=clean_text(body.get('category', ''), 40))
|
||||
geography.apply(item, body, get_object('sites', key), clean_text, Problem)
|
||||
if item['kind'] not in ('home', 'company', 'office', 'factory', 'other'):
|
||||
raise Problem('请选择有效区域用途')
|
||||
save_object('sites', item)
|
||||
@@ -893,8 +897,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.answer(APPEARANCE.public())
|
||||
return
|
||||
if path in ('/brand-logo.png', '/brand-icon.png'):
|
||||
value = APPEARANCE.config().get('logoData' if path == '/brand-logo.png' else 'iconData', '')
|
||||
raw = base64.b64decode(value.split(',', 1)[1]) if value else (ROOT/'web/zhao-icon.png').read_bytes()
|
||||
kind='logo' if path == '/brand-logo.png' else 'icon'
|
||||
config=APPEARANCE.config();value=config.get(kind+'Data','')
|
||||
raw = CLOUD_IMAGES.get(config[kind+'Ref']) if config.get(kind+'Ref') else base64.b64decode(value.split(',',1)[1]) if value else (ROOT/'web/zhao-icon.png').read_bytes()
|
||||
self.image(raw, public=True)
|
||||
return
|
||||
if path == '/api/session':
|
||||
@@ -942,7 +947,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.answer(APPEARANCE.preferences(self.user))
|
||||
elif path == '/api/appearance':
|
||||
self.require_admin()
|
||||
self.answer(APPEARANCE.config())
|
||||
self.answer(APPEARANCE.editable())
|
||||
elif path == '/api/backups':
|
||||
self.require_admin()
|
||||
self.answer(BACKUPS.status())
|
||||
@@ -950,8 +955,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
home = get_object('households', query.get('id'))
|
||||
if not home or self.user['role'] != 'admin' and home['id'] != HOUSEHOLDS.scope(self.user):
|
||||
raise Problem('封面不存在或未获授权', 404)
|
||||
if not home.get('coverData'): raise Problem('尚未上传封面', 404)
|
||||
self.image(base64.b64decode(home['coverData'].split(',', 1)[1]))
|
||||
if not home.get('coverRef') and not home.get('coverData'): raise Problem('尚未上传封面', 404)
|
||||
self.image(CLOUD_IMAGES.get(home['coverRef']) if home.get('coverRef') else base64.b64decode(home['coverData'].split(',', 1)[1]))
|
||||
elif path == '/api/users':
|
||||
self.require_manager()
|
||||
self.answer({'users': [ACCOUNTS.public(u) for u in HOUSEHOLDS.objects(self.user, 'users')
|
||||
@@ -1047,6 +1052,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
'/device-model.js': 'device-model.js', '/devices.js': 'devices.js',
|
||||
'/steward.js': 'steward.js', '/heritage.js': 'heritage.js', '/personalization.js': 'personalization.js',
|
||||
'/journal.js': 'journal.js', '/file-hash.js': 'file-hash.js',
|
||||
'/geography.js': 'geography.js', '/data/geography-data.js': 'data/geography-data.js',
|
||||
'/family-graph.js': 'family-graph.js', '/family-map.js': 'family-map.js',
|
||||
'/family-map.css': 'family-map.css', '/chinese-theme.css': 'chinese-theme.css',
|
||||
'/family-events.js': 'family-events.js',
|
||||
|
||||
Reference in New Issue
Block a user