Added ability to search media by path, descr, and mime type
svn: r20042
This commit is contained in:
parent
daaf25867d
commit
b5bf4a3644
@ -694,7 +694,7 @@ def build_family_query(request, search):
|
|||||||
return query, order, terms
|
return query, order, terms
|
||||||
|
|
||||||
def build_media_query(request, search):
|
def build_media_query(request, search):
|
||||||
terms = ["id"]
|
terms = ["id", "path", "description", "mime"]
|
||||||
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
|
||||||
@ -717,6 +717,12 @@ def build_media_query(request, search):
|
|||||||
query &= Q(**{str(field.replace(".", "__")): value})
|
query &= Q(**{str(field.replace(".", "__")): value})
|
||||||
elif field == "id":
|
elif field == "id":
|
||||||
query &= Q(gramps_id__icontains=value)
|
query &= Q(gramps_id__icontains=value)
|
||||||
|
elif field == "path":
|
||||||
|
query &= Q(path__icontains=value)
|
||||||
|
elif field == "description":
|
||||||
|
query &= Q(desc__icontains=value)
|
||||||
|
elif field == "mime":
|
||||||
|
query &= Q(mime__icontains=value)
|
||||||
else:
|
else:
|
||||||
request.user.message_set.create(message="Invalid query field '%s'" % field)
|
request.user.message_set.create(message="Invalid query field '%s'" % field)
|
||||||
else: # no search fields, just raw search
|
else: # no search fields, just raw search
|
||||||
|
Loading…
Reference in New Issue
Block a user