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

Commit c057fdb

Browse files
committed
Merge pull request #266 from ialja/master
make search aware of past setting
2 parents e96ff14 + 8dfff31 commit c057fdb

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

web/templates/pages/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<div class="clearfix">
4141
<div id="search-events-link">
4242
<a class="btn btn-primary btn-lg"
43-
href="{% url 'web.search_events' %}?country_code={{ country.country_code }}">
43+
href="{% url 'web.search_events' %}?country_code={{ country.country_code }}&amp;past={{ past }}">
4444
<i class="fa fa-list"></i> List all events {% if country %}in
4545
<span id="country"> {{ country.country_name }}</span>{% endif %}
4646
</a>

web/templates/pages/search_events.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,24 @@
5151
{% include 'layout/event_tile_long.html' %}
5252
{% endfor %}
5353

54-
{% show_pages %}
54+
{% get_pages %}
55+
{% if pages.paginated %}
56+
<ul class="pagination">
57+
<li>{{ pages.previous }}</li>
58+
{% for page in pages %}
59+
{% if page.is_current %}
60+
<li class="active endless_page_current">
61+
<a href="#">
62+
{% else %}
63+
<li>
64+
<a href="{% url 'web.search_events' %}?past={% if past %}yes{% else %}no{% endif %}{% if page.url %}&amp;page={{ page.number }}{% endif %}" rel="page" class="endless_page_link">
65+
{% endif %}
66+
{{ page.number }}</a>
67+
</li>
68+
{% endfor %}
69+
<li>{{ pages.next }}</li>
70+
</ul>
71+
{% endif %}
5572

5673
{% else %}
5774
<h3>

web/views/events.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ def search_events(request):
261261
country_code = request.GET.get('country_code', None)
262262
country = get_country(country_code, user_ip)
263263
events = get_approved_events(country_code=country)
264+
265+
is_it_past = request.GET.get('past', 'no')
266+
if is_it_past == 'yes':
267+
past = True
268+
else:
269+
past = False
264270

265271
if request.method == 'POST':
266272
form = SearchEventForm(request.POST)
@@ -274,15 +280,20 @@ def search_events(request):
274280

275281
events = get_filtered_events(search_filter, country_filter, theme_filter, audience_filter, past_events)
276282
country = {'country_code': country_filter}
283+
284+
if past_events:
285+
past = True
286+
277287
else:
278-
form = SearchEventForm(country_code=country['country_code'])
279-
events = get_approved_events(country_code=country['country_code'])
288+
form = SearchEventForm(country_code=country['country_code'],initial={'past_events': past})
289+
events = get_approved_events(country_code=country['country_code'],past=past)
280290

281291
return render_to_response(
282292
'pages/search_events.html', {
283293
'events': events,
284294
'form': form,
285295
'country': country['country_code'],
296+
'past': past,
286297
}, context_instance=RequestContext(request))
287298

288299

0 commit comments

Comments
 (0)