Skip to content

Commit 3a07e5f

Browse files
committed
improved search templates; almost done with this branch !
1 parent fbc6d2e commit 3a07e5f

File tree

5 files changed

+45
-29
lines changed

5 files changed

+45
-29
lines changed

djity/search/views.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from haystack.views import basic_search
44
from haystack.query import SearchQuerySet
5+
from haystack.forms import SearchForm
56

67
from djity.utils.decorators import djity_view
78
from djity.utils.context import DjityContext
@@ -12,7 +13,4 @@ def project_search(request,context=None):
1213
Override haystack basic_view for customization.
1314
"""
1415
sqs = SearchQuerySet().narrow("project:%s"% context['project'].id).narrow("status:%s" % settings.LOWER_VISIBLE_STATUS[context['role']])
15-
#for hidden_status in settings.HIDDEN_STATUSES[context['role']]:
16-
# sqs = sqs.exclude(status=hidden_status)
17-
print sqs
18-
return basic_search(request, template='djity/search/search.html', searchqueryset=sqs, extra_context=context, context_class=DjityContext)
16+
return basic_search(request, template='djity/search/search.html', searchqueryset=sqs, form_class=SearchForm, extra_context=context, context_class=DjityContext)

djity/static/djity/js/djity.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,25 @@ function widgetify() {
163163
$(this).removeClass("ui-state-hover");
164164
}
165165
);
166+
167+
$('#search_query').keypress(function(e) {
168+
if(e.which == 13) {
169+
$("#search_button").click();
170+
}});
171+
172+
$('#search_button')
173+
.addClass("dj-mini-button")
174+
.button({
175+
icons: {
176+
primary: "ui-icon-search"
177+
},
178+
text:false,
179+
})
180+
.click(function(){
181+
query = $("#search_query").val();
182+
project_url = $("#search_button .ui-button-text").text();
183+
window.location.replace(project_url+"/search/?q="+query);
184+
});
166185

167186
$('#messages').notify();
168187

djity/templates/djity/base.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,15 @@
124124
{% endif %}
125125
</div>
126126
</div>
127-
128-
<div id="search_form">
129-
<form method="get" action="{% djiurl project %}/search/">
130-
<input id="search_query" name='q' type="text"></input>
131-
<input type="submit" id="search_button" value="{% trans "Search" %}" />
132-
</form>
133-
</div>
134127

135128
<nav id="portal_parameters" class="ui-helper-hidden">
136129
</nav>
130+
131+
132+
<div id="search_form">
133+
<input id="search_query" name='q' type="text"></input>
134+
<span class="ui-icon ui-icon-search" title="{% trans "Search" %}" id="search_button">{% djiurl project %}</span>
135+
</div>
137136

138137
<nav id="right_tabs" class="ui-helper-hidden" >
139138
{% if perm.manage %}

djity/templates/djity/search/search.html

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,17 @@
22

33
{% load search_result %}
44

5-
{% block body %}
6-
<h2>Search</h2>
7-
8-
<form method="get" action=".">
9-
<table>
10-
{{ form.as_table }}
11-
<tr>
12-
<td>&nbsp;</td>
13-
<td>
14-
<input type="submit" value="Search">
15-
</td>
16-
</tr>
17-
</table>
5+
{% load i18n %}
186

7+
{% block body %}
198
{% if query %}
20-
<h3>Results</h3>
21-
9+
<h3>{% trans "Search results for query" %} "{{ query }}"</h3>
2210
{% for result in page.object_list %}
2311
<p>
2412
{% search_result result %}
2513
</p>
2614
{% empty %}
27-
<p>No results found.</p>
15+
<p>{% trans "No results found." %}</p>
2816
{% endfor %}
2917

3018
{% if page.has_previous or page.has_next %}
@@ -35,7 +23,6 @@ <h3>Results</h3>
3523
</div>
3624
{% endif %}
3725
{% else %}
38-
{# Show some example queries to run, maybe query syntax, something else? #}
26+
{% trans "Submit a query to get some results !"
3927
{% endif %}
40-
</form>
4128
{% endblock %}

djity/templates/djity/style/project.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,19 @@ html>body #main {
217217
float:right;
218218
}
219219

220+
#search_form {
221+
float:right;
222+
padding-right:50px;
223+
}
224+
225+
#search_query {
226+
}
227+
228+
#search_button {
229+
right:32px;
230+
border:none;
231+
background:none;
232+
}
220233

221234
#create_tab_button {
222235
float:right;

0 commit comments

Comments
 (0)