Permalink
Browse files

Added cms app hook

  • Loading branch information...
1 parent 5bebb36 commit e14e91cea720bcf32d7d5a2fcf4060afda335bb4 Mark Ransom committed Apr 25, 2012
View
@@ -0,0 +1,12 @@
+"""Applications hooks for cmsplugin_zinnia"""
+from django.utils.translation import ugettext_lazy as _
+
+from cms.app_base import CMSApp
+from cms.apphook_pool import apphook_pool
+
+class StoreLocatorApphook(CMSApp):
+ """Store Locator Apphook"""
+ name = _('Store Locator')
+ urls = ['store_locator.urls']
+
+apphook_pool.register(StoreLocatorApphook)
@@ -0,0 +1,68 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'StoreLocator.show_distance'
+ db.add_column('cmsplugin_storelocator', 'show_distance', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'StoreLocator.show_distance'
+ db.delete_column('cmsplugin_storelocator', 'show_distance')
+
+
+ models = {
+ 'cms.cmsplugin': {
+ 'Meta': {'object_name': 'CMSPlugin'},
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+ 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
+ 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+ },
+ 'cms.placeholder': {
+ 'Meta': {'object_name': 'Placeholder'},
+ 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'store_locator.location': {
+ 'Meta': {'object_name': 'Location'},
+ 'address': ('django.db.models.fields.TextField', [], {'max_length': '255'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
+ 'location_types': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['store_locator.LocationType']", 'null': 'True', 'blank': 'True'}),
+ 'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'phone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
+ },
+ 'store_locator.locationtype': {
+ 'Meta': {'object_name': 'LocationType'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'store_locator.storelocator': {
+ 'Meta': {'object_name': 'StoreLocator', 'db_table': "'cmsplugin_storelocator'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'default_distance': ('django.db.models.fields.CharField', [], {'default': "'10'", 'max_length': '50'}),
+ 'show_distance': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'starting_location': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['store_locator']
@@ -7,6 +7,7 @@ var zoom_list = {
"50" : 9,
"100" : 8,
"500" : 7,
+ "2000" : 4,
}
var markers = new Array;
@@ -21,7 +22,7 @@ var infoWindow = new google.maps.InfoWindow();
var search_value = '';
$(document).ready(function() {
- location_search();
+ //location_search();
});
document.map = map;
@@ -0,0 +1,41 @@
+{% extends "base.html" %}
+{% block content %}
+<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
+
+<div class="locations_search_fields">
+ <form>
+ <input type="text" id="locations_search_field" />
+ <select id="distance_field">
+ {% for distance in distance_choices %}
+ <option value="{{ distance.0 }}" {% if instance.default_distance == distance.0 %}selected="selected"{% endif %}>{{ distance.1 }}</option>
+ {% endfor %}
+ </select>
+ <input type="submit" onClick="location_search(); return false;" value="Search" />
+ <ul class="location_types_list">
+ {% for type in location_types %}
+ <li>
+ <input name="location_type_{{ instance.id }}" type="radio" class="location_type" id="type_{{ type.id }}" value="{{ type.id }}">
+ <label for="type_{{ type.id }}">{{ type.name }}</label>
+ </li>
+ {% endfor %}
+ <li>
+ <input name="location_type_{{ instance.id }}" checked="checked" type="radio" class="location_type" id="type_all" value="">
+ <label for="type_all">All</label>
+ </li>
+ </ul>
+ </form>
+</div>
+<div id="map_canvas" lass="locations_map" style="width:600px; height:400px"></div>
+<ul class="location_list">
+
+</ul>
+<script type="text/javascript">
+ var get_lat_long_url = "{{ get_lat_long_url }}";
+ var get_locations_url = "{{ get_locations_url }}";
+ var starting_location = "wichita, ks";
+ var starting_zoom = 2000;
+</script>
+
+<script type="text/javascript" src="{{ STATIC_URL }}store_locator/js/store_locator_map.js"></script>
+{% endblock%}
View
@@ -2,6 +2,7 @@
from store_locator import views
urlpatterns = patterns('',
- (r'^get_lat_long/$', views.get_lat_long),
- (r'^get_locations/$', views.get_locations),
+ url(r'^get_lat_long/$', views.get_lat_long, name='get_lat_long_url'),
+ url(r'^get_locations/$', views.get_locations, name='get_locations_url'),
+ url(r'^$', views.show_locations),
)
View
@@ -6,7 +6,19 @@
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
-from store_locator.models import Location
+from store_locator.models import StoreLocator, DISTANCE_CHOICES, LocationType, Location
+
+def show_locations(request):
+ get_lat_long_url = reverse('get_lat_long_url')
+ get_locations_url = reverse('get_locations_url')
+ location_types = LocationType.objects.all()
+ params = {
+ 'get_lat_long_url': get_lat_long_url,
+ 'get_locations_url': get_locations_url,
+ 'distance_choices': DISTANCE_CHOICES,
+ 'location_types': location_types,
+ }
+ return render_to_response('store_locator/store_locator_map_view.html', params, context_instance=RequestContext(request))
def get_lat_long(request):
if not request.GET.get('q'):

0 comments on commit e14e91c

Please sign in to comment.