Django debug support; added table support; add missing DjangoDb funcs; minor css tweaks

svn: r13594
This commit is contained in:
Doug Blank 2009-11-15 22:47:43 +00:00
parent fa21027a23
commit 313bcfa0cd
7 changed files with 332 additions and 67 deletions

View File

@ -198,6 +198,10 @@ a:visited {
margin:0 0 5px 50px;
}
#data {
background-color: white;
}
/* Navigation
----------------------------------------------------- */
#navigation, #subnavigation {

View File

@ -30,16 +30,36 @@
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tabs-1" style=":hover {color: black;}">Sources</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-2">Notes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-3">Gallery</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-3">Attributes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-3">References</a></li>
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-children">Children</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-events">Events</a></li>
<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-attributes">Attributes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-gallery">Gallery</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-lds">LDS</a></li>
</ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-children">
<!-- Events -->
{{ family|family_children_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-events">
{{ 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 }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
{{ family|family_attribute_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-notes">
{{ family|family_note_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery">
{{ family|family_gallery_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-lds">
{{ family|family_lds_table:user|safe }}
</div>
</div>

View File

@ -13,37 +13,34 @@
<div class="content" id="IndividualDetail">
<h3>{{person.name_set|make_name:user}}</h3>
<div id="summaryarea">
<table class="infolist">
<table class="infolist"> {% comment %} 5 cols {% endcomment %}
<tbody>
<tr>
<td class="ColumnAttribute">Family</td>
<td class="ColumnValue">{{person.name_set|preferred:"surname"}}</td>
<td class="ColumnAttribute">Prefix</td>
<td class="ColumnValue">{{person.name_set|preferred:"prefix"}}</td>
<td class="ColumnAttribute">Family:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"surname"}}</td>
<td class="ColumnAttribute">Prefix:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"prefix"}}</td>
<td rowspan="3" colspan="2" style="border:solid 2px #7D5925;">Image:</td>
</tr>
<tr>
<td class="ColumnAttribute">Given</td>
<td class="ColumnValue">{{person.name_set|preferred:"first_name"}}</td>
<td class="ColumnAttribute">Callname</td>
<td class="ColumnValue">{{person.name_set|preferred:"call"}}</td>
<td class="ColumnAttribute">Given:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"first_name"}}</td>
<td class="ColumnAttribute">Call Name:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"call"}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Type</td>
<td class="ColumnValue">{{person.name_set|preferred:"name_type"}}</td>
<td class="ColumnAttribute">Patronymic</td>
<td class="ColumnValue">{{person.name_set|preferred:"patronymic"}}</td>
<td class="ColumnAttribute">Type:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"name_type"}}</td>
<td class="ColumnAttribute">Patronymic:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"patronymic"}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Description</td>
<td class="ColumnValue" spancols="3"></td>
</tr>
<tr>
<td class="ColumnAttribute">ID</td>
<td class="ColumnValue" spancols="3">{{person.gramps_id|escape}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Place</td>
<td class="ColumnValue" spancols="3"></td>
<td class="ColumnAttribute">Gender:</td>
<td class="ColumnValue" id="data">{{person.gender_type|escape}}</td>
<td class="ColumnAttribute">ID:</td>
<td class="ColumnValue" id="data">{{person.gramps_id|escape}}</td>
<td class="ColumnAttribute">Marker:</td>
<td class="ColumnValue" id="data">{{person.marker_type|escape}}</td>
</tr>
</tbody>
</table>
@ -55,40 +52,52 @@
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tabs-1">Events</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-2">Names</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-3">Sources</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-4">Attributes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-5">Notes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-6">Gallery</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-7">Internet</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-8">Associations</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-9">LDS</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-10">References</a></li>
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-events">Events</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-names">Names</a></li>
<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-attributes">Attributes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-addresses">Addresses</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-gallery">Gallery</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-internet">Internet</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-association">Associations</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-lds">LDS</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
</ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tabs-1">
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-events">
<!-- Events -->
{{ person|events_table|safe }}
{{ person|person_event_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-2">
<!-- Names -->
<table border="1">
{% for name in person.name_set.all %}
<tr>
<td>{{forloop.counter}}</td>
<td><a href="/name/{{name.id}}">{{name|make_name:user}}</a></td>
</tr>
{% endfor %}
</table>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-names">
{{ 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 }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
{{ person|person_attribute_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-addresses">
{{ person|person_address_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-notes">
{{ person|person_note_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery">
{{ person|person_gallery_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-internet">
{{ person|person_internet_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-association">
{{ person|person_association_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-lds">
{{ person|person_lds_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
{{ person|person_reference_table:user|safe }}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-3"> table 3 </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-4"> table 4 </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-5"> table 5 </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-6"> table 6 </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-7"> table 7 </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-8"> table 8 </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-9"> table 9 </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-10"> table 10 </div>
</div>

View File

@ -59,6 +59,16 @@ class DjangoDb(GrampsDbBase):
obj.unserialize(self.dji.get_place(self.dji.Place.get(handle=handle)))
return obj
def get_source_from_handle(self, handle):
obj = gen.lib.Source()
obj.unserialize(self.dji.get_source(self.dji.Source.get(handle=handle)))
return obj
def get_note_from_handle(self, handle):
obj = gen.lib.Note()
obj.unserialize(self.dji.get_note(self.dji.Note.get(handle=handle)))
return obj
def get_person_handles(self):
return [person.handle for person in self.dji.Person.all()]

View File

@ -1,10 +1,18 @@
from django.template import escape, Library
from web.utils import *
import web.utils
register = Library()
events_table.is_safe = True
register.filter('events_table', events_table)
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']
for filter_name in util_filters:
func = getattr(web.utils, filter_name)
func.is_safe = True
register.filter(filter_name, func)
person_get_birth_date.is_safe = True
register.filter('person_get_birth_date', person_get_birth_date)

View File

@ -6,6 +6,8 @@ import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
INTERNAL_IPS = ('127.0.0.1',)
ADMINS = (
('admin', 'your_email@domain.com'),
)
@ -35,6 +37,7 @@ MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
)
ROOT_URLCONF = 'web.urls'
@ -60,8 +63,31 @@ INSTALLED_APPS = (
'django.contrib.admin',
'web.grampsdb',
# 'django_extensions',
# 'debug_toolbar',
)
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
)
def custom_show_toolbar(request):
return True # Always show toolbar, for example purposes only.
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': True,
# 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
# 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
'HIDE_DJANGO_SQL': False,
}
# Had to add these to use settings.configure():
DATABASE_OPTIONS = ''
URL_VALIDATOR_USER_AGENT = ''

View File

@ -61,7 +61,7 @@ class Table(object):
_ = lambda text: text
def events_table(djperson):
def person_event_table(djperson, user):
table = Table()
table.columns(_("Description"),
_("Type"),
@ -75,7 +75,6 @@ def events_table(djperson):
object_type=obj_type).order_by("order")
event_list = [(obj.ref_object, obj) for obj in event_ref_list]
for (djevent, event_ref) in event_list:
print djevent.description
table.row(
djevent.description,
table.db.get_event_from_handle(djevent.handle),
@ -85,6 +84,195 @@ def events_table(djperson):
str(event_ref.role_type))
return table.get_html()
def person_name_table(djperson, user):
table = Table()
table.columns(_("Name"),
_("Type"),
_("Group As"),
_("Source"),
_("Note Preview"))
for name in djperson.name_set.all():
obj_type = ContentType.objects.get_for_model(name)
sourceq = dji.SourceRef.filter(object_type=obj_type,
object_id=name.id).count() > 0
note_refs = dji.NoteRef.filter(object_type=obj_type,
object_id=name.id)
note = ""
if note_refs.count() > 0:
note = dji.Note.get(id=note_refs[0].object_id).text[:50]
table.row(make_name(name, user),
str(name.name_type),
name.group_as,
["No", "Yes"][sourceq],
note)
return table.get_html()
def person_source_table(djperson, user):
table = Table()
table.columns(_("ID"),
_("Title"),
_("Author"),
_("Page"))
obj_type = ContentType.objects.get_for_model(djperson)
source_refs = dji.SourceRef.filter(object_type=obj_type,
object_id=djperson.id)
for source_ref in source_refs:
source = table.db.get_source_from_handle(source_ref.ref_object.handle)
table.row(source,
source_ref.ref_object.title,
source_ref.ref_object.author,
source_ref.page,
)
return table.get_html()
def person_attribute_table(djperson, user):
table = Table()
table.columns(_("Type"),
_("Value"),
)
obj_type = ContentType.objects.get_for_model(djperson)
attributes = dji.Attribute.filter(object_type=obj_type,
object_id=djperson.id)
for attribute in attributes:
table.row(attribute.attribute_type.name,
attribute.value)
return table.get_html()
def person_address_table(djperson, user):
table = Table()
table.columns(_("Date"),
_("Address"),
_("City"),
_("State"),
_("Country"))
for address in djperson.address_set.all().order_by("order"):
locations = address.location_set.all().order_by("order")
for location in locations:
table.row(display_date(address),
location.street,
location.city,
location.state,
location.country)
return table.get_html()
def person_note_table(djperson, user):
table = Table()
table.columns(
_("ID"),
_("Type"),
_("Note"))
obj_type = ContentType.objects.get_for_model(djperson)
note_refs = dji.NoteRef.filter(object_type=obj_type,
object_id=djperson.id)
for note_ref in note_refs:
note = table.db.get_note_from_handle(
note_ref.ref_object.handle)
table.row(table.db.get_note_from_handle(note.handle),
str(note_ref.ref_object.note_type),
note_ref.ref_object.text[:50])
return table.get_html()
def person_gallery_table(djperson, user):
table = Table()
table.columns(_("Name"),
_("Type"),
)
return table.get_html()
def person_internet_table(djperson, user):
table = Table()
table.columns(_("Type"),
_("Path"),
_("Description"))
urls = dji.Url.filter(person=djperson)
for url in urls:
table.row(str(url.url_type),
url.path,
url.desc)
return table.get_html()
def person_association_table(djperson, user):
table = Table()
table.columns(_("Name"),
_("ID"),
_("Association"))
gperson = table.db.get_person_from_handle(djperson.handle)
associations = gperson.get_person_ref_list()
for association in associations:
table.row()
return table.get_html()
def person_lds_table(djperson, user):
table = Table()
table.columns(_("Type"),
_("Date"),
_("Status"),
_("Temple"),
_("Place"))
obj_type = ContentType.objects.get_for_model(djperson)
ldss = djperson.lds_set.all().order_by("order")
for lds in ldss:
table.row(str(lds.lds_type),
display_date(lds),
str(lds.status),
lds.temple,
get_title(lds.place))
return table.get_html()
def person_reference_table(djperson, user):
table = Table()
table.columns(_("Type"),
_("ID"),
_("Name"))
references = dji.PersonRef.filter(ref_object=djperson)
for reference in references:
table.row(str(reference.reference_type),
reference.ref_object.gramps_id,
make_name(reference.ref_object))
return table.get_html()
def family_children_table(djfamily, user):
table = Table()
table.columns(_("Column"))
table.row("test")
return table.get_html()
def family_event_table(djfamily, user):
table = Table()
table.columns(_("Column"))
table.row("test")
return table.get_html()
def family_source_table(djfamily, user):
table = Table()
table.columns(_("Column"))
table.row("test")
return table.get_html()
def family_attribute_table(djfamily, user):
table = Table()
table.columns(_("Column"))
table.row("test")
return table.get_html()
def family_note_table(djfamily, user):
table = Table()
table.columns(_("Column"))
table.row("test")
return table.get_html()
def family_gallery_table(djfamily, user):
table = Table()
table.columns(_("Column"))
table.row("test")
return table.get_html()
def family_lds_table(djfamily, user):
table = Table()
table.columns(_("Column"))
table.row("test")
return table.get_html()
## FIXME: these dji function wrappers just use the functions
## written for the import/export. Can be done much more directly.
@ -142,7 +330,7 @@ def make_name(name, user):
return escape("%s, %s" % (surname, "[Living]"))
else:
return escape("%s, %s" % (surname, name.first_name))
elif name:
elif name: # name_set
name = name.get(preferred=True)
if name:
return make_name(name, user)