Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 8174e45

Browse files
committed
Merge pull request #359 from sparkica/fea_search_get2
Even more search improvements - 2nd attempt :)
2 parents 5f73b01 + 154dfb9 commit 8174e45

File tree

15 files changed

+201
-230
lines changed

15 files changed

+201
-230
lines changed

api/processors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def get_filtered_events(search_filter=None, country_filter=None, theme_filter=No
9999
filter_kwargs['theme__in'] = theme_filter
100100

101101
if audience_filter:
102-
audience = EventAudience.objects.filter()
103102
filter_kwargs['audience__in'] = audience_filter
104103

105104
if len(filter_args) > 0:

static/js/endless_pagination/custom-endless-pagination.js

Lines changed: 0 additions & 118 deletions
This file was deleted.

static/js/faceted-search-events.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ var Codeweek = window.Codeweek || {};
1515

1616
$('.search-form-element').on('change', function (e) {
1717
var container = $('#events-container');
18+
var search_counter_container = $('#search-counter-container');
1819
var data = $('#faceted-search-events').serialize();
1920
var url = $('#faceted-search-events').attr('action');
2021

21-
$.post(url, data, function(fragment) {
22-
container.empty();
23-
container.html(fragment);
24-
});
22+
if (!Modernizr.history) {
23+
document.getElementById('faceted-search-events').submit();
24+
} else {
25+
$("#events-container").html("<img id='loading-gif' src='/static/img/loading.gif'/>");
26+
$('#events-container').load(url + " #events-container", data);
27+
}
2528
});
2629
});
2730
};

static/js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ var Codeweek = window.Codeweek || {};
232232
// Initialize map on front page
233233
google.maps.event.addDomListener(window, 'load', function () {
234234
var ajaxURL = "/api/event/list/?format=json";
235-
if (past == "yes")
236-
ajaxURL = ajaxURL + "&past=yes"
235+
if (past == "on")
236+
ajaxURL = ajaxURL + "&past=on"
237237

238238
$.ajax({
239239
type: "GET",

web/forms/event_form.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ class SearchEventForm(forms.Form):
164164
if not 'Kosovo' in list(dict(countries._countries).values()):
165165
countries._countries.append((u'XK', u'Kosovo'))
166166

167-
search = forms.CharField(
167+
q = forms.CharField(
168168
required=False,
169169
widget=forms.TextInput(attrs={'placeholder': 'Search for event name or tag', 'class': 'form-control'})
170170
)
171-
past_events = forms.BooleanField(
171+
past = forms.BooleanField(
172172
label='Include past events',
173173
required=False,
174174
widget=forms.CheckboxInput(attrs={'class': 'search-form-element'}),
@@ -197,15 +197,18 @@ class SearchEventForm(forms.Form):
197197
def __init__(self, *args, **kwargs):
198198
country_code = kwargs.pop('country_code', None)
199199
past_events = kwargs.pop('past_events', False)
200-
search_query = kwargs.pop('search', None)
200+
search_query = kwargs.pop('q', None)
201+
theme = kwargs.pop('theme', None)
202+
audience = kwargs.pop('audience', None)
203+
201204
super(SearchEventForm, self).__init__(*args, **kwargs)
205+
202206
if country_code:
203207
self.fields['country'].initial = country_code
204-
self.fields['past_events'].initial = past_events
208+
self.fields['past'].initial = past_events
205209
if search_query:
206-
self.fields['search'].initial = search_query
207-
208-
209-
210-
211-
210+
self.fields['q'].initial = search_query
211+
if theme:
212+
self.fields['theme'].initial = theme
213+
if audience:
214+
self.fields['audience'].initial = audience

web/templates/endless/show_more.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load i18n %}
22
{% if querystring %}
3-
<div class="endless_container">
4-
<a class="endless_more" href="{{ path }}{{ querystring }}"
3+
<div class="endless_container col-md-6 col-md-offset-3">
4+
<a class="endless_more btn btn-primary btn-lg btn-block" href="{{ path }}{{ querystring }}"
55
rel="{{ querystring_key }}">{% if label %}{{ label }}{% else %}{% trans "more" %}{% endif %}</a>
66
<div class="endless_loading" style="display: none;">{{ loading|safe }}</div>
77
</div>

web/templates/pages/ajax_faceted_search_events.html renamed to web/templates/pages/faceted_search_results.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{% load endless %}
22

33
{% if events %}
4-
<div class="search-counter">{{ events|length }} {% if events|length > 1 %}events match{% else %}event matches{% endif %} your search criteria:</div>
5-
{% lazy_paginate 6 events as pag_events %}
4+
{% lazy_paginate 10 events as pag_events %}
65
{% for event in pag_events %}
76
{% include 'layout/event_tile_long.html' %}
87
{% endfor %}
@@ -15,4 +14,3 @@ <h3>
1514
</h3>
1615
{% endif %}
1716

18-

web/templates/pages/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@
3333

3434
<div class="container index-content">
3535
<div id="past-events">
36-
{% if past == 'yes' %}
36+
{% if past == 'on' %}
3737
<a id="past-link" href="{% url 'web.index' %}"><i class="fa fa-check-square-o"></i>
3838
{% else %}
39-
<a id="past-link" href="{% url 'web.index' %}?past=yes"><i class="fa fa-square-o"></i>
39+
<a id="past-link" href="{% url 'web.index' %}?past=on"><i class="fa fa-square-o"></i>
4040
{% endif %}
4141
Show past events</a>
4242
</div>
4343
<div class="clearfix">
4444
<div id="search-events-link">
4545
<a class="btn btn-primary btn-lg"
46-
href="{% url 'web.search_events' %}?country_code={{ country.country_code }}&amp;past={{ past }}">
46+
href="{% url 'web.search_events' %}?country={{ country.country_code }}&amp;past={{ past }}">
4747
<i class="fa fa-list"></i> List all events {% if country %}in
4848
<span id="country"> {{ country.country_name }}</span>{% endif %}
4949
</a>

web/templates/pages/scoreboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h1>#codeEU Events Scoreboard</h1>
1111
<img src="/static/flags/{{ country.country_code|lower }}.png" alt="{{ country.country_name }}" />
1212
<span class="icon-flag">
1313
<span class="country-name">{{ country.country_name }}</span> is participating with
14-
<span class="event-number"><a href="{% url 'web.search_events' %}?country_code={{ country.country_code }}&amp;past=yes">{{ country.events }}</span> event{% if country.events != 1 %}s{% endif %}</a>
14+
<span class="event-number"><a href="{% url 'web.search_events' %}?country_code={{ country.country_code }}&amp;past=on">{{ country.events }}</span> event{% if country.events != 1 %}s{% endif %}</a>
1515
</span>
1616
</div>
1717
{% endfor %}

web/templates/pages/search_events.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,41 @@
1111
<div class="container">
1212
<div class="search-page">
1313
<div class="search-options">
14-
<form id="faceted-search-events" method="post" action="{% url 'web.search_events' %}" enctype="multipart/form-data">{% csrf_token %}
14+
<form id="faceted-search-events" method="get" action="{% url 'web.search_events' %}" enctype="multipart/form-data">
1515
{{ form.non_field_errors }}
1616
<div class="row">
17-
<div class="form-group col-md-8">
18-
{{ form.search }}
17+
<div class="form-group col-md-9">
18+
{{ form.q }}
1919
</div>
20+
<div class="col-md-3"><input type="submit" class="btn btn-primary btn-lg" value="Search" /></div>
2021
<div class="col-md-12"><hr></div>
2122
</div>
2223
<div class="row">
2324
<div class="col-md-4">
24-
<label for="id_country">{{ form.fields.country.label }}</label>
25+
<label for="{{ form.country.id_for_label }}">{{ form.fields.country.label }}</label>
2526
{{ form.country }}
26-
2727
<div class="search-checkbox">
2828
<hr>
29-
{{ form.past_events }}
30-
<label for="id_include_past">{{ form.past_events.label }}</label>
29+
{{ form.past }}
30+
<label for="{{ form.past.id_for_label }}">{{ form.past.label }}</label>
3131
</div>
32-
3332
<div class="search-checkbox">
3433
<hr>
3534
<label>{{ form.fields.theme.label }}</label>
3635
{{ form.theme }}
3736
</div>
38-
3937
<div class="search-checkbox">
4038
<hr>
4139
<label>{{ form.fields.audience.label }}</label>
4240
{{ form.audience }}
4341
</div>
4442
<hr>
45-
<input type="submit" class="btn btn-primary btn-lg" value="Search" />
4643
</div>
4744
<div class="col-md-8">
4845
<div id="events-container">
46+
{% if events %}
47+
<div id="search-counter-container" class="search-counter">{{ all_results }} {% if all_results > 1 %}events match{% else %}event matches{% endif %} your search criteria:</span></div>
48+
{% endif %}
4949
{% include page_template %}
5050
</div>
5151
</div>
@@ -58,7 +58,7 @@
5858

5959
{% block custom_js %}
6060
{{ block.super }}
61-
<script type="text/javascript" src="{% static "js/endless_pagination/custom-endless-pagination.js" %}" ></script>
61+
<script type="text/javascript" src="{% static "js/endless_pagination/endless-pagination.js" %}" ></script>
6262
<script type="text/javascript" src="{% static "js/faceted-search-events.js" %}" ></script>
6363
<script type="text/javascript">
6464
Codeweek.FacetedSearch.init();

0 commit comments

Comments
 (0)