diff --git a/src/data/templates/view_family_detail.html b/src/data/templates/view_family_detail.html
index 2ffb5ac69..6777012dc 100644
--- a/src/data/templates/view_family_detail.html
+++ b/src/data/templates/view_family_detail.html
@@ -89,7 +89,7 @@
{{ family|family_event_table:user|safe }}
- {{ family|family_source_table:user|safe }}
+ {{ family|source_table:user|safe }}
{{ family|family_attribute_table:user|safe }}
diff --git a/src/data/templates/view_name_detail.html b/src/data/templates/view_name_detail.html
index fabf8b957..4d6707c7f 100644
--- a/src/data/templates/view_name_detail.html
+++ b/src/data/templates/view_name_detail.html
@@ -68,9 +68,25 @@
Sources
Notes
+
+
+ {{form.group_as.label}}: |
+ {{form.group_as|render:action}} |
+
+ {{form.sort_as.label}}: |
+ {{form.sort_as|render:action}} |
+
+ {{form.display_as.label}}: |
+ {{form.display_as|render:action}} |
+
+ {{form.text.label}}: |
+ {{form.text|render:action}} |
+
+
+ {% source_table form.model user action "/person/%s/name/%s/source/add" person.handle form.model.order %}
diff --git a/src/data/templates/view_page.html b/src/data/templates/view_page.html
index 8eef2a8e2..3d38145b8 100644
--- a/src/data/templates/view_page.html
+++ b/src/data/templates/view_page.html
@@ -6,41 +6,45 @@
{% block content %}
-
+
-
+
@@ -54,32 +58,36 @@
diff --git a/src/data/templates/view_person_detail.html b/src/data/templates/view_person_detail.html
index 2d8d5be6b..95fcdec7a 100644
--- a/src/data/templates/view_person_detail.html
+++ b/src/data/templates/view_person_detail.html
@@ -86,7 +86,7 @@
{{ person|person_name_table:user|safe }}
- {{ person|person_source_table:user|safe }}
+ {% source_table person user action "/person/%s/source/add" person.handle %}
{{ person|person_attribute_table:user|safe }}
diff --git a/src/web/grampsdb/fixtures/initial_data.json b/src/web/grampsdb/fixtures/initial_data.json
index 1ad2b0531..15bad817f 100644
--- a/src/web/grampsdb/fixtures/initial_data.json
+++ b/src/web/grampsdb/fixtures/initial_data.json
@@ -18,7 +18,7 @@
"setting" : "db_created" ,
"description" : "database creation date/time" ,
"value_type" : "str" ,
- "value" : "2009-12-12 20:42"
+ "value" : "2009-12-26 00:38"
}
},
{
@@ -1568,5 +1568,41 @@
"val" : 13,
"name": "Uncleared"
}
+ } ,
+ {
+ "model": "grampsdb.nameformattype",
+ "pk": 1,
+ "fields":
+ {
+ "val" : 0,
+ "name": "Default format"
+ }
+ } ,
+ {
+ "model": "grampsdb.nameformattype",
+ "pk": 2,
+ "fields":
+ {
+ "val" : 1,
+ "name": "Surname, Given Patronymic"
+ }
+ } ,
+ {
+ "model": "grampsdb.nameformattype",
+ "pk": 3,
+ "fields":
+ {
+ "val" : 2,
+ "name": "Given Surname"
+ }
+ } ,
+ {
+ "model": "grampsdb.nameformattype",
+ "pk": 4,
+ "fields":
+ {
+ "val" : 3,
+ "name": "Patronymic, Given"
+ }
}
]
diff --git a/src/web/grampsdb/forms.py b/src/web/grampsdb/forms.py
index a06271bc5..218fbfeb4 100644
--- a/src/web/grampsdb/forms.py
+++ b/src/web/grampsdb/forms.py
@@ -20,18 +20,36 @@ class PersonForm(forms.ModelForm):
class NameForm(forms.ModelForm):
class Meta:
model = Name
- fields = ("suffix", "first_name", "title", "prefix",
- "call", "surname", "patronymic", "name_type",
- "preferred")
+ # Exclude these, so they don't get checked:
+ exclude = ["order", "calendar", "modifier",
+ "quality",
+ #"quality_estimated", "quality_calculated",
+ #"quality_interpreted",
+ "year1", "day1", "month1",
+ "sortval", "newyear", "person"]
# Add these because they are TextFields, which render as
# Textareas:
- surname = forms.CharField(required=False, widget=TextInput(attrs={'size':'30'}))
- first_name = forms.CharField(required=False, widget=TextInput(attrs={'size':'30'}))
- title = forms.CharField(required=False, widget=TextInput(attrs={'size':'30'}))
- prefix = forms.CharField(required=False, widget=TextInput(attrs={'size':'30'}))
- suffix = forms.CharField(required=False, widget=TextInput(attrs={'size':'30'}))
- call = forms.CharField(required=False, widget=TextInput(attrs={'size':'30'}))
- patronymic = forms.CharField(required=False, widget=TextInput(attrs={'size':'30'}))
+ surname = forms.CharField(required=False,
+ widget=TextInput(attrs={'size':'30'}))
+ first_name = forms.CharField(label="Given",
+ required=False,
+ widget=TextInput(attrs={'size':'30'}))
+ title = forms.CharField(required=False,
+ widget=TextInput(attrs={'size':'30'}))
+ prefix = forms.CharField(required=False,
+ widget=TextInput(attrs={'size':'30'}))
+ suffix = forms.CharField(required=False,
+ widget=TextInput(attrs={'size':'30'}))
+ call = forms.CharField(label="Callname",
+ 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",
+ required=False,
+ widget=TextInput(attrs={'size':'30'}))
'''class NameFormset(BaseModelFormSet):
def __init__(self, *args, **kwargs):
diff --git a/src/web/grampsdb/models.py b/src/web/grampsdb/models.py
index b1f6a3588..6bb5a2576 100644
--- a/src/web/grampsdb/models.py
+++ b/src/web/grampsdb/models.py
@@ -229,6 +229,68 @@ class LdsStatus(mGrampsType):
_DEFAULT = _DATAMAP[0]
val = models.IntegerField('lds status', choices=_DATAMAP, blank=False)
+class NameFormatType(mGrampsType):
+ _DATAMAP = [(0, "Default format"),
+ (1, "Surname, Given Patronymic"),
+ (2, "Given Surname"),
+ (3, "Patronymic, Given"),]
+ _DEFAULT = _DATAMAP[0]
+ val = models.IntegerField('Name formats', choices=_DATAMAP, blank=False)
+
+class CalendarType(mGrampsType):
+ CAL_GREGORIAN = 0 # CODE
+ CAL_JULIAN = 1
+ CAL_HEBREW = 2
+ CAL_FRENCH = 3
+ CAL_PERSIAN = 4
+ CAL_ISLAMIC = 5
+ CAL_SWEDISH = 6
+
+ _DATAMAP = [(CAL_GREGORIAN, "Gregorian"),
+ (CAL_JULIAN, "Julian"),
+ (CAL_HEBREW, "Hebrew"),
+ (CAL_FRENCH, "French Republican"),
+ (CAL_PERSIAN, "Persian"),
+ (CAL_ISLAMIC, "Islamic"),
+ (CAL_SWEDISH, "Swedish")]
+
+ _DEFAULT = _DATAMAP[CAL_GREGORIAN]
+ val = models.IntegerField('Calendar', choices=_DATAMAP, blank=False)
+
+class DateModifierType(mGrampsType):
+ MOD_NONE = 0 # CODE
+ MOD_BEFORE = 1
+ MOD_AFTER = 2
+ MOD_ABOUT = 3
+ MOD_RANGE = 4
+ MOD_SPAN = 5
+ MOD_TEXTONLY = 6
+
+ _DATAMAP = [(MOD_NONE, ""),
+ (MOD_BEFORE, "Before"),
+ (MOD_AFTER, "After"),
+ (MOD_ABOUT, "About"),
+ (MOD_RANGE, "Range"),
+ (MOD_SPAN, "Span"),
+ (MOD_TEXTONLY, "Text only")]
+
+ _DEFAULT = _DATAMAP[MOD_NONE]
+ val = models.IntegerField('Date modifier', choices=_DATAMAP, blank=False)
+
+class DateNewYearType(mGrampsType):
+ NEWYEAR_JAN1 = 0 # CODE
+ NEWYEAR_MAR1 = 1
+ NEWYEAR_MAR25 = 2
+ NEWYEAR_SEP1 = 3
+
+ _DATAMAP = [(NEWYEAR_JAN1, ""),
+ (NEWYEAR_MAR1, "March 1"),
+ (NEWYEAR_MAR25, "March 25"),
+ (NEWYEAR_SEP1, "September 1")]
+
+ _DEFAULT = _DATAMAP[NEWYEAR_JAN1]
+ val = models.IntegerField('New Year start date', choices=_DATAMAP, blank=False)
+
#---------------------------------------------------------------------------
#
# Support definitions
@@ -241,6 +303,9 @@ class DateObject(models.Model):
calendar = models.IntegerField()
modifier = models.IntegerField()
quality = models.IntegerField()
+ #quality_estimated = models.BooleanField()
+ #quality_calculated = models.BooleanField()
+ #quality_interpreted = models.BooleanField()
day1 = models.IntegerField()
month1 = models.IntegerField()
year1 = models.IntegerField()
@@ -447,7 +512,7 @@ class SecondaryObject(models.Model):
class Name(DateObject, SecondaryObject):
name_type = models.ForeignKey('NameType', related_name="name_code")
- preferred = models.BooleanField('preferred name?')
+ preferred = models.BooleanField('Preferred name?')
first_name = models.TextField(blank=True)
surname = models.TextField(blank=True)
suffix = models.TextField(blank=True)
@@ -456,8 +521,10 @@ class Name(DateObject, SecondaryObject):
patronymic = models.TextField(blank=True)
call = models.TextField(blank=True)
group_as = models.TextField(blank=True)
- sort_as = models.IntegerField(blank=True)
- display_as = models.IntegerField(blank=True)
+ sort_as = models.ForeignKey('NameFormatType',
+ related_name="sort_as")
+ display_as = models.ForeignKey('NameFormatType',
+ related_name="display_as")
## Key:
person = models.ForeignKey("Person")
@@ -656,6 +723,7 @@ TABLES = [
("type", MarkerType),
("type", MarkupType),
("type", NameType),
+ ("type", NameFormatType),
("type", AttributeType),
("type", UrlType),
("type", ChildRefType),
diff --git a/src/web/grampsdb/templatetags/my_tags.py b/src/web/grampsdb/templatetags/my_tags.py
index 20fdaa6bd..59be2150d 100644
--- a/src/web/grampsdb/templatetags/my_tags.py
+++ b/src/web/grampsdb/templatetags/my_tags.py
@@ -8,17 +8,6 @@ import web.utils
register = Library()
-util_filters = ['person_event_table', 'person_name_table',
- 'person_source_table', 'person_attribute_table',
- 'person_address_table', 'person_note_table',
- 'person_gallery_table', 'person_internet_table',
- 'person_association_table', 'person_lds_table',
- 'person_reference_table',
- 'family_children_table', 'family_event_table',
- 'family_source_table', 'family_attribute_table',
- 'family_note_table', 'family_gallery_table',
- 'family_lds_table',
- 'nbsp', 'render']
for filter_name in util_filters:
func = getattr(web.utils, filter_name)
func.is_safe = True
@@ -66,6 +55,9 @@ def make_tag(func):
register.tag("get_person_from_handle",
make_tag(get_person_from_handle))
+register.tag("source_table",
+ make_tag(source_table))
+
probably_alive.is_safe = True
register.filter('probably_alive', probably_alive)
diff --git a/src/web/grampsdb/views.py b/src/web/grampsdb/views.py
index 37ddffd44..ace8936a8 100644
--- a/src/web/grampsdb/views.py
+++ b/src/web/grampsdb/views.py
@@ -141,7 +141,10 @@ def view_name_detail(request, handle, order, action="view"):
elif action == "add":
person = Person.objects.get(handle=handle)
name = Name()
- form = NameForm()
+ name.sort_as = NameFormatType.objects.get(val=0)
+ name.display_as = NameFormatType.objects.get(val=0)
+ name.name_type = NameType.objects.get(val=2) # Birth Name
+ form = NameForm(instance=name)
form.model = name
action = "edit"
elif action == "save":
@@ -153,7 +156,9 @@ def view_name_detail(request, handle, order, action="view"):
name = Name(calendar=0, modifier=0, quality=0,
year1=0, day1=0, month1=0,
sortval = 0, newyear=0, order=order,
- sort_as=0, display_as=0, person_id=person.id)
+ sort_as=NameFormatType(val=0),
+ display_as=NameFormatType(val=0),
+ person_id=person.id)
form = NameForm(request.POST, instance=name)
form.model = name
if form.is_valid():
@@ -276,6 +281,7 @@ def view_detail(request, view, handle):
else:
raise Http404(_("Requested page type not known"))
context[view] = obj
+ context["action"] = "view"
return render_to_response(view_template, context)
def view(request, view):
diff --git a/src/web/init.py b/src/web/init.py
index 99eae0849..0250b5fbd 100644
--- a/src/web/init.py
+++ b/src/web/init.py
@@ -43,7 +43,7 @@ from gen.lib.srcmediatype import SourceMediaType
from gen.lib.eventroletype import EventRoleType
from gen.lib.notetype import NoteType
-from grampsdb.models import GenderType, LdsType, LdsStatus
+from grampsdb.models import GenderType, LdsType, LdsStatus, NameFormatType
def get_datamap(x):
"""
@@ -86,7 +86,8 @@ for table, entries in [("grampsdb.config",
type_models = [MarkerType, NameType, AttributeType, UrlType, ChildRefType,
RepositoryType, EventType, FamilyRelType, SourceMediaType,
- EventRoleType, NoteType, GenderType, LdsType, LdsStatus]
+ EventRoleType, NoteType, GenderType, LdsType, LdsStatus,
+ NameFormatType]
for type in type_models:
count = 1
# Add each code:
diff --git a/src/web/libdjango.py b/src/web/libdjango.py
index 5b0c60578..dd013158a 100644
--- a/src/web/libdjango.py
+++ b/src/web/libdjango.py
@@ -583,7 +583,7 @@ class DjangoInterface(object):
return (name.private, source_list, note_list, date,
name.first_name, name.surname, name.suffix, name.title,
tuple(name.name_type), name.prefix, name.patronymic,
- name.group_as, name.sort_as, name.display_as, name.call)
+ name.group_as, name.sort_as.val, name.display_as.val, name.call)
def pack_location(self, loc, with_parish):
if with_parish:
@@ -1005,8 +1005,8 @@ class DjangoInterface(object):
name.prefix = prefix
name.patronymic = patronymic
name.group_as = group_as
- name.sort_as = sort_as
- name.display_as = display_as
+ name.sort_as = models.get_type(models.NameFormatType, sort_as)
+ name.display_as = models.get_type(models.NameFormatType, display_as)
name.call = call
# we know person exists
# needs to have an ID for key
diff --git a/src/web/settings.py b/src/web/settings.py
index 12f5f8982..d2c97aad6 100644
--- a/src/web/settings.py
+++ b/src/web/settings.py
@@ -26,7 +26,7 @@
import const
import os
-DEBUG = False
+DEBUG = True
TEMPLATE_DEBUG = DEBUG
INTERNAL_IPS = ('127.0.0.1',)
diff --git a/src/web/sqlite.db b/src/web/sqlite.db
index 7baadc36b..b7d627fe6 100644
Binary files a/src/web/sqlite.db and b/src/web/sqlite.db differ
diff --git a/src/web/utils.py b/src/web/utils.py
index 06a7c1237..75eea13ad 100644
--- a/src/web/utils.py
+++ b/src/web/utils.py
@@ -62,9 +62,20 @@ from gen.utils import get_birth_or_fallback, get_death_or_fallback
from gen.plug import BasePluginManager
from cli.grampscli import CLIManager
+util_filters = ['person_event_table', 'person_name_table',
+ 'person_attribute_table',
+ 'person_address_table', 'person_note_table',
+ 'person_gallery_table', 'person_internet_table',
+ 'person_association_table', 'person_lds_table',
+ 'person_reference_table',
+ 'family_children_table', 'family_event_table',
+ 'family_attribute_table',
+ 'family_note_table', 'family_gallery_table',
+ 'family_lds_table',
+ 'nbsp', 'render']
#------------------------------------------------------------------------
#
-# Modeul Constants
+# Module Constants
#
#------------------------------------------------------------------------
dji = libdjango.DjangoInterface()
@@ -216,7 +227,7 @@ def person_name_table(djperson, user):
retval += make_button(_("Add name"), "/person/%s/name/add" % djperson.handle)
return retval
-def person_source_table(djperson, user):
+def source_table(obj, user, action, url=None, *args):
retval = ""
table = Table()
table.columns(_("ID"),
@@ -224,9 +235,9 @@ def person_source_table(djperson, user):
_("Author"),
_("Page"))
if user.is_authenticated():
- obj_type = ContentType.objects.get_for_model(djperson)
+ obj_type = ContentType.objects.get_for_model(obj)
source_refs = dji.SourceRef.filter(object_type=obj_type,
- object_id=djperson.id)
+ object_id=obj.id)
for source_ref in source_refs:
source = table.db.get_source_from_handle(source_ref.ref_object.handle)
table.row(source,
@@ -235,8 +246,8 @@ def person_source_table(djperson, user):
source_ref.page,
)
retval += table.get_html()
- if user.is_authenticated():
- retval += make_button(_("Add source"), "/person/%s/source/add" % djperson.handle)
+ if user.is_authenticated() and url and action != "edit":
+ retval += make_button(_("Add source"), url % args)
return retval
def person_attribute_table(djperson, user):