diff --git a/src/data/templates/reference.html b/src/data/templates/reference.html index cd01fc480..3189010dd 100644 --- a/src/data/templates/reference.html +++ b/src/data/templates/reference.html @@ -27,7 +27,9 @@ - +{% if user.is_superuser %} + {% make_button "Go to reference" url %} +{% endif %} {% endblock %} diff --git a/src/data/templates/view_citation_detail.html b/src/data/templates/view_citation_detail.html index b4d418174..c16effc80 100644 --- a/src/data/templates/view_citation_detail.html +++ b/src/data/templates/view_citation_detail.html @@ -68,6 +68,7 @@
+ {% citation_reference_table citation user action %}
diff --git a/src/data/templates/view_event_detail.html b/src/data/templates/view_event_detail.html index b48e42317..393b30ee7 100644 --- a/src/data/templates/view_event_detail.html +++ b/src/data/templates/view_event_detail.html @@ -64,6 +64,7 @@
+ {% event_reference_table event user action %}
diff --git a/src/data/templates/view_families.html b/src/data/templates/view_families.html index f7f24d012..7d7888d34 100644 --- a/src/data/templates/view_families.html +++ b/src/data/templates/view_families.html @@ -21,7 +21,7 @@ {{family.father|make_name:user|nbsp}} {{family.mother|make_name:user|nbsp}} {% if user.is_authenticated %} - {{family.family_rel_type|escape}} + {{family.family_rel_type|escape|nbsp}} {% else %} [Private] {% endif %} diff --git a/src/data/templates/view_media_detail.html b/src/data/templates/view_media_detail.html index 8e31bbb2d..8031b6df2 100644 --- a/src/data/templates/view_media_detail.html +++ b/src/data/templates/view_media_detail.html @@ -53,18 +53,24 @@
-
+
-
+
-
+ + +
+
+
+ {% media_reference_table media user action %}
diff --git a/src/data/templates/view_note_detail.html b/src/data/templates/view_note_detail.html index 5cd756729..64e3f1488 100644 --- a/src/data/templates/view_note_detail.html +++ b/src/data/templates/view_note_detail.html @@ -73,7 +73,7 @@
  • References
  • - {{note.references.all.to_list}} + {% note_reference_table note user action %}
    diff --git a/src/data/templates/view_notes.html b/src/data/templates/view_notes.html index f39a6f17b..c8e116af1 100644 --- a/src/data/templates/view_notes.html +++ b/src/data/templates/view_notes.html @@ -19,8 +19,8 @@ [{{note.gramps_id}}] {% if user.is_authenticated %} - {{note.note_type|escape}} - {{note.text|preview:70}} + {{note.note_type|escape|nbsp}} + {{note.text|preview:70|nbsp}} {% else %} diff --git a/src/data/templates/view_person_detail.html b/src/data/templates/view_person_detail.html index c5d5c6a10..40e50ab74 100644 --- a/src/data/templates/view_person_detail.html +++ b/src/data/templates/view_person_detail.html @@ -124,7 +124,7 @@ {% lds_table person user action "/person/%s/$act/lds" person.handle %}
    - {% reference_table person user action "/reference/$act/person/%s" person.handle %} + {% person_reference_table person user action %}
    diff --git a/src/data/templates/view_places.html b/src/data/templates/view_places.html index ff944663c..d67e72e71 100644 --- a/src/data/templates/view_places.html +++ b/src/data/templates/view_places.html @@ -18,7 +18,7 @@ [{{place.gramps_id}}] {% if user.is_authenticated %} - {{place.title|escape}} + {{place.title|escape|nbsp}} {% else %} {% endif %} diff --git a/src/data/templates/view_repositories.html b/src/data/templates/view_repositories.html index 01b528ffa..c660910cc 100644 --- a/src/data/templates/view_repositories.html +++ b/src/data/templates/view_repositories.html @@ -20,8 +20,8 @@ [{{repository.gramps_id}}] {% if user.is_authenticated %} - {{repository.repository_type|escape}} - {{repository.name|escape}} + {{repository.repository_type|escape|nbsp}} + {{repository.name|escape|nbsp}} {% else %} diff --git a/src/data/templates/view_repository_detail.html b/src/data/templates/view_repository_detail.html index 32c605625..7d62ec385 100644 --- a/src/data/templates/view_repository_detail.html +++ b/src/data/templates/view_repository_detail.html @@ -57,6 +57,7 @@
    + {% repository_reference_table repository user action %}
    diff --git a/src/data/templates/view_sources.html b/src/data/templates/view_sources.html index 22f889140..965cd39f2 100644 --- a/src/data/templates/view_sources.html +++ b/src/data/templates/view_sources.html @@ -20,7 +20,7 @@ [{{source.gramps_id}}] {% if user.is_authenticated %} - {{source.title|escape}} + {{source.title|escape|nbsp}} {{source.pubinfo|nbsp}} {{source.author|nbsp}} {% else %} diff --git a/src/data/templates/view_tag_detail.html b/src/data/templates/view_tag_detail.html index 7cba84c23..6f5b29080 100644 --- a/src/data/templates/view_tag_detail.html +++ b/src/data/templates/view_tag_detail.html @@ -39,22 +39,12 @@ - -
    -
    -
    -
    -
    -
    -
    -
    +
    + {% tag_reference_table tag user action %}
    diff --git a/src/data/templates/view_tags.html b/src/data/templates/view_tags.html index 68824a44f..2da8dddac 100644 --- a/src/data/templates/view_tags.html +++ b/src/data/templates/view_tags.html @@ -20,8 +20,8 @@ [{{tag.name}}] {% if user.is_authenticated %} - {{tag.color}} - {{tag.priority}} + {{tag.color|nbsp}} + {{tag.priority|nbsp}} {% else %} diff --git a/src/webapp/grampsdb/models.py b/src/webapp/grampsdb/models.py index bc641bc2c..539002da2 100644 --- a/src/webapp/grampsdb/models.py +++ b/src/webapp/grampsdb/models.py @@ -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") diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py index 85cb27fa7..884f1df8b 100644 --- a/src/webapp/grampsdb/views.py +++ b/src/webapp/grampsdb/views.py @@ -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) diff --git a/src/webapp/utils.py b/src/webapp/utils.py index 0b93bf121..b8c26c53a 100644 --- a/src/webapp/utils.py +++ b/src/webapp/utils.py @@ -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