Basic framework for edit/view forms
svn: r13919
This commit is contained in:
parent
5269f03669
commit
04d5da1939
@ -89,7 +89,7 @@
|
||||
{{ family|family_event_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-sources">
|
||||
{{ family|family_source_table:user|safe }}
|
||||
{{ family|source_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
|
||||
{{ family|family_attribute_table:user|safe }}
|
||||
|
@ -68,9 +68,25 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-sources">Sources</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-general">
|
||||
<table>
|
||||
<tr><td>{{form.group_as.label}}: </td>
|
||||
<td>{{form.group_as|render:action}}</td>
|
||||
</tr>
|
||||
<tr><td>{{form.sort_as.label}}: </td>
|
||||
<td>{{form.sort_as|render:action}}</td>
|
||||
</tr>
|
||||
<tr><td>{{form.display_as.label}}: </td>
|
||||
<td>{{form.display_as|render:action}}</td>
|
||||
</tr>
|
||||
<tr><td>{{form.text.label}}: </td>
|
||||
<td>{{form.text|render:action}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-sources">
|
||||
{% source_table form.model user action "/person/%s/name/%s/source/add" person.handle form.model.order %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-notes">
|
||||
</div>
|
||||
|
@ -6,41 +6,45 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<p id="description">
|
||||
<div id="description" style="padding: 10pt 10pt 10pt 10pt;">
|
||||
<form name="SearchForm">
|
||||
<input type="submit" value="Search:"></input>
|
||||
<input autocomplete="off" name="search" id="get_focus" type="text" size="50" value="{{search}}"></input>
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<span class="step-links">
|
||||
<div id="alphabet" style="padding: 0pt 0 0pt 0;">
|
||||
<ul>
|
||||
{% ifequal page.number 1 %}
|
||||
[first]
|
||||
<li>first</li>
|
||||
{% else %}
|
||||
[<a href="?page=1{{search_query}}">first</a>]
|
||||
<li><a href="?page=1{{search_query}}">first</a></li>
|
||||
{% endifequal %}
|
||||
{% if page.has_previous %}
|
||||
[<a href="?page={{page.previous_page_number}}{{search_query}}">previous</a>]
|
||||
<li><a href="?page={{page.previous_page_number}}{{search_query}}">previous</a></li>
|
||||
{% else %}
|
||||
[previous]
|
||||
<li>previous</li>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
Page {{ page.number }} of {{ page.paginator.num_pages }}
|
||||
<li>Page {{ page.number }} of {{ page.paginator.num_pages }}</li>
|
||||
</span>
|
||||
|
||||
{% if page.has_next %}
|
||||
[<a href="?page={{ page.next_page_number }}{{search_query}}">next</a>]
|
||||
<li><a href="?page={{ page.next_page_number }}{{search_query}}">next</a></li>
|
||||
{% else %}
|
||||
[next]
|
||||
<li>next</li>
|
||||
{% endif %}
|
||||
{% ifequal page.number page.paginator.num_pages %}
|
||||
[last]
|
||||
<li>last</li>
|
||||
{% else %}
|
||||
[<a href="?page={{page.paginator.num_pages}}{{search_query}}">last</a>]
|
||||
<li><a href="?page={{page.paginator.num_pages}}{{search_query}}">last</a></li>
|
||||
{% endifequal %}
|
||||
<b>Matches</b>: {{page.paginator.count}}/{{total}}
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -54,32 +58,36 @@
|
||||
|
||||
<div class="pagination">
|
||||
<span class="step-links">
|
||||
<div id="alphabet" style="padding: 10pt 0 10pt 0;">
|
||||
<ul>
|
||||
{% ifequal page.number 1 %}
|
||||
[first]
|
||||
<li>first</li>
|
||||
{% else %}
|
||||
[<a href="?page=1{{search_query}}">first</a>]
|
||||
<li><a href="?page=1{{search_query}}">first</a></li>
|
||||
{% endifequal %}
|
||||
{% if page.has_previous %}
|
||||
[<a href="?page={{page.previous_page_number}}{{search_query}}">previous</a>]
|
||||
<li><a href="?page={{page.previous_page_number}}{{search_query}}">previous</a></li>
|
||||
{% else %}
|
||||
[previous]
|
||||
<li>previous</li>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
Page {{ page.number }} of {{ page.paginator.num_pages }}
|
||||
<li>Page {{ page.number }} of {{ page.paginator.num_pages }}</li>
|
||||
</span>
|
||||
|
||||
{% if page.has_next %}
|
||||
[<a href="?page={{ page.next_page_number }}{{search_query}}">next</a>]
|
||||
<li><a href="?page={{ page.next_page_number }}{{search_query}}">next</a></li>
|
||||
{% else %}
|
||||
[next]
|
||||
<li>next</li>
|
||||
{% endif %}
|
||||
{% ifequal page.number page.paginator.num_pages %}
|
||||
[last]
|
||||
<li>last</li>
|
||||
{% else %}
|
||||
[<a href="?page={{page.paginator.num_pages}}{{search_query}}">last</a>]
|
||||
<li><a href="?page={{page.paginator.num_pages}}{{search_query}}">last</a></li>
|
||||
{% endifequal %}
|
||||
<b>Matches</b>: {{page.paginator.count}}/{{total}}
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -86,7 +86,7 @@
|
||||
{{ person|person_name_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-sources">
|
||||
{{ person|person_source_table:user|safe }}
|
||||
{% source_table person user action "/person/%s/source/add" person.handle %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
|
||||
{{ person|person_attribute_table:user|safe }}
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -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):
|
||||
|
@ -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),
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -26,7 +26,7 @@
|
||||
import const
|
||||
import os
|
||||
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
INTERNAL_IPS = ('127.0.0.1',)
|
||||
|
Binary file not shown.
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user