Permalink
Browse files

Moving maps API key to config

  • Loading branch information...
1 parent f2a7824 commit 348e65ba9b48c117817136038673be938633e34f @artshpakov committed Apr 15, 2012
Showing with 8 additions and 2 deletions.
  1. +4 −0 catalog/views.py
  2. +2 −0 settings.py
  3. +1 −1 templates/pages/contacts.html
  4. +1 −1 urls.py
View
@@ -1,8 +1,12 @@
from django.shortcuts import render_to_response, get_object_or_404
+from django.conf import settings
from models import Page, Brand, Category
def product(request, **kwargs):
page = get_object_or_404(Page, slug="products")
brands = Brand.objects.all()
current_brand = filter(lambda brand: brand.slug == kwargs['brand'], brands)[0] if kwargs['brand'] else brands[0]
return render_to_response("pages/products.html", {"object": page, "brands": brands, "brand": current_brand})
+
+def contacts(request):
+ return render_to_response('pages/contacts.html', {"object": get_object_or_404(Page, slug="contacts"), "map_api_key": settings.MAP_API_KEY})
View
@@ -96,4 +96,6 @@
}
}
+MAP_API_KEY = ''
+
from settings_local import *
@@ -4,7 +4,7 @@
{{ block.super }}
<div id="map" style="width:600px;height:400px;"></div>
- <script src="http://api-maps.yandex.ru/1.1/index.xml?key=AF8DZk8BAAAAhNXvHAQAA3_JWzFjcrQ0H6P5FrZ42q5ksxwAAAAAAAAAAACeHlX19trDSnKE1gjSd90Tsk2Krw==" type="text/javascript"></script>
+ <script src="http://api-maps.yandex.ru/1.1/index.xml?key={{ map_api_key }}" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () {
var map = new YMaps.Map(document.getElementById("map"));
View
@@ -9,7 +9,7 @@
urlpatterns = patterns('',
url(r'^/?$', direct_to_template, {"template": 'index.html'}, name="index"),
url(r'^about/?$', object_detail, {"template_name": 'pages/about.html', "queryset": Page.objects.all(), "slug": 'about'}),
- url(r'^contacts/?$', object_detail, {"template_name": 'pages/contacts.html', "queryset": Page.objects.all(), "slug": 'contacts'}),
+ url(r'^contacts/?$', "catalog.views.contacts", name="contacts"),
url(r'^products/(?P<brand>[a-zA-Z0-9-_]+)?$', "catalog.views.product", name="product"),
url(r'^info/?$', object_detail, {"template_name": 'pages/info.html', "queryset": Page.objects.all(), "slug": 'info'}),
url(r'^admin/', include(admin.site.urls)),

0 comments on commit 348e65b

Please sign in to comment.