Don't load references when adding a new record
svn: r19714
This commit is contained in:
parent
2abf41570c
commit
f14b94dd14
@ -406,6 +406,12 @@ class Tag(models.Model):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return str(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
|
def get_url(self):
|
||||||
|
return "/tag/%s" % self.handle
|
||||||
|
|
||||||
|
def get_link(self):
|
||||||
|
return "<a href='%s'>%s</a>" % (self.get_url(), self.name)
|
||||||
|
|
||||||
# Just the following have tag lists:
|
# Just the following have tag lists:
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
#src/gen/lib/family.py
|
#src/gen/lib/family.py
|
||||||
|
@ -555,7 +555,7 @@ def person_reference_table(obj, user, action):
|
|||||||
_("Type"),
|
_("Type"),
|
||||||
_("Reference"),
|
_("Reference"),
|
||||||
_("ID"))
|
_("ID"))
|
||||||
if user.is_authenticated():
|
if user.is_authenticated() and action != "add":
|
||||||
for reference in obj.families.all():
|
for reference in obj.families.all():
|
||||||
table.row(
|
table.row(
|
||||||
_("Family (spouse in)"),
|
_("Family (spouse in)"),
|
||||||
@ -577,7 +577,7 @@ def note_reference_table(obj, user, action):
|
|||||||
_("Type"),
|
_("Type"),
|
||||||
_("Reference"),
|
_("Reference"),
|
||||||
_("ID"))
|
_("ID"))
|
||||||
if user.is_authenticated():
|
if user.is_authenticated() and action != "add":
|
||||||
for reference in models.NoteRef.objects.filter(ref_object=obj):
|
for reference in models.NoteRef.objects.filter(ref_object=obj):
|
||||||
ref_from_class = reference.object_type.model_class()
|
ref_from_class = reference.object_type.model_class()
|
||||||
item = ref_from_class.objects.get(id=reference.object_id)
|
item = ref_from_class.objects.get(id=reference.object_id)
|
||||||
@ -596,7 +596,7 @@ def event_reference_table(obj, user, action):
|
|||||||
_("Type"),
|
_("Type"),
|
||||||
_("Reference"),
|
_("Reference"),
|
||||||
_("ID"))
|
_("ID"))
|
||||||
if user.is_authenticated():
|
if user.is_authenticated() and action != "add":
|
||||||
for reference in models.EventRef.objects.filter(ref_object=obj):
|
for reference in models.EventRef.objects.filter(ref_object=obj):
|
||||||
ref_from_class = reference.object_type.model_class()
|
ref_from_class = reference.object_type.model_class()
|
||||||
item = ref_from_class.objects.get(id=reference.object_id)
|
item = ref_from_class.objects.get(id=reference.object_id)
|
||||||
@ -615,7 +615,7 @@ def repository_reference_table(obj, user, action):
|
|||||||
_("Type"),
|
_("Type"),
|
||||||
_("Reference"),
|
_("Reference"),
|
||||||
_("ID"))
|
_("ID"))
|
||||||
if user.is_authenticated():
|
if user.is_authenticated() and action != "add":
|
||||||
for reference in models.RepositoryRef.objects.filter(ref_object=obj):
|
for reference in models.RepositoryRef.objects.filter(ref_object=obj):
|
||||||
ref_from_class = reference.object_type.model_class()
|
ref_from_class = reference.object_type.model_class()
|
||||||
item = ref_from_class.objects.get(id=reference.object_id)
|
item = ref_from_class.objects.get(id=reference.object_id)
|
||||||
@ -634,7 +634,7 @@ def citation_reference_table(obj, user, action):
|
|||||||
_("Type"),
|
_("Type"),
|
||||||
_("Reference"),
|
_("Reference"),
|
||||||
_("ID"))
|
_("ID"))
|
||||||
if user.is_authenticated():
|
if user.is_authenticated() and action != "add":
|
||||||
for reference in models.CitationRef.objects.filter(citation=obj):
|
for reference in models.CitationRef.objects.filter(citation=obj):
|
||||||
ref_from_class = reference.object_type.model_class()
|
ref_from_class = reference.object_type.model_class()
|
||||||
item = ref_from_class.objects.get(id=reference.object_id)
|
item = ref_from_class.objects.get(id=reference.object_id)
|
||||||
@ -653,7 +653,7 @@ def media_reference_table(obj, user, action):
|
|||||||
_("Type"),
|
_("Type"),
|
||||||
_("Reference"),
|
_("Reference"),
|
||||||
_("ID"))
|
_("ID"))
|
||||||
if user.is_authenticated():
|
if user.is_authenticated() and action != "add":
|
||||||
for reference in models.MediaRef.objects.filter(ref_object=obj):
|
for reference in models.MediaRef.objects.filter(ref_object=obj):
|
||||||
ref_from_class = reference.object_type.model_class()
|
ref_from_class = reference.object_type.model_class()
|
||||||
item = ref_from_class.objects.get(id=reference.object_id)
|
item = ref_from_class.objects.get(id=reference.object_id)
|
||||||
@ -672,7 +672,7 @@ def tag_reference_table(obj, user, action):
|
|||||||
_("Type"),
|
_("Type"),
|
||||||
_("Reference"),
|
_("Reference"),
|
||||||
_("ID"))
|
_("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]
|
querysets = [obj.person_set, obj.family_set, obj.note_set, obj.media_set]
|
||||||
for queryset in querysets:
|
for queryset in querysets:
|
||||||
for item in queryset.all():
|
for item in queryset.all():
|
||||||
@ -775,7 +775,7 @@ def render(formfield, user, action, test=False, truetext="", id=None):
|
|||||||
try:
|
try:
|
||||||
item = getattr(formfield.form.model, fieldname)
|
item = getattr(formfield.form.model, fieldname)
|
||||||
if (item.__class__.__name__ == 'ManyRelatedManager'):
|
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:
|
else:
|
||||||
retval = str(item)
|
retval = str(item)
|
||||||
if retval == "True":
|
if retval == "True":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user