diff --git a/src/webapp/grampsdb/forms.py b/src/webapp/grampsdb/forms.py index 476ac5abe..25b79db22 100644 --- a/src/webapp/grampsdb/forms.py +++ b/src/webapp/grampsdb/forms.py @@ -101,6 +101,7 @@ class NameFormFromPerson(NameForm): class Meta: model = Name # Exclude these, so they don't get checked: + # Excludes sort_as and display_as exclude = ["order", "calendar", "modifier", "quality", #"quality_estimated", "quality_calculated", @@ -108,3 +109,4 @@ class NameFormFromPerson(NameForm): "year1", "day1", "month1", "sortval", "newyear", "person", "sort_as", "display_as"] + diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py index aca5d48f1..a000040d6 100644 --- a/src/webapp/grampsdb/views.py +++ b/src/webapp/grampsdb/views.py @@ -523,31 +523,25 @@ def view_person_detail(request, view, handle, action="view"): surname = name.surname_set.get(primary=True) except: surname = Surname(name=name, primary=True) - name.surname_set = [surname] else: # adding a new person with new name name = Name(person=person, preferred=True) surname = Surname(name=name, primary=True) - name.surname_set = [surname] pf = PersonForm(request.POST, instance=person) pf.model = person nf = NameFormFromPerson(request.POST, instance=name) nf.model = name if nf.is_valid() and pf.is_valid(): - name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else "" - name.title = nf.cleaned_data["title"] - name.nick = nf.cleaned_data["nick"] - name.name_type = nf.cleaned_data["name_type"] - name.call = nf.cleaned_data["call"] - name.first_name = nf.cleaned_data["first_name"] - + person = pf.save() + name = nf.save(commit=False) + # Manually set any name data: + name.preferred = True # FIXME: why is this False? + name.save() + # Manually set surname data: surname.surname = nf.cleaned_data["surname"] surname.prefix = nf.cleaned_data["prefix"] if nf.cleaned_data["prefix"] != " prefix " else "" - - pf.save() - nf.save(commit=False) + surname.name = name surname.save() - import pdb; pdb.set_trace() - #name.save() # FIXME: why this get rid of name.person? + # FIXME: last_saved, last_changed, last_changed_by # FIXME: update cache # FIXME: update probably_alive return redirect("/person/%s" % person.handle) diff --git a/src/webapp/utils.py b/src/webapp/utils.py index ab1163882..f3568ba2e 100644 --- a/src/webapp/utils.py +++ b/src/webapp/utils.py @@ -607,11 +607,11 @@ def render(formfield, user, action, test=False, truetext="", id=None): if (not user.is_authenticated() and not test) or user.is_authenticated(): fieldname = formfield.name # 'surname' try: - retval = "1:" + str(getattr(formfield.form.model, fieldname)) + retval = str(getattr(formfield.form.model, fieldname)) except: # name, "prefix" try: - retval = "2:" + str(formfield.form.data[fieldname]) # formfield._data() + retval = str(formfield.form.data[fieldname]) # formfield._data() except: retval = "[ERROR: %s]" % fieldname else: