From f14b94dd14ee4bc483ce6dfd01c799ce506aafb4 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Wed, 30 May 2012 17:14:39 +0000 Subject: [PATCH] Don't load references when adding a new record svn: r19714 --- src/webapp/grampsdb/models.py | 6 ++++++ src/webapp/utils.py | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/webapp/grampsdb/models.py b/src/webapp/grampsdb/models.py index 539002da2..8e0406a25 100644 --- a/src/webapp/grampsdb/models.py +++ b/src/webapp/grampsdb/models.py @@ -406,6 +406,12 @@ class Tag(models.Model): def __unicode__(self): return str(self.name) + def get_url(self): + return "/tag/%s" % self.handle + + def get_link(self): + return "%s" % (self.get_url(), self.name) + # Just the following have tag lists: # --------------------------------- #src/gen/lib/family.py diff --git a/src/webapp/utils.py b/src/webapp/utils.py index b8c26c53a..c1e5b6765 100644 --- a/src/webapp/utils.py +++ b/src/webapp/utils.py @@ -555,7 +555,7 @@ def person_reference_table(obj, user, action): _("Type"), _("Reference"), _("ID")) - if user.is_authenticated(): + if user.is_authenticated() and action != "add": for reference in obj.families.all(): table.row( _("Family (spouse in)"), @@ -577,7 +577,7 @@ def note_reference_table(obj, user, action): _("Type"), _("Reference"), _("ID")) - if user.is_authenticated(): + if user.is_authenticated() and action != "add": 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) @@ -596,7 +596,7 @@ def event_reference_table(obj, user, action): _("Type"), _("Reference"), _("ID")) - if user.is_authenticated(): + if user.is_authenticated() and action != "add": 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) @@ -615,7 +615,7 @@ def repository_reference_table(obj, user, action): _("Type"), _("Reference"), _("ID")) - if user.is_authenticated(): + if user.is_authenticated() and action != "add": 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) @@ -634,7 +634,7 @@ def citation_reference_table(obj, user, action): _("Type"), _("Reference"), _("ID")) - if user.is_authenticated(): + if user.is_authenticated() and action != "add": 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) @@ -653,7 +653,7 @@ def media_reference_table(obj, user, action): _("Type"), _("Reference"), _("ID")) - if user.is_authenticated(): + if user.is_authenticated() and action != "add": 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) @@ -672,7 +672,7 @@ def tag_reference_table(obj, user, action): _("Type"), _("Reference"), _("ID")) - if user.is_authenticated(): + if user.is_authenticated() and action != "add": querysets = [obj.person_set, obj.family_set, obj.note_set, obj.media_set] for queryset in querysets: for item in queryset.all(): @@ -775,7 +775,7 @@ def render(formfield, user, action, test=False, truetext="", id=None): try: item = getattr(formfield.form.model, fieldname) if (item.__class__.__name__ == 'ManyRelatedManager'): - retval = ", ".join([str(i) for i in item.all()]) + retval = ", ".join([i.get_link() for i in item.all()]) else: retval = str(item) if retval == "True":