Allow events to be searched by desc; added family search on first_name
svn: r20050
This commit is contained in:
@ -608,7 +608,7 @@ def build_person_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "surname":
|
elif field == "surname":
|
||||||
query &= build_string_query("surname__surname", value, exact, startswith, endswith)
|
query &= build_string_query("surname__surname", value, exact, startswith, endswith)
|
||||||
elif field == "given":
|
elif field == "given":
|
||||||
@ -657,7 +657,7 @@ 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"]
|
terms = ["father", "mother", "id", "type", "surnames", "father.name.first_name", "mother.name.first_name"]
|
||||||
protect = not request.user.is_authenticated()
|
protect = not request.user.is_authenticated()
|
||||||
if protect:
|
if protect:
|
||||||
query = (Q(private=False) & Q(father__private=False) &
|
query = (Q(private=False) & Q(father__private=False) &
|
||||||
@ -698,7 +698,7 @@ def build_family_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "surnames":
|
elif field == "surnames":
|
||||||
query &= (build_string_query("father__name__surname__surname", value, exact, startswith, endswith) |
|
query &= (build_string_query("father__name__surname__surname", value, exact, startswith, endswith) |
|
||||||
build_string_query("mother__name__surname__surname", value, exact, startswith, endswith))
|
build_string_query("mother__name__surname__surname", value, exact, startswith, endswith))
|
||||||
@ -760,7 +760,7 @@ def build_media_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
||||||
elif field == "path":
|
elif field == "path":
|
||||||
@ -818,7 +818,7 @@ def build_note_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
||||||
elif field == "type":
|
elif field == "type":
|
||||||
@ -872,7 +872,7 @@ def build_place_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
||||||
elif field == "title":
|
elif field == "title":
|
||||||
@ -922,7 +922,7 @@ def build_repository_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
||||||
elif field == "name":
|
elif field == "name":
|
||||||
@ -978,7 +978,7 @@ def build_citation_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
||||||
else:
|
else:
|
||||||
@ -1024,7 +1024,7 @@ def build_source_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
||||||
else:
|
else:
|
||||||
@ -1070,7 +1070,7 @@ def build_tag_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "name":
|
elif field == "name":
|
||||||
query &= Q(name__icontains=value)
|
query &= Q(name__icontains=value)
|
||||||
else:
|
else:
|
||||||
@ -1117,7 +1117,7 @@ def build_report_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "name":
|
elif field == "name":
|
||||||
query &= Q(name__icontains=value)
|
query &= Q(name__icontains=value)
|
||||||
else:
|
else:
|
||||||
@ -1132,7 +1132,7 @@ def build_report_query(request, search):
|
|||||||
return query, order, terms
|
return query, order, terms
|
||||||
|
|
||||||
def build_event_query(request, search):
|
def build_event_query(request, search):
|
||||||
terms = ["id", "type", "place"]
|
terms = ["id", "type", "place", "description"]
|
||||||
protect = not request.user.is_authenticated()
|
protect = not request.user.is_authenticated()
|
||||||
if protect:
|
if protect:
|
||||||
query = Q(private=False) # general privacy
|
query = Q(private=False) # general privacy
|
||||||
@ -1163,9 +1163,11 @@ def build_event_query(request, search):
|
|||||||
if startswith and endswith:
|
if startswith and endswith:
|
||||||
exact = True
|
exact = True
|
||||||
if "." in field and not protect:
|
if "." in field and not protect:
|
||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
query &= build_string_query("gramps_id", value, exact, startswith, endswith)
|
||||||
|
elif field == "description":
|
||||||
|
query &= build_string_query("desc", value, exact, startswith, endswith)
|
||||||
elif field == "type":
|
elif field == "type":
|
||||||
query &= build_string_query("event_type__name", value, exact, startswith, endswith)
|
query &= build_string_query("event_type__name", value, exact, startswith, endswith)
|
||||||
elif field == "place":
|
elif field == "place":
|
||||||
@ -1175,10 +1177,12 @@ def build_event_query(request, search):
|
|||||||
else: # no search fields, just raw search
|
else: # no search fields, just raw search
|
||||||
if protect:
|
if protect:
|
||||||
query &= (Q(gramps_id__icontains=search) |
|
query &= (Q(gramps_id__icontains=search) |
|
||||||
|
Q(desc__icontains=search) |
|
||||||
Q(event_type__name__icontains=search) |
|
Q(event_type__name__icontains=search) |
|
||||||
Q(place__title__icontains=search))
|
Q(place__title__icontains=search))
|
||||||
else:
|
else:
|
||||||
query &= (Q(gramps_id__icontains=search) |
|
query &= (Q(gramps_id__icontains=search) |
|
||||||
|
Q(desc__icontains=search) |
|
||||||
Q(event_type__name__icontains=search) |
|
Q(event_type__name__icontains=search) |
|
||||||
Q(place__title__icontains=search))
|
Q(place__title__icontains=search))
|
||||||
else: # no search
|
else: # no search
|
||||||
|
Reference in New Issue
Block a user