Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a Show Location Types selector to the store locator plugin

  • Loading branch information...
commit 44de1ac83d99824a9505281a8749fbbccf719052 1 parent ead1770
Mark Ransom authored
View
4 store_locator/__init__.py
@@ -1,3 +1,3 @@
-VERSION = (1,8,0)
-__version__ = "1.8.0"
+VERSION = (1,9,0)
+__version__ = "1.9.0"
View
2  store_locator/cms_plugins.py
@@ -15,7 +15,7 @@ class StoreLocatorPlugin(CMSPluginBase):
def render(self, context, instance, placeholder):
get_lat_long_url = reverse('admin:get_lat_long_url')
get_locations_url = reverse('admin:get_locations_url')
- location_types = LocationType.objects.all()
+ location_types = instance.show_location_types.all() or LocationType.objects.all()
context.update({
'get_lat_long_url': get_lat_long_url,
'get_locations_url': get_locations_url,
View
74 store_locator/migrations/0010_auto.py
@@ -0,0 +1,74 @@
+# 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 M2M table for field show_location_types on 'StoreLocator'
+ db.create_table('store_locator_storelocator_show_location_types', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('storelocator', models.ForeignKey(orm['store_locator.storelocator'], null=False)),
+ ('locationtype', models.ForeignKey(orm['store_locator.locationtype'], null=False))
+ ))
+ db.create_unique('store_locator_storelocator_show_location_types', ['storelocator_id', 'locationtype_id'])
+
+
+ def backwards(self, orm):
+
+ # Removing M2M table for field show_location_types on 'StoreLocator'
+ db.delete_table('store_locator_storelocator_show_location_types')
+
+
+ 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': 'True'}),
+ 'show_location_types': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['store_locator.LocationType']", 'null': 'True', 'blank': 'True'}),
+ 'starting_location': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['store_locator']
View
3  store_locator/models.py
@@ -90,5 +90,6 @@ def get_single_line_address(self):
class StoreLocator(CMSPlugin):
default_distance = models.CharField(max_length=50, default='10', choices=DISTANCE_CHOICES)
- starting_location = models.CharField(max_length=255, help_text="A city or address to center the map on.")
+ starting_location = models.CharField(max_length=255, help_text="A city or address to center the map on.", blank=True)
show_distance = models.BooleanField(default=True, help_text='Disabling this will render all locations on the map regardless of zoom level')
+ show_location_types = models.ManyToManyField(LocationType, blank=True, null=True)
View
2  store_locator/static/store_locator/js/store_locator_map.js
@@ -22,7 +22,7 @@ var infoWindow = new google.maps.InfoWindow();
var search_value = '';
$(document).ready(function() {
- //location_search();
+ location_search();
});
document.map = map;
View
11 store_locator/templates/store_locator/store_locator_map.html
@@ -15,16 +15,23 @@
{% endif %}
<input type="submit" onClick="location_search(); return false;" value="Search" />
<ul class="location_types_list">
- {% for type in location_types %}
+ {% for type in instance.show_location_types.all %}
+ <li>
+ <input {% if forloop.first %}checked="checked" {% endif %}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>
+ {% empty %}
+ {% 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 %}
+ {% 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>
+ {% endfor %}
</ul>
</form>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.