Added references tab for all objects (except family); some fixes on ref editor

svn: r19710
This commit is contained in:
Doug Blank 2012-05-30 15:54:51 +00:00
parent d746cdb0d7
commit 1b87f73f5e
17 changed files with 191 additions and 43 deletions

View File

@ -27,7 +27,9 @@
</table>
</div>
</div>
</form>
{% if user.is_superuser %}
{% make_button "Go to reference" url %}
{% endif %}
{% endblock %}

View File

@ -68,6 +68,7 @@
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-data">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
{% citation_reference_table citation user action %}
</div>
</div>

View File

@ -64,6 +64,7 @@
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-attributes">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-references">
{% event_reference_table event user action %}
</div>
</div>

View File

@ -21,7 +21,7 @@
<td><a href="/{{view}}/{{family.handle|escape}}" class="browsecell">{{family.father|make_name:user|nbsp}}</a>
<td><a href="/{{view}}/{{family.handle|escape}}" class="browsecell">{{family.mother|make_name:user|nbsp}}</a>
{% if user.is_authenticated %}
<td><a href="/{{view}}/{{family.handle|escape}}" class="browsecell">{{family.family_rel_type|escape}}</a>
<td><a href="/{{view}}/{{family.handle|escape}}" class="browsecell">{{family.family_rel_type|escape|nbsp}}</a>
{% else %}
<td><a href="/{{view}}/{{family.handle|escape}}" class="browsecell">[Private]</a>
{% endif %}

View File

@ -53,18 +53,24 @@
<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-sources" style=":hover {color: black;}">Sources</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-attributes">Attributes</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 ui-tabs-hide" id="tabs-1">
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-sources">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-2">
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-notes">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tabs-3">
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-references">
{% media_reference_table media user action %}
</div>
</div>

View File

@ -73,7 +73,7 @@
<li class="ui-corner-top ui-state-default"><a href="#tabs-references">References</a></li>
</ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-references">
{{note.references.all.to_list}}
{% note_reference_table note user action %}
</div>
</div>
</div>

View File

@ -19,8 +19,8 @@
<td><a href="/{{view}}/{{note.handle|escape}}" class="noThumb browsecell">
<span class="grampsid">[{{note.gramps_id}}]</span></a>
{% if user.is_authenticated %}
<td><a href="/{{view}}/{{note.handle|escape}}" class="browsecell">{{note.note_type|escape}}</a>
<td><a href="/{{view}}/{{note.handle|escape}}" class="browsecell">{{note.text|preview:70}}</a>
<td><a href="/{{view}}/{{note.handle|escape}}" class="browsecell">{{note.note_type|escape|nbsp}}</a>
<td><a href="/{{view}}/{{note.handle|escape}}" class="browsecell">{{note.text|preview:70|nbsp}}</a>
{% else %}
<td></td>
<td></td>

View File

@ -124,7 +124,7 @@
{% lds_table person user action "/person/%s/$act/lds" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
{% reference_table person user action "/reference/$act/person/%s" person.handle %}
{% person_reference_table person user action %}
</div>
</div>

View File

@ -18,7 +18,7 @@
<td><a href="/{{view}}/{{place.handle|escape}}" class="noThumb browsecell">
<span class="grampsid">[{{place.gramps_id}}]</span></a>
{% if user.is_authenticated %}
<td><a href="/{{view}}/{{place.handle|escape}}" class="browsecell">{{place.title|escape}}</a>
<td><a href="/{{view}}/{{place.handle|escape}}" class="browsecell">{{place.title|escape|nbsp}}</a>
{% else %}
<td></td>
{% endif %}

View File

@ -20,8 +20,8 @@
<td><a href="/{{view}}/{{repository.handle|escape}}" class="noThumb browsecell">
<span class="grampsid">[{{repository.gramps_id}}]</span></a>
{% if user.is_authenticated %}
<td><a href="/{{view}}/{{repository.handle|escape}}" class="browsecell">{{repository.repository_type|escape}}</a>
<td><a href="/{{view}}/{{repository.handle|escape}}" class="browsecell">{{repository.name|escape}}</a>
<td><a href="/{{view}}/{{repository.handle|escape}}" class="browsecell">{{repository.repository_type|escape|nbsp}}</a>
<td><a href="/{{view}}/{{repository.handle|escape}}" class="browsecell">{{repository.name|escape|nbsp}}</a>
{% else %}
<td></td>
<td></td>

View File

@ -57,6 +57,7 @@
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-notes">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-references">
{% repository_reference_table repository user action %}
</div>
</div>

View File

@ -20,7 +20,7 @@
<td><a href="/{{view}}/{{source.handle|escape}}" class="noThumb browsecell">
<span class="grampsid">[{{source.gramps_id}}]</span></a>
{% if user.is_authenticated %}
<td><a href="/{{view}}/{{source.handle|escape}}" class="browsecell">{{source.title|escape}}</a>
<td><a href="/{{view}}/{{source.handle|escape}}" class="browsecell">{{source.title|escape|nbsp}}</a>
<td><a href="/{{view}}/{{source.handle|escape}}" class="browsecell">{{source.pubinfo|nbsp}}</a>
<td><a href="/{{view}}/{{source.handle|escape}}" class="browsecell">{{source.author|nbsp}}</a>
{% else %}

View File

@ -39,22 +39,12 @@
</tr>
</table>
<!-- Tabs -->
<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-addresses">Addresses</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-internet">Internet</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-notes">Notes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tabs-references">References</a></li>
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-references" style=":hover {color: black;}">References</a></li>
</ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tabs-addresses">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-internet">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-notes">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tabs-references">
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-references">
{% tag_reference_table tag user action %}
</div>
</div>

View File

@ -20,8 +20,8 @@
<td><a href="/{{view}}/{{tag.handle|escape}}" class="noThumb browsecell">
<span class="grampsid">[{{tag.name}}]</span></a>
{% if user.is_authenticated %}
<td><a href="/{{view}}/{{tag.handle}}" class="browsecell">{{tag.color}}</a></td>
<td><a href="/{{view}}/{{tag.handle}}" class="browsecell">{{tag.priority}}</a></td>
<td><a href="/{{view}}/{{tag.handle}}" class="browsecell">{{tag.color|nbsp}}</a></td>
<td><a href="/{{view}}/{{tag.handle}}" class="browsecell">{{tag.priority|nbsp}}</a></td>
{% else %}
<td></td>
<td></td>

View File

@ -436,6 +436,10 @@ class PrimaryObject(models.Model):
return "%s: %s" % (self.__class__.__name__,
self.gramps_id)
def get_url(self):
return "/%s/%s" % (self.__class__.__name__.lower(),
self.handle)
class Person(PrimaryObject):
"""
The model for the person object
@ -535,7 +539,7 @@ class Event(DateObject, PrimaryObject):
object_id_field="object_id")
def __unicode__(self):
return str(self.description)
return str(self.description) or str(self.event_type)
class Repository(PrimaryObject):
repository_type = models.ForeignKey('RepositoryType', verbose_name="Type")

View File

@ -716,7 +716,7 @@ def process_reference(request, ref_by, handle, ref_to, order):
referenced_by = ref_by_class.objects.get(handle=handle)
object_type = ContentType.objects.get_for_model(referenced_by)
ref_to_class = dji.get_model("%sRef" % ref_to.title())
exclude = ["last_changed_by", "last_changed", "object_type", "object_id", "order"]
exclude = ["last_changed_by", "last_changed", "object_type", "object_id", "order", "ref_object"]
if order == "new":
referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id,
object_type=object_type,
@ -734,5 +734,7 @@ def process_reference(request, ref_by, handle, ref_to, order):
context["tviews"] = _('References')
context["object"] = referenced_by
context["handle"] = referenced_by.handle
context["url"] = "/%s/%s" % (referenced_to[0].ref_object.__class__.__name__.lower(),
referenced_to[0].ref_object.handle)
context["action"] = "view"
return render_to_response("reference.html", context)

View File

@ -39,6 +39,7 @@ from HTMLParser import HTMLParser
#------------------------------------------------------------------------
from django.utils.safestring import mark_safe
from django.contrib.contenttypes.models import ContentType
from django.db.models import Q
#------------------------------------------------------------------------
#
@ -89,6 +90,13 @@ util_tags = [
"association_table",
"lds_table",
"reference_table",
"person_reference_table",
"note_reference_table",
"event_reference_table",
"repository_reference_table",
"citation_reference_table",
"media_reference_table",
"tag_reference_table",
"children_table",
"make_button",
]
@ -530,15 +538,148 @@ def lds_table(obj, user, action, url=None, *args):
def reference_table(obj, user, action, url=None, *args):
retval = ""
table = Table()
table.columns(_("Type"),
_("ID"),
_("Name"))
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
references = dji.PersonRef.filter(ref_object=obj)
for reference in references:
table.row(str(reference.ref_object),
reference.ref_object.gramps_id,
make_name(reference.ref_object.name_set, user))
pass
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval
def person_reference_table(obj, user, action):
retval = ""
table = Table()
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
for reference in obj.families.all():
table.row(
_("Family (spouse in)"),
reference,
reference.gramps_id)
for reference in obj.parent_families.all():
table.row(
_("Family (child in)"),
reference,
reference.gramps_id)
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval
def note_reference_table(obj, user, action):
retval = ""
table = Table()
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
for reference in models.NoteRef.objects.filter(ref_object=obj):
ref_from_class = reference.object_type.model_class()
item = ref_from_class.objects.get(id=reference.object_id)
table.row(
item.__class__.__name__,
item,
item.gramps_id)
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval
def event_reference_table(obj, user, action):
retval = ""
table = Table()
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
for reference in models.EventRef.objects.filter(ref_object=obj):
ref_from_class = reference.object_type.model_class()
item = ref_from_class.objects.get(id=reference.object_id)
table.row(
item.__class__.__name__,
item,
item.gramps_id)
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval
def repository_reference_table(obj, user, action):
retval = ""
table = Table()
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
for reference in models.RepositoryRef.objects.filter(ref_object=obj):
ref_from_class = reference.object_type.model_class()
item = ref_from_class.objects.get(id=reference.object_id)
table.row(
item.__class__.__name__,
item,
item.gramps_id)
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval
def citation_reference_table(obj, user, action):
retval = ""
table = Table()
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
for reference in models.CitationRef.objects.filter(citation=obj):
ref_from_class = reference.object_type.model_class()
item = ref_from_class.objects.get(id=reference.object_id)
table.row(
item.__class__.__name__,
item,
item.gramps_id)
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval
def media_reference_table(obj, user, action):
retval = ""
table = Table()
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
for reference in models.MediaRef.objects.filter(ref_object=obj):
ref_from_class = reference.object_type.model_class()
item = ref_from_class.objects.get(id=reference.object_id)
table.row(
item.__class__.__name__,
item,
item.gramps_id)
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval
def tag_reference_table(obj, user, action):
retval = ""
table = Table()
table.columns(
_("Type"),
_("Reference"),
_("ID"))
if user.is_authenticated():
querysets = [obj.person_set, obj.family_set, obj.note_set, obj.media_set]
for queryset in querysets:
for item in queryset.all():
table.row(
item.__class__.__name__,
item,
item.gramps_id)
retval += table.get_html()
retval += nbsp("") # to keep tabs same height
return retval