Separate system accounts and household people, add generation directory and consented member location sharing
This commit is contained in:
+5
-5
@@ -103,12 +103,12 @@ class Family:
|
||||
(('people', 'fromId'), ('people', 'toId')) if kind == 'link' else ())
|
||||
if kind == 'event' and isinstance(data.get('personIds', []), list):
|
||||
for person in data.get('personIds', []):
|
||||
a.HOUSEHOLDS.owns(user, a.get_object('people', person))
|
||||
a.HOUSEHOLDS.owns_person(user, a.get_object('people', person))
|
||||
old = a.get_object(table, data.get('id'))
|
||||
if data.get('id') and not old:
|
||||
raise a.Problem('家谱记录不存在', 404)
|
||||
item = {'person': self.person, 'link': self.link, 'event': self.event}[kind](data, old)
|
||||
item.update(familyId=family_id, updatedAt=dt.datetime.now(dt.timezone.utc).isoformat(), updatedBy=user['username'])
|
||||
item.update(familyId=(old or {}).get('familyId', family_id), updatedAt=dt.datetime.now(dt.timezone.utc).isoformat(), updatedBy=user['username'])
|
||||
added_link = None
|
||||
bind_self = data.get('asSelf', False)
|
||||
if not isinstance(bind_self, bool):
|
||||
@@ -119,7 +119,7 @@ class Family:
|
||||
links = a.HOUSEHOLDS.objects(user, 'family_links')
|
||||
if kind == 'person' and not old and not bind_self:
|
||||
relative = data.get('relativeId')
|
||||
a.HOUSEHOLDS.owns(user, a.get_object('people', relative))
|
||||
a.HOUSEHOLDS.owns_person(user, a.get_object('people', relative))
|
||||
relation = data.get('relativeKind')
|
||||
if relation not in ('parent', 'child', 'spouse'):
|
||||
raise a.Problem('新增人物时请选择与已有亲属的关系')
|
||||
@@ -170,7 +170,7 @@ class Family:
|
||||
with a.LOCK:
|
||||
if not table or not a.get_object(table, target_id):
|
||||
raise a.Problem('家谱记录不存在', 404)
|
||||
a.HOUSEHOLDS.owns(user, a.get_object(table, target_id))
|
||||
(a.HOUSEHOLDS.owns if kind == 'event' else a.HOUSEHOLDS.owns_person)(user, a.get_object(table, target_id))
|
||||
if before is not None:
|
||||
a.integer(before, 1, 2**53 - 1)
|
||||
rows = a.DB.execute('SELECT * FROM family_changes WHERE kind=? AND target_id=? AND revision<? '
|
||||
@@ -192,7 +192,7 @@ class Family:
|
||||
row = self.a.DB.execute('SELECT * FROM family_changes WHERE revision=?', (change_revision,)).fetchone()
|
||||
if not row:
|
||||
raise self.a.Problem('修改记录不存在', 404)
|
||||
self.a.HOUSEHOLDS.owns(user, json.loads(row['after_json']))
|
||||
(self.a.HOUSEHOLDS.owns if row['kind'] == 'event' else self.a.HOUSEHOLDS.owns_person)(user, json.loads(row['after_json']))
|
||||
return dict(revision=row['revision'], kind=row['kind'], targetId=row['target_id'],
|
||||
before=json.loads(row['before_json']) if row['before_json'] else None,
|
||||
after=json.loads(row['after_json']), at=row['at'], actor=row['actor'])
|
||||
|
||||
Reference in New Issue
Block a user