Webapp: search refinements
svn: r22993
This commit is contained in:
parent
8e8a2b7c6a
commit
4fefbfb647
@ -408,7 +408,7 @@ def view_list(request, view):
|
|||||||
except (EmptyPage, InvalidPage):
|
except (EmptyPage, InvalidPage):
|
||||||
page = paginator.page(paginator.num_pages)
|
page = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
context["search_terms"] = ", ".join(terms)
|
context["search_terms"] = ", ".join(terms) + "; ^start, end$"
|
||||||
context["page"] = page
|
context["page"] = page
|
||||||
context["view"] = view
|
context["view"] = view
|
||||||
context["tview"] = _(view.title())
|
context["tview"] = _(view.title())
|
||||||
@ -621,14 +621,15 @@ def build_person_query(request, search):
|
|||||||
"""
|
"""
|
||||||
protect = not request.user.is_authenticated()
|
protect = not request.user.is_authenticated()
|
||||||
### Build the order:
|
### Build the order:
|
||||||
terms = ["surname", "given", "id", "tag", "public", "private"]
|
|
||||||
if protect:
|
if protect:
|
||||||
# Do this to get the names sorted by private/alive
|
# Do this to get the names sorted by private/alive
|
||||||
# NOTE: names can be private
|
# NOTE: names can be private
|
||||||
|
terms = ["surname", "given", "id", "tag"]
|
||||||
query = Q(private=False) & Q(person__private=False)
|
query = Q(private=False) & Q(person__private=False)
|
||||||
order = ["surname__surname", "private", "person__probably_alive",
|
order = ["surname__surname", "private", "person__probably_alive",
|
||||||
"first_name"]
|
"first_name"]
|
||||||
else:
|
else:
|
||||||
|
terms = ["surname", "given", "id", "tag", "public", "private"]
|
||||||
query = Q()
|
query = Q()
|
||||||
order = ["surname__surname", "first_name"]
|
order = ["surname__surname", "first_name"]
|
||||||
### Build the query:
|
### Build the query:
|
||||||
@ -712,10 +713,9 @@ def build_family_query(request, search):
|
|||||||
Build and return a Django QuerySet and sort order for the Family
|
Build and return a Django QuerySet and sort order for the Family
|
||||||
table.
|
table.
|
||||||
"""
|
"""
|
||||||
terms = ["father", "mother", "id", "type", "surnames", "father.name.first_name",
|
|
||||||
"mother.name.first_name", "tag", "public", "private"]
|
|
||||||
protect = not request.user.is_authenticated()
|
protect = not request.user.is_authenticated()
|
||||||
if protect:
|
if protect:
|
||||||
|
terms = ["father", "mother", "id", "type", "surnames", "tag"]
|
||||||
query = (Q(private=False) & Q(father__private=False) &
|
query = (Q(private=False) & Q(father__private=False) &
|
||||||
Q(mother__private=False))
|
Q(mother__private=False))
|
||||||
order = ["father__name__surname__surname",
|
order = ["father__name__surname__surname",
|
||||||
@ -725,6 +725,8 @@ def build_family_query(request, search):
|
|||||||
"mother__private", "mother__probably_alive",
|
"mother__private", "mother__probably_alive",
|
||||||
"mother__name__first_name"]
|
"mother__name__first_name"]
|
||||||
else:
|
else:
|
||||||
|
terms = ["father", "mother", "id", "type", "surnames", "father.name.first_name",
|
||||||
|
"mother.name.first_name", "tag", "public", "private"]
|
||||||
query = Q()
|
query = Q()
|
||||||
order = ["father__name__surname__surname",
|
order = ["father__name__surname__surname",
|
||||||
"father__name__first_name",
|
"father__name__first_name",
|
||||||
@ -775,16 +777,20 @@ def build_family_query(request, search):
|
|||||||
else:
|
else:
|
||||||
make_message(request, message="Invalid query field '%s'" % field)
|
make_message(request, message="Invalid query field '%s'" % field)
|
||||||
else: # no search fields, just raw search
|
else: # no search fields, just raw search
|
||||||
if protect:
|
if protect: # need to protect!
|
||||||
query &= (Q(gramps_id__icontains=search) |
|
query &= (Q(gramps_id__icontains=search) |
|
||||||
Q(family_rel_type__name__icontains=search) |
|
Q(family_rel_type__name__icontains=search) |
|
||||||
Q(father__name__surname__surname__icontains=search) |
|
Q(father__name__surname__surname__icontains=search) |
|
||||||
Q(mother__name__surname__surname__icontains=search))
|
Q(father__name__first_name__icontains=search) |
|
||||||
|
Q(mother__name__surname__surname__icontains=search) |
|
||||||
|
Q(mother__name__first_name__icontains=search))
|
||||||
else:
|
else:
|
||||||
query &= (Q(gramps_id__icontains=search) |
|
query &= (Q(gramps_id__icontains=search) |
|
||||||
Q(family_rel_type__name__icontains=search) |
|
Q(family_rel_type__name__icontains=search) |
|
||||||
Q(father__name__surname__surname__icontains=search) |
|
Q(father__name__surname__surname__icontains=search) |
|
||||||
Q(mother__name__surname__surname__icontains=search))
|
Q(father__name__first_name__icontains=search) |
|
||||||
|
Q(mother__name__surname__surname__icontains=search) |
|
||||||
|
Q(mother__name__first_name__icontains=search))
|
||||||
else: # no search
|
else: # no search
|
||||||
pass # nothing left to do
|
pass # nothing left to do
|
||||||
#make_message(request, query)
|
#make_message(request, query)
|
||||||
|
Loading…
Reference in New Issue
Block a user