feat: organize places and device workspaces with scoped heritage records
This commit is contained in:
@@ -33,6 +33,7 @@ import identity
|
||||
import genealogy
|
||||
import households
|
||||
import inventory
|
||||
import heritage
|
||||
import ptz
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
@@ -77,6 +78,7 @@ ACCOUNTS = identity.Accounts(sys.modules[__name__])
|
||||
FAMILY = genealogy.Family(sys.modules[__name__])
|
||||
HOUSEHOLDS = households.Households(sys.modules[__name__])
|
||||
INVENTORY = inventory.Inventory(sys.modules[__name__])
|
||||
HERITAGE = heritage.Heritage(sys.modules[__name__])
|
||||
|
||||
|
||||
def setting(key, default=None):
|
||||
@@ -615,14 +617,14 @@ class Handler(BaseHTTPRequestHandler):
|
||||
try:
|
||||
path = url.urlsplit(self.path).path
|
||||
# 12,000 Chinese characters plus JSON escapes and linked people exceed 16 KiB.
|
||||
data = self.body(131072 if path == '/api/family/event' else 16384)
|
||||
data = self.body(131072 if path in ('/api/family/event','/api/heritage') else 16384)
|
||||
self.validate_origin()
|
||||
if path in ('/api/login', '/api/setup'):
|
||||
self.login(data, path == '/api/setup')
|
||||
return
|
||||
self.require_auth()
|
||||
if path not in ('/api/logout', '/api/account/password', '/api/family/restore',
|
||||
'/api/family/person', '/api/family/link', '/api/family/event', '/api/ptz', '/api/ptz/presets'):
|
||||
'/api/family/person', '/api/family/link', '/api/family/event', '/api/heritage', '/api/ptz', '/api/ptz/presets'):
|
||||
self.require_manager()
|
||||
if path == '/api/logout':
|
||||
with LOCK:
|
||||
@@ -674,6 +676,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.answer(HOUSEHOLDS.leadership(data, self.user))
|
||||
elif path == '/api/device-view':
|
||||
self.answer(HOUSEHOLDS.save_view(data, self.user))
|
||||
elif path == '/api/heritage':
|
||||
self.answer(HERITAGE.save(data, self.user))
|
||||
elif path == '/api/devices':
|
||||
self.answer(INVENTORY.save(data, self.user))
|
||||
elif path in ('/api/family/person', '/api/family/link', '/api/family/event'):
|
||||
@@ -830,6 +834,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.require_manager()
|
||||
self.answer({'users': [ACCOUNTS.public(u) for u in HOUSEHOLDS.objects(self.user, 'users')
|
||||
if self.user['role'] == 'admin' or u['role'] != 'admin']})
|
||||
elif path == '/api/heritage':
|
||||
self.answer(HERITAGE.snapshot(self.user))
|
||||
elif path == '/api/households':
|
||||
self.answer({'households': HOUSEHOLDS.list(self.user), 'activeId': HOUSEHOLDS.scope(self.user)})
|
||||
elif path == '/api/ptz/presets':
|
||||
@@ -917,6 +923,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
files = {'/': 'index.html', '/app.js': 'app.js', '/live-player.js': 'live-player.js', '/style.css': 'style.css',
|
||||
'/family.js': 'family.js', '/kinship.js': 'kinship.js', '/households.js': 'households.js',
|
||||
'/device-model.js': 'device-model.js', '/devices.js': 'devices.js',
|
||||
'/steward.js': 'steward.js', '/heritage.js': 'heritage.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',
|
||||
@@ -955,6 +962,7 @@ def initialize():
|
||||
FAMILY.initialize()
|
||||
ACCOUNTS.initialize()
|
||||
HOUSEHOLDS.initialize()
|
||||
HERITAGE.initialize()
|
||||
if not setting('storage'):
|
||||
set_setting('storage', {'retentionDays': 7, 'maxGB': 40, 'reserveGB': 8})
|
||||
if not setting('mediaSecret'):
|
||||
|
||||
Reference in New Issue
Block a user