From 22d91dfd6c3ac3d6131e8e0b9471c2f63dc3360f Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 18 Oct 2011 01:56:14 +0000 Subject: [PATCH] Working on editing person svn: r18342 --- src/data/templates/view_person_detail.html | 48 +++++++++++----------- src/webapp/grampsdb/forms.py | 47 +++++++++++++-------- src/webapp/grampsdb/views.py | 12 +++++- 3 files changed, 65 insertions(+), 42 deletions(-) diff --git a/src/data/templates/view_person_detail.html b/src/data/templates/view_person_detail.html index 2643451dc..16d3ecc11 100644 --- a/src/data/templates/view_person_detail.html +++ b/src/data/templates/view_person_detail.html @@ -14,11 +14,9 @@ {{ "/browse|Browse,/person|People"|breadcrumb}} -

{{nameform|render_name:user}} [{{person.gramps_id}}]

{% comment %} 5 cols {% endcomment %} - {% if user.is_authenticated %} {% ifequal action "edit" %} {% for error in personform.errors %} @@ -32,38 +30,40 @@ {% endif %} - - - - - - - - - - - - - - - - - + + - - + + + + + - + + + + + + + + + + + + + - + + + - + diff --git a/src/webapp/grampsdb/forms.py b/src/webapp/grampsdb/forms.py index 4ab359ff1..e56eeb042 100644 --- a/src/webapp/grampsdb/forms.py +++ b/src/webapp/grampsdb/forms.py @@ -12,11 +12,6 @@ class PersonForm(forms.ModelForm): model = Person exclude = ["death", "birth", "handle", "birth_ref_index", "death_ref_index"] - surname = forms.CharField(required=False, - widget=TextInput(attrs={'size':'30'})) - prefix = forms.CharField(required=False, - widget=TextInput(attrs={'size':'30'})) - class NameForm(forms.ModelForm): class Meta: model = Name @@ -33,23 +28,41 @@ class NameForm(forms.ModelForm): widget=TextInput(attrs={'size':'30'})) first_name = forms.CharField(label="Given", required=False, - widget=TextInput(attrs={'size':'30'})) + widget=TextInput(attrs={'size':'60'})) title = forms.CharField(required=False, - widget=TextInput(attrs={'size':'30'})) + widget=TextInput(attrs={'size':'15'})) prefix = forms.CharField(required=False, - widget=TextInput(attrs={'size':'30'})) + initial='prefix', + widget=TextInput(attrs={'size':'15', + 'style': 'font-style: italic; color: gray; ', + 'onFocus': """if (this.value == 'prefix') {this.value = ''; + this.style.color = "black"; + this.style.fontStyle = 'normal'; + }""", + 'onBlur': """if (this.value == '') {this.value = 'prefix'; + this.style.color = "gray"; + this.style.fontStyle = 'italic'; + }"""})) suffix = forms.CharField(required=False, - widget=TextInput(attrs={'size':'30'})) - call = forms.CharField(label="Callname", + initial='suffix', + widget=TextInput(attrs={'size':'15', + 'style': 'font-style: italic; color: gray; ', + 'onFocus': """if (this.value == 'suffix') {this.value = ''; + this.style.color = "black"; + this.style.fontStyle = 'normal'; + }""", + 'onBlur': """if (this.value == '') {this.value = 'suffix'; + this.style.color = "gray"; + this.style.fontStyle = 'italic'; + }"""})) + call = forms.CharField(label="Call", required=False, - widget=TextInput(attrs={'size':'30'})) - patronymic = forms.CharField(required=False, - widget=TextInput(attrs={'size':'30'})) - group_as = forms.CharField(required=False, - widget=TextInput(attrs={'size':'30'})) - text = forms.CharField(label="Date", + widget=TextInput(attrs={'size':'15'})) + nick = forms.CharField(label="Nick", required=False, - widget=TextInput(attrs={'size':'30'})) + widget=TextInput(attrs={'size':'15'})) + origin = forms.CharField(required=False, + widget=TextInput(attrs={'size':'15'})) class NameFormFromPerson(NameForm): class Meta: diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py index 14faf56de..892d4d5f2 100644 --- a/src/webapp/grampsdb/views.py +++ b/src/webapp/grampsdb/views.py @@ -438,9 +438,19 @@ def view_person_detail(request, view, handle, action="view"): name = person.name_set.get(preferred=True) except: name = Name(person=person, preferred=True) + primary_surname = name.surname_set.get(primary=True) + default_data = {"surname": primary_surname.surname, + "prefix": primary_surname.prefix, + "suffix": name.suffix or "suffix", + "first_name": name.first_name, + "name_type": name.name_type, + "title": name.title, + "nick": name.nick, + "call": name.call, + } pf = PersonForm(instance=person) pf.model = person - nf = NameForm(instance=name) + nf = NameForm(default_data, instance=name) nf.model = name elif action == "add": # make new data:
Image:
{{nameform.suffix.label}}{% render nameform.suffix user action %}
{{nameform.first_name.label}}{% render nameform.first_name user action nameform.model.person.probably_alive "[Living]" %}{{nameform.call.label}}{% render nameform.call user action %}
{{nameform.name_type.label}}{{nameform|render_name:user}} [{{person.gramps_id}}]{{nameform.name_type.label}}: {% render nameform.name_type user action %}
{{nameform.title.label}}{{nameform.title.label}}: {% render nameform.title user action %}{{nameform.nick.label}}:{% render nameform.nick user action %}{{nameform.call.label}}:{% render nameform.call user action %}
{{personform.gender_type.label}}{{nameform.first_name.label}}:{% render nameform.first_name user action %}{% render nameform.suffix user action %}
{{nameform.surname.label}}:{% render nameform.prefix user action %}{% render nameform.surname user action %}{{nameform.origin.label}}:{% render nameform.origin user action %}
{{personform.gender_type.label}}: {% render personform.gender_type user action %}{{personform.gramps_id.label}}{{personform.gramps_id.label}}: {% render personform.gramps_id user action %}{{personform.tags.label}}:{% render personform.tags user action %}
{{personform.private.label}}{{personform.private.label}}: {% render personform.private user action %}