From 65e1b85c6f60fb4f5ded7fd417e8c3f79be9ac85 Mon Sep 17 00:00:00 2001
From: Greg Taylor
Date: Tue, 31 Jul 2007 18:39:48 +0000
Subject: [PATCH] Some cosmetics. Also make searching news match against Title
and Body for now. Will eventually have some checkboxes to with the option to
do both or only one.
---
apps/news/views.py | 3 ++-
webtemplates/prosimii/news/search_form.html | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/apps/news/views.py b/apps/news/views.py
index 75fd653d97..ecfb770952 100755
--- a/apps/news/views.py
+++ b/apps/news/views.py
@@ -7,6 +7,7 @@ import django.views.generic.list_detail as gv_list_detail
from django.http import HttpResponseRedirect
from django.contrib.auth.models import User
from django import newforms as forms
+from django.db.models import Q
from apps.news.models import NewsTopic, NewsEntry
@@ -93,7 +94,7 @@ def search_results(request):
valid_search = search_form.is_valid()
cleaned_get = search_form.cleaned_data
- news_entries = NewsEntry.objects.filter(title__contains=cleaned_get['search_terms'])
+ news_entries = NewsEntry.objects.filter(Q(title__contains=cleaned_get['search_terms']) | Q(body__contains=cleaned_get['search_terms']))
pagevars = {
"page_title": "Search Results",
diff --git a/webtemplates/prosimii/news/search_form.html b/webtemplates/prosimii/news/search_form.html
index acf246fdf9..ee546c05da 100644
--- a/webtemplates/prosimii/news/search_form.html
+++ b/webtemplates/prosimii/news/search_form.html
@@ -14,6 +14,6 @@
long.
{% endblock %}
\ No newline at end of file