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

Commit 3c646d9

Browse files
committed
Merge pull request #252 from ialja/past-events
Add the ability to display past events on the map
2 parents 3a82e7b + c16a3a0 commit 3c646d9

File tree

6 files changed

+49
-8
lines changed

6 files changed

+49
-8
lines changed

static/js/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var Codeweek = window.Codeweek || {};
1313
placeinfowindow = null,
1414
overlapSpiderifier = null;
1515

16-
1716
function createMap(events, lat, lng, zoomVal) {
1817
var markerData = JSON.parse(events),
1918
markerData_len = markerData.length,
@@ -212,6 +211,7 @@ var Codeweek = window.Codeweek || {};
212211
$('#country').html(country_name);
213212
}
214213

214+
215215
function initialize(events, lon, lan) {
216216
map = createMap(events, lon, lan, 3);
217217
//setAutocomplete();
@@ -250,6 +250,12 @@ var Codeweek = window.Codeweek || {};
250250
document.location.hash = "!" + country_code;
251251
});
252252

253+
$("#past-link").click(function (event) {
254+
255+
var newUrl = $(this).attr('href') + document.location.hash;
256+
$(this).attr('href', newUrl);
257+
});
258+
253259
$("#zoomEU").click(function (event) {
254260
event.preventDefault();
255261

static/scss/_base.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,30 @@ INDEX PAGE STYLES
138138
padding-left: 0.5em;
139139
padding-right: 0.5em;
140140
}
141+
141142
#showcountries{
142143
background-color: $whitesmoke;
143144
padding-bottom: 25px;
144145
}
146+
147+
#past-events{
148+
position: absolute;
149+
top: 0;
150+
right: 0;
151+
padding-top: 15px;
152+
padding-bottom: 15px;
153+
padding-left: 30px;
154+
padding-right: 25px;
155+
z-index: 0;
156+
border-style: solid;
157+
border-color: $primary-color;
158+
border-width: 0px 0px 2px 2px;
159+
background-color: $whitesmoke;
160+
background: rgba($whitesmoke, 0.8);
161+
font-size: 14px;
162+
@include border-radius(15px);
163+
}
164+
145165
.country-link {
146166
margin: 1em 0;
147167
height: 80px;

static/scss/mixins.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@mixin border-radius($radius) {
2+
-webkit-border-radius: 0 0 0 $radius;
3+
-moz-border-radius: 0 0 0 $radius;
4+
-ms-border-radius: 0 0 0 $radius;
5+
border-radius: 0 0 0 $radius;
6+
}

web/templates/pages/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
</div>
3030

3131
<div class="container index-content">
32+
<div id="past-events">
33+
{% if past == 'yes' %}
34+
<a id="past-link" href="{% url 'web.index' %}"><i class="fa fa-check-square-o"></i>
35+
{% else %}
36+
<a id="past-link" href="{% url 'web.index' %}?past=yes"><i class="fa fa-square-o"></i>
37+
{% endif %}
38+
Show past events</a>
39+
</div>
3240
<div class="clearfix">
3341
<div id="search-events-link">
3442
<a class="btn btn-primary btn-lg"

web/tests/test_event_views.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def test_index_view_without_approved_events(self):
3636
self.assertEquals(200, response.status_code)
3737
self.assertJSONEqual('[]', json.loads(response.context['map_events']))
3838
self.assertEquals((46.0, 15.0), response.context['lan_lon'])
39-
self.assertQuerysetEqual([], response.context['latest_events'])
4039
self.assertTemplateUsed(response, 'pages/index.html')
4140

4241
def test_index_view_changing_remote_in_request(self):
@@ -77,8 +76,6 @@ def test_index_with_approved_events(self):
7776
#assert
7877
self.assertJSONEqual(expected_map_events_result, json.loads(response.context['map_events']))
7978
self.assertEquals('SI', response.context['country']['country_code'])
80-
self.assertEquals(1, len(response.context['latest_events']))
81-
self.assertEquals(aproved.title, response.context['latest_events'][0].title)
8279

8380
def test_view_event_without_picture(self):
8481
#setup

web/views/events.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@
4444

4545
def index(request, country_code=None):
4646
template = 'pages/index.html'
47-
events = get_approved_events()
47+
48+
past = request.GET.get('past', 'no')
49+
if past == 'yes':
50+
events = get_approved_events(past=True)
51+
else:
52+
events = get_approved_events()
53+
4854
map_events = serializers.serialize('json', events, fields=('geoposition', 'title', 'pk', 'slug', 'description', 'picture'))
4955
user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'),
5056
remote=request.META.get('REMOTE_ADDR'))
@@ -56,16 +62,14 @@ def index(request, country_code=None):
5662
except GeoIPException:
5763
lan_lon = (58.08695, 5.58121)
5864

59-
events = get_approved_events(order='pub_date', country_code=country.get('country_code', None))
60-
6165
all_countries = list_countries()
6266
return render_to_response(
6367
template, {
64-
'latest_events': events,
6568
'map_events': map_events,
6669
'lan_lon': lan_lon,
6770
'country': country,
6871
'all_countries': all_countries,
72+
'past': past
6973
},
7074
context_instance=RequestContext(request))
7175

0 commit comments

Comments
 (0)