Separate system accounts and household people, add generation directory and consented member location sharing

This commit is contained in:
Codex
2026-10-18 20:00:43 +08:00
parent 67bc5a1ba9
commit 3b2c046060
52 changed files with 1497 additions and 311 deletions
+13 -7
View File
@@ -13,11 +13,14 @@ class Inventory:
users = a.HOUSEHOLDS.objects(user, 'users')
if user['role'] == 'admin' and not any(u['id'] == user['id'] for u in users):
users.append(user)
result = [dict(ref='user:'+u['id'], name=u['name'], label=u['name']+' / '+u['username'], kind='账号成员')
for u in users if not u.get('disabled')]
linked = {u.get('personId') for u in users if not u.get('disabled')}
result += [dict(ref='person:'+p['id'], name=p['name'], label=p['name']+' · '+p['id'][-4:], kind='家谱人物')
for p in a.HOUSEHOLDS.objects(user, 'people') if not p.get('archived') and p['id'] not in linked]
members = a.MEMBERS.snapshot(user)['items']
eligible = {m['personId'] for m in members if m['status'] != 'historical' and m['lifeStatus'] != 'deceased'}
result = [dict(ref='person:'+p['id'], name=p['name'], label=p['name']+' · '+p['id'][-4:], kind='家庭成员')
for p in a.HOUSEHOLDS.objects(user, 'people') if p['id'] in eligible and not p.get('archived')]
# Preserve optional account contacts for offices/external maintainers; a login
# grant does not make that account a real household member.
result += [dict(ref='user:'+u['id'], name=u['name'], label=u['name']+' / '+u['username'], kind='授权账号联系人')
for u in users if not u.get('disabled') and u.get('personId') not in eligible]
return result
def display(self, item):
@@ -26,8 +29,11 @@ class Inventory:
ref = item.get(prefix+'Ref', '')
kind, _, key = ref.partition(':')
target = self.a.get_object({'user':'users','person':'people'}.get(kind, 'users'), key) if key else None
if target and (self.a.HOUSEHOLDS.family_of(target) == self.a.HOUSEHOLDS.family_of(item) or
kind == 'user' and target.get('role') == 'admin'):
family = self.a.HOUSEHOLDS.family_of(item)
valid = target and (self.a.HOUSEHOLDS.family_of(target) == family or
kind == 'user' and self.a.HOUSEHOLDS.grant(target, family) or
kind == 'person' and any(m['personId'] == key for m in self.a.MEMBERS.rows(family)))
if valid:
result[prefix+'Name'] = target['name']
return result