Merge pull request #337 from artlepool/master

Allow users to enter a ref number in the search
remotes/origin/enhancement/email-actions
Alejandro 2015-05-26 06:03:34 -07:00
commit 6631f40ef4
1 changed files with 7 additions and 4 deletions

View File

@ -24,6 +24,7 @@ MAX_RESULTS = getattr(settings, "SEARCHES_MAX_RESULTS", 150)
def search_user_stories(project, text): def search_user_stories(project, text):
model_cls = apps.get_model("userstories", "UserStory") model_cls = apps.get_model("userstories", "UserStory")
where_clause = ("to_tsvector(coalesce(userstories_userstory.subject) || ' ' || " where_clause = ("to_tsvector(coalesce(userstories_userstory.subject) || ' ' || "
"coalesce(userstories_userstory.ref) || ' ' || "
"coalesce(userstories_userstory.description)) @@ plainto_tsquery(%s)") "coalesce(userstories_userstory.description)) @@ plainto_tsquery(%s)")
if text: if text:
@ -35,8 +36,9 @@ def search_user_stories(project, text):
def search_tasks(project, text): def search_tasks(project, text):
model_cls = apps.get_model("tasks", "Task") model_cls = apps.get_model("tasks", "Task")
where_clause = ("to_tsvector(coalesce(tasks_task.subject, '') || ' ' || coalesce(tasks_task.description, '')) " where_clause = ("to_tsvector(coalesce(tasks_task.subject, '') || ' ' || "
"@@ plainto_tsquery(%s)") "coalesce(tasks_task.ref) || ' ' || "
"coalesce(tasks_task.description, '')) @@ plainto_tsquery(%s)")
if text: if text:
return (model_cls.objects.extra(where=[where_clause], params=[text]) return (model_cls.objects.extra(where=[where_clause], params=[text])
@ -47,8 +49,9 @@ def search_tasks(project, text):
def search_issues(project, text): def search_issues(project, text):
model_cls = apps.get_model("issues", "Issue") model_cls = apps.get_model("issues", "Issue")
where_clause = ("to_tsvector(coalesce(issues_issue.subject) || ' ' || coalesce(issues_issue.description)) " where_clause = ("to_tsvector(coalesce(issues_issue.subject) || ' ' || "
"@@ plainto_tsquery(%s)") "coalesce(issues_issue.ref) || ' ' || "
"coalesce(issues_issue.description)) @@ plainto_tsquery(%s)")
if text: if text:
return (model_cls.objects.extra(where=[where_clause], params=[text]) return (model_cls.objects.extra(where=[where_clause], params=[text])