Commit 5eae6b51 authored by Ryan Herbert's avatar Ryan Herbert
Browse files

models/ add parse_search function

the object is to filter the search bar and and extract tags from
parent c794f187
......@@ -108,3 +108,12 @@ def tags_to_json(tags):
return json.dumps(tag_list)
def parse_search(search_string):
split = search_string.split()
tag_prefix = get_tag_prefix()
plen = len(tag_prefix)
tags = [t[plen:] for t in split if t[:plen] == tag_prefix]
searches = [s for s in split if s[:plen] != tag_prefix]
search_string = " ".join(searches)
return search_string, tags
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment