Webapp: put .distinct() last to remove duplicate matches in queries

svn: r22977
This commit is contained in:
Doug Blank 2013-09-01 02:11:15 +00:00
parent 4a8d98ec2e
commit 8958407097

View File

@ -286,8 +286,8 @@ def view_list(request, view):
query, order, terms = build_event_query(request, search) query, order, terms = build_event_query(request, search)
object_list = Event.objects \ object_list = Event.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_events.html' view_template = 'view_events.html'
total = Event.objects.all().count() total = Event.objects.all().count()
elif view == "media": elif view == "media":
@ -296,8 +296,8 @@ def view_list(request, view):
query, order, terms = build_media_query(request, search) query, order, terms = build_media_query(request, search)
object_list = Media.objects \ object_list = Media.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_media.html' view_template = 'view_media.html'
total = Media.objects.all().count() total = Media.objects.all().count()
elif view == "note": elif view == "note":
@ -306,8 +306,8 @@ def view_list(request, view):
query, order, terms = build_note_query(request, search) query, order, terms = build_note_query(request, search)
object_list = Note.objects \ object_list = Note.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_notes.html' view_template = 'view_notes.html'
total = Note.objects.all().count() total = Note.objects.all().count()
elif view == "person": elif view == "person":
@ -316,8 +316,8 @@ def view_list(request, view):
query, order, terms = build_person_query(request, search) query, order, terms = build_person_query(request, search)
object_list = Name.objects \ object_list = Name.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_people.html' view_template = 'view_people.html'
total = Name.objects.all().count() total = Name.objects.all().count()
elif view == "family": elif view == "family":
@ -326,8 +326,8 @@ def view_list(request, view):
query, order, terms = build_family_query(request, search) query, order, terms = build_family_query(request, search)
object_list = Family.objects \ object_list = Family.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_families.html' view_template = 'view_families.html'
total = Family.objects.all().count() total = Family.objects.all().count()
elif view == "place": elif view == "place":
@ -336,8 +336,8 @@ def view_list(request, view):
query, order, terms = build_place_query(request, search) query, order, terms = build_place_query(request, search)
object_list = Place.objects \ object_list = Place.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_places.html' view_template = 'view_places.html'
total = Place.objects.all().count() total = Place.objects.all().count()
elif view == "repository": elif view == "repository":
@ -346,8 +346,8 @@ def view_list(request, view):
query, order, terms = build_repository_query(request, search) query, order, terms = build_repository_query(request, search)
object_list = Repository.objects \ object_list = Repository.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_repositories.html' view_template = 'view_repositories.html'
total = Repository.objects.all().count() total = Repository.objects.all().count()
elif view == "citation": elif view == "citation":
@ -356,8 +356,8 @@ def view_list(request, view):
query, order, terms = build_citation_query(request, search) query, order, terms = build_citation_query(request, search)
object_list = Citation.objects \ object_list = Citation.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_citations.html' view_template = 'view_citations.html'
total = Citation.objects.all().count() total = Citation.objects.all().count()
elif view == "source": elif view == "source":
@ -366,8 +366,8 @@ def view_list(request, view):
query, order, terms = build_source_query(request, search) query, order, terms = build_source_query(request, search)
object_list = Source.objects \ object_list = Source.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_sources.html' view_template = 'view_sources.html'
total = Source.objects.all().count() total = Source.objects.all().count()
elif view == "tag": elif view == "tag":
@ -376,8 +376,8 @@ def view_list(request, view):
query, order, terms = build_tag_query(request, search) query, order, terms = build_tag_query(request, search)
object_list = Tag.objects \ object_list = Tag.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_tags.html' view_template = 'view_tags.html'
total = Tag.objects.all().count() total = Tag.objects.all().count()
elif view == "report": elif view == "report":
@ -386,8 +386,8 @@ def view_list(request, view):
query, order, terms = build_report_query(request, search) query, order, terms = build_report_query(request, search)
object_list = Report.objects \ object_list = Report.objects \
.filter(query) \ .filter(query) \
.distinct() \ .order_by(*order) \
.order_by(*order) .distinct()
view_template = 'view_report.html' view_template = 'view_report.html'
total = Report.objects.all().count() total = Report.objects.all().count()
else: else: