Can now edit a person
svn: r19540
This commit is contained in:
parent
324544e4b4
commit
b9eb3cefd3
@ -101,6 +101,7 @@ class NameFormFromPerson(NameForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Name
|
model = Name
|
||||||
# Exclude these, so they don't get checked:
|
# Exclude these, so they don't get checked:
|
||||||
|
# Excludes sort_as and display_as
|
||||||
exclude = ["order", "calendar", "modifier",
|
exclude = ["order", "calendar", "modifier",
|
||||||
"quality",
|
"quality",
|
||||||
#"quality_estimated", "quality_calculated",
|
#"quality_estimated", "quality_calculated",
|
||||||
@ -108,3 +109,4 @@ class NameFormFromPerson(NameForm):
|
|||||||
"year1", "day1", "month1",
|
"year1", "day1", "month1",
|
||||||
"sortval", "newyear", "person",
|
"sortval", "newyear", "person",
|
||||||
"sort_as", "display_as"]
|
"sort_as", "display_as"]
|
||||||
|
|
||||||
|
@ -523,31 +523,25 @@ def view_person_detail(request, view, handle, action="view"):
|
|||||||
surname = name.surname_set.get(primary=True)
|
surname = name.surname_set.get(primary=True)
|
||||||
except:
|
except:
|
||||||
surname = Surname(name=name, primary=True)
|
surname = Surname(name=name, primary=True)
|
||||||
name.surname_set = [surname]
|
|
||||||
else: # adding a new person with new name
|
else: # adding a new person with new name
|
||||||
name = Name(person=person, preferred=True)
|
name = Name(person=person, preferred=True)
|
||||||
surname = Surname(name=name, primary=True)
|
surname = Surname(name=name, primary=True)
|
||||||
name.surname_set = [surname]
|
|
||||||
pf = PersonForm(request.POST, instance=person)
|
pf = PersonForm(request.POST, instance=person)
|
||||||
pf.model = person
|
pf.model = person
|
||||||
nf = NameFormFromPerson(request.POST, instance=name)
|
nf = NameFormFromPerson(request.POST, instance=name)
|
||||||
nf.model = name
|
nf.model = name
|
||||||
if nf.is_valid() and pf.is_valid():
|
if nf.is_valid() and pf.is_valid():
|
||||||
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
|
person = pf.save()
|
||||||
name.title = nf.cleaned_data["title"]
|
name = nf.save(commit=False)
|
||||||
name.nick = nf.cleaned_data["nick"]
|
# Manually set any name data:
|
||||||
name.name_type = nf.cleaned_data["name_type"]
|
name.preferred = True # FIXME: why is this False?
|
||||||
name.call = nf.cleaned_data["call"]
|
name.save()
|
||||||
name.first_name = nf.cleaned_data["first_name"]
|
# Manually set surname data:
|
||||||
|
|
||||||
surname.surname = nf.cleaned_data["surname"]
|
surname.surname = nf.cleaned_data["surname"]
|
||||||
surname.prefix = nf.cleaned_data["prefix"] if nf.cleaned_data["prefix"] != " prefix " else ""
|
surname.prefix = nf.cleaned_data["prefix"] if nf.cleaned_data["prefix"] != " prefix " else ""
|
||||||
|
surname.name = name
|
||||||
pf.save()
|
|
||||||
nf.save(commit=False)
|
|
||||||
surname.save()
|
surname.save()
|
||||||
import pdb; pdb.set_trace()
|
# FIXME: last_saved, last_changed, last_changed_by
|
||||||
#name.save() # FIXME: why this get rid of name.person?
|
|
||||||
# FIXME: update cache
|
# FIXME: update cache
|
||||||
# FIXME: update probably_alive
|
# FIXME: update probably_alive
|
||||||
return redirect("/person/%s" % person.handle)
|
return redirect("/person/%s" % person.handle)
|
||||||
|
@ -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():
|
if (not user.is_authenticated() and not test) or user.is_authenticated():
|
||||||
fieldname = formfield.name # 'surname'
|
fieldname = formfield.name # 'surname'
|
||||||
try:
|
try:
|
||||||
retval = "1:" + str(getattr(formfield.form.model, fieldname))
|
retval = str(getattr(formfield.form.model, fieldname))
|
||||||
except:
|
except:
|
||||||
# name, "prefix"
|
# name, "prefix"
|
||||||
try:
|
try:
|
||||||
retval = "2:" + str(formfield.form.data[fieldname]) # formfield._data()
|
retval = str(formfield.form.data[fieldname]) # formfield._data()
|
||||||
except:
|
except:
|
||||||
retval = "[ERROR: %s]" % fieldname
|
retval = "[ERROR: %s]" % fieldname
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user