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

Commit d5d2fb5

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 3804eb4 + 617e571 commit d5d2fb5

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

web/processors/event.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313

1414
def get_client_ip(forwarded=None, remote=None):
15-
16-
if settings.DEBUG:
17-
return '93.103.53.11'
18-
1915
if forwarded:
2016
return forwarded.split(',')[0]
2117
return remote

web/templates/pages/index.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@
4242
</div>
4343
<div class="clearfix">
4444
<div id="search-events-link">
45-
<a class="btn btn-primary btn-lg"
46-
href="{% url 'web.search_events' %}?country_code={{ country.country_code }}&amp;past={{ past }}">
47-
<i class="fa fa-list"></i> List all events {% if country %}in
48-
<span id="country"> {{ country.country_name }}</span>{% endif %}
49-
</a>
45+
{% if country.country_code %}
46+
<a class="btn btn-primary btn-lg"
47+
href="{% url 'web.search_events' %}?country_code={{ country.country_code }}&amp;past={{ past }}">
48+
<i class="fa fa-list"></i> List all events in <span id="country"> {{ country.country_name }}</span>
49+
</a>
50+
{% else %}
51+
<a class="btn btn-primary btn-lg" href="{% url 'web.search_events' %}">
52+
<i class="fa fa-list"></i> List all events
53+
</a>
54+
{% endif %}
5055
</div>
5156
</div>
5257

web/tests/test_event_views.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ def test_nonexistent_event(db, client):
235235

236236
assert response.status_code == 404
237237

238+
@pytest.mark.django_db
239+
def test_geoip_slovenian_ip(db, client):
240+
response = client.get('/', REMOTE_ADDR='93.103.53.1')
241+
242+
assert 'List all events in <span id="country"> Slovenia' in response.content
243+
244+
@pytest.mark.django_db
245+
def test_geoip_invalid_ip(db, client):
246+
response = client.get('/', REMOTE_ADDR='127.0.0.1')
247+
248+
assert 'List all events' in response.content
249+
assert 'List all events <span' not in response.content
250+
238251
@pytest.mark.django_db
239252
def test_list_events_for_country_code(db, client):
240253
response = client.get(reverse('web.view_event_by_country', args=['SI']))

web/views/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def index(request):
5858
country = get_country_from_user_ip(user_ip)
5959

6060
try:
61-
lan_lon = get_lat_lon_from_user_ip(user_ip)
61+
lan_lon = get_lat_lon_from_user_ip(user_ip) or (58.08695, 5.58121)
6262
except GeoIPException:
6363
lan_lon = (58.08695, 5.58121)
6464

0 commit comments

Comments
 (0)