From 7cc1a962ae3dd7d6c44d98cfb4258614b96edcef Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 12 Jun 2012 12:31:58 +0000 Subject: [PATCH] Fixes for editing/creating families svn: r19833 --- src/webapp/grampsdb/view/family.py | 19 ++++++++++++++++++- src/webapp/grampsdb/view/person.py | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/webapp/grampsdb/view/family.py b/src/webapp/grampsdb/view/family.py index 0a714791c..f65e2ef23 100644 --- a/src/webapp/grampsdb/view/family.py +++ b/src/webapp/grampsdb/view/family.py @@ -66,6 +66,14 @@ def process_family(request, context, handle, action, add_to=None): # view, edit, if familyform.is_valid(): update_last_changed(family, request.user.username) family = familyform.save() + # FIXME: multiple families with same parents? + # FIXME: remove family from previous mother/father? + if family.mother: + if family not in family.mother.families.all(): + family.mother.families.add(family) + if family.father: + if family not in family.father.families.all(): + family.father.families.add(family) dji.rebuild_cache(family) action = "view" else: @@ -79,12 +87,21 @@ def process_family(request, context, handle, action, add_to=None): # view, edit, if familyform.is_valid(): update_last_changed(family, request.user.username) family = familyform.save() + # FIXME: multiple families with same parents? + # FIXME: remove family from previous mother/father? + if family.mother: + if family not in family.mother.families.all(): + family.mother.families.add(family) + if family.father: + if family not in family.father.families.all(): + family.father.families.add(family) dji.rebuild_cache(family) - if add_to: + if add_to: # FIXME: add family to... what?? item, handle = add_to model = dji.get_model(item) obj = model.objects.get(handle=handle) dji.add_family_ref(obj, family.handle) + # FIXME: cache; move to save methods? what about forms? return redirect("/%s/%s" % (item, handle)) action = "view" else: diff --git a/src/webapp/grampsdb/view/person.py b/src/webapp/grampsdb/view/person.py index ec001ed29..270d3ea2b 100644 --- a/src/webapp/grampsdb/view/person.py +++ b/src/webapp/grampsdb/view/person.py @@ -396,7 +396,7 @@ def process_person(request, context, handle, action, add_to=None): # view, edit, model = dji.get_model(item) # what model? obj = model.objects.get(handle=handle) # get family dji.add_child_ref_default(obj, person) # add person to family - person.parent_familes.add(obj) # add family to child + person.parent_families.add(obj) # add family to child dji.rebuild_cache(person) # rebuild child dji.rebuild_cache(obj) # rebuild family return redirect("/%s/%s%s" % (item, handle, build_search(request)))