Skip to content

Commit

Permalink
Merge pull request #3369 from akvo/issue/3368-update-maps-api
Browse files Browse the repository at this point in the history
[#3368] Use an API key with all maps requests
  • Loading branch information
zzgvh committed Sep 13, 2018
2 parents c773c2e + 4530881 commit 7db8de1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions akvo/rsr/context_processors.py
Expand Up @@ -29,6 +29,7 @@ def extra_context(request, protocol="http"):
deploy_commit_id = getattr(settings, 'DEPLOY_COMMIT_ID', 'Unknown')
deploy_commit_full_id = getattr(settings, 'DEPLOY_COMMIT_FULL_ID', 'Unknown')
sentry_dsn = get_sentry_dsn(settings)
gmaps_api_key = getattr(settings, 'GOOGLE_MAPS_API_KEY', 'NO_API_KEY')

return dict(
current_site=current_site,
Expand All @@ -39,6 +40,7 @@ def extra_context(request, protocol="http"):
deploy_commit_id=deploy_commit_id,
deploy_commit_full_id=deploy_commit_full_id,
sentry_dsn=sentry_dsn,
gmaps_api_key=gmaps_api_key,
)


Expand Down
2 changes: 2 additions & 0 deletions akvo/settings/85-gmaps.conf
@@ -0,0 +1,2 @@
# The security to prevent others from abusing the is on the Google settings side
GOOGLE_MAPS_API_KEY = 'AIzaSyARjGtFp0IV0wANJOjMpQ8jumgbquLR0h8'
2 changes: 1 addition & 1 deletion akvo/templates/inclusion_tags/maps.html
@@ -1,5 +1,5 @@
<div class= "akvo_map" id="{{map_id}}" style="width:{{width}};height:{{height}};"></div>
<script type="text/javascript" src="//maps.google.com/maps/api/js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key={{gmaps_api_key}}"></script>
<script type="text/javascript">
var googleMap = {
canvas: document.getElementById('{{map_id}}'),
Expand Down
3 changes: 1 addition & 2 deletions akvo/templates/organisation_directory.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% load i18n maps rsr_utils bootstrap3 pipeline %}
{% load i18n rsr_utils bootstrap3 pipeline %}
{% block title %}{% trans 'Organisations' %}{% endblock %}
{% block maincontent %}

Expand All @@ -9,7 +9,6 @@

{% block js %}
{{ block.super }}
<script src="//maps.google.com/maps/api/js"></script>
{# Translation strings #}
<script type="application/json" id="organisations-text">
{
Expand Down
5 changes: 1 addition & 4 deletions akvo/templates/organisation_main.html
Expand Up @@ -5,7 +5,7 @@
-->

{% extends "base.html" %}
{% load i18n rsr_filters humanize rsr_utils maps %}
{% load i18n rsr_filters humanize rsr_utils %}
{% block title %}{{ organisation.name }}{% endblock %}
{% block maincontent %}
<div class="container organisationDetail">
Expand Down Expand Up @@ -238,7 +238,4 @@ <h2>{% trans 'Funding' %}</h2>

{% block js %}
{{ block.super }}

{# Google Maps #}
<script src="//maps.google.com/maps/api/js"></script>
{% endblock js %}
5 changes: 2 additions & 3 deletions akvo/templates/project_directory.html
Expand Up @@ -10,9 +10,8 @@
{% block js %}
{{ block.super }}

{# Google Maps API #}
<script src="//maps.google.com/maps/api/js"></script>

{# Google Maps API #}
<script src="https://maps.googleapis.com/maps/api/js?key={{gmaps_api_key}}"></script>
<script type="application/json" id="akvo-rsr-typeahead-thumbs">
{
"numberOfProjects": {{ project_count }}
Expand Down
2 changes: 1 addition & 1 deletion akvo/templates/update_directory.html
Expand Up @@ -10,7 +10,7 @@
{% block js %}
{{ block.super }}

<script src="//maps.google.com/maps/api/js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key={{gmaps_api_key}}"></script>
{# Translation strings #}
<script type="application/json" id="updates-text">
{
Expand Down

0 comments on commit 7db8de1

Please sign in to comment.