Release 0.1.45: member phone locations and people-first family navigation
This commit is contained in:
+17
-8
@@ -33,14 +33,19 @@ class Members:
|
||||
account = a.get_object('users', user['id']) or user
|
||||
homes = a.HOUSEHOLDS.list(user)
|
||||
home_map = {h['id']: h for h in homes}
|
||||
trees, placed = {}, set()
|
||||
readable = {}
|
||||
for home in homes:
|
||||
actor = a.HOUSEHOLDS.context(account, home['id'])
|
||||
if not a.HOUSEHOLDS.manager(actor) and actor.get('familyAccess') not in ('read', 'edit'):
|
||||
continue
|
||||
if home.get('kind', 'home') == 'home' and (a.HOUSEHOLDS.manager(actor) or actor.get('familyAccess') in ('read', 'edit')):
|
||||
readable.setdefault(a.HOUSEHOLDS.genealogy_of(home['id']), []).append(home['id'])
|
||||
trees, placed = {}, set()
|
||||
for home in homes:
|
||||
tree = a.HOUSEHOLDS.genealogy_of(home['id'])
|
||||
if tree in trees:
|
||||
if tree in trees or tree not in readable:
|
||||
continue
|
||||
context_id = a.HOUSEHOLDS.scope(user)
|
||||
context_id = context_id if context_id in readable[tree] else readable[tree][0]
|
||||
actor = a.HOUSEHOLDS.context(account, context_id)
|
||||
people = a.HOUSEHOLDS.objects(actor, 'people')
|
||||
links = a.HOUSEHOLDS.objects(actor, 'family_links')
|
||||
connected = {}
|
||||
@@ -61,19 +66,22 @@ class Members:
|
||||
branch, level = connected[person['id']]
|
||||
branches.setdefault(branch, {})[person['id']] = dict(
|
||||
id=person['id'], name=person['name'], generation=level,
|
||||
lifeStatus=person.get('lifeStatus', 'alive'), homes=[])
|
||||
self=person['id'] == account.get('personId'),
|
||||
lifeStatus=person.get('lifeStatus', 'alive'), homes=[], journalHomes=[])
|
||||
for member in a.objects('family_members'):
|
||||
if member['familyId'] not in home_map or member['personId'] not in connected:
|
||||
continue
|
||||
if member['status'] == 'historical':
|
||||
continue
|
||||
pid = member['personId']
|
||||
branch, _ = connected[pid]
|
||||
branches[branch][pid]['journalHomes'].append(dict(
|
||||
id=member['familyId'], name=home_map[member['familyId']]['name']))
|
||||
if member['status'] == 'historical':
|
||||
continue
|
||||
branches[branch][pid]['homes'].append(dict(
|
||||
id=member['familyId'], name=home_map[member['familyId']]['name'], status=member['status']))
|
||||
placed.add(member['familyId'])
|
||||
trees[tree] = dict(
|
||||
id=tree, homes=[dict(id=h['id'], name=h['name']) for h in homes
|
||||
id=tree, familyId=context_id, homes=[dict(id=h['id'], name=h['name']) for h in homes
|
||||
if a.HOUSEHOLDS.genealogy_of(h['id']) == tree],
|
||||
branches=[dict(id=k, people=sorted(v.values(), key=lambda p: (p['generation'] or 100000, p['name'])))
|
||||
for k, v in branches.items()])
|
||||
@@ -99,6 +107,7 @@ class Members:
|
||||
items.append(dict(row, name=person['name'], lifeStatus=person.get('lifeStatus', 'alive'),
|
||||
hasAccount=bool(accounts), self=person['id'] == user.get('personId')))
|
||||
return dict(items=items, canManage=a.HOUSEHOLDS.manager(user),
|
||||
canViewGenealogy=a.HOUSEHOLDS.manager(user) or user.get('familyAccess') in ('read', 'edit'),
|
||||
genealogyId=a.HOUSEHOLDS.genealogy_of(family),
|
||||
genealogyHomes=[dict(id=h['id'], name=h['name']) for h in a.HOUSEHOLDS.list(user)
|
||||
if a.HOUSEHOLDS.genealogy_of(h['id']) == a.HOUSEHOLDS.genealogy_of(family)],
|
||||
|
||||
Reference in New Issue
Block a user