Permalink
Browse files

Got the location list working and added Location Types

  • Loading branch information...
Mark Ransom
Mark Ransom committed Feb 29, 2012
1 parent f608e07 commit 339b7d6824fa7ab0d50686710630f64bbc40ef6b
View
@@ -1,6 +1,7 @@
*.pyc
*.vim
*.swp
+*.swo
*.py~
*.html~
*.txt~
View
@@ -1,8 +1,8 @@
from django.contrib import admin, messages
from django.conf.urls.defaults import patterns, url
-from models import Location
+from models import Location, LocationType
from django.conf import settings
-from store_locator.views import get_lat_long
+from store_locator.views import get_lat_long, get_locations
class LocationAdmin(admin.ModelAdmin):
list_display = ('id','name','address','phone', 'url')
@@ -11,7 +11,7 @@ class LocationAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
- 'fields': ('name',)
+ 'fields': ('name','location_type',)
}),
('Address', {
'fields': ('address', ('latitude', 'longitude'))
@@ -26,9 +26,11 @@ class Media:
def get_urls(self):
old_urls = super(LocationAdmin, self).get_urls()
new_urls = patterns('',
- url(r'^get_lat_long/$', get_lat_long)
+ url(r'^get_lat_long/$', get_lat_long, name='get_lat_long_url'),
+ url(r'^get_locations/$', get_locations, name='get_locations_url'),
)
return new_urls + old_urls
admin.site.register(Location, LocationAdmin)
+admin.site.register(LocationType)
@@ -3,7 +3,7 @@
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from django.core.urlresolvers import reverse
-from store_locator.models import StoreLocator
+from store_locator.models import StoreLocator, DISTANCE_CHOICES, LocationType
class StoreLocatorPlugin(CMSPluginBase):
"""Subclass of Text plugin, includes 'topic' & 'css' fields"""
@@ -13,13 +13,15 @@ class StoreLocatorPlugin(CMSPluginBase):
render_template = "store_locator/store_locator_map.html"
def render(self, context, instance, placeholder):
- get_lat_long_url = reverse('store_locator.views.get_lat_long')
- get_locations_url = reverse('store_locator.views.get_locations')
-
+ get_lat_long_url = reverse('admin:get_lat_long_url')
+ get_locations_url = reverse('admin:get_locations_url')
+ location_types = LocationType.objects.all()
context.update({
'get_lat_long_url': get_lat_long_url,
'get_locations_url': get_locations_url,
'instance': instance,
+ 'distance_choices': DISTANCE_CHOICES,
+ 'location_types': location_types,
})
return context
@@ -0,0 +1,73 @@
+# 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):
+
+ # Deleting field 'StoreLocator.distance'
+ db.delete_column('cmsplugin_storelocator', 'distance')
+
+ # Adding field 'StoreLocator.default_distance'
+ db.add_column('cmsplugin_storelocator', 'default_distance', self.gf('django.db.models.fields.CharField')(default='10', max_length=50), keep_default=False)
+
+ # Adding field 'StoreLocator.start_location'
+ db.add_column('cmsplugin_storelocator', 'start_location', self.gf('django.db.models.fields.CharField')(default='', max_length=200, blank=True), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Adding field 'StoreLocator.distance'
+ db.add_column('cmsplugin_storelocator', 'distance', self.gf('django.db.models.fields.IntegerField')(default=25), keep_default=False)
+
+ # Deleting field 'StoreLocator.default_distance'
+ db.delete_column('cmsplugin_storelocator', 'default_distance')
+
+ # Deleting field 'StoreLocator.start_location'
+ db.delete_column('cmsplugin_storelocator', 'start_location')
+
+
+ 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'}),
+ '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.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'}),
+ 'start_location': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['store_locator']
@@ -0,0 +1,81 @@
+# 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):
+
+ # Deleting field 'StoreLocator.start_location'
+ db.delete_column('cmsplugin_storelocator', 'start_location')
+
+ # Adding field 'StoreLocator.address'
+ db.add_column('cmsplugin_storelocator', 'address', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
+
+ # Adding field 'StoreLocator.latitude'
+ db.add_column('cmsplugin_storelocator', 'latitude', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False)
+
+ # Adding field 'StoreLocator.longitude'
+ db.add_column('cmsplugin_storelocator', 'longitude', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Adding field 'StoreLocator.start_location'
+ db.add_column('cmsplugin_storelocator', 'start_location', self.gf('django.db.models.fields.CharField')(default='', max_length=200, blank=True), keep_default=False)
+
+ # Deleting field 'StoreLocator.address'
+ db.delete_column('cmsplugin_storelocator', 'address')
+
+ # Deleting field 'StoreLocator.latitude'
+ db.delete_column('cmsplugin_storelocator', 'latitude')
+
+ # Deleting field 'StoreLocator.longitude'
+ db.delete_column('cmsplugin_storelocator', 'longitude')
+
+
+ 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'}),
+ '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.storelocator': {
+ 'Meta': {'object_name': 'StoreLocator', 'db_table': "'cmsplugin_storelocator'", '_ormbases': ['cms.CMSPlugin']},
+ 'address': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ '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'}),
+ 'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+ 'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['store_locator']
@@ -0,0 +1,79 @@
+# 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):
+
+ # Deleting field 'StoreLocator.longitude'
+ db.delete_column('cmsplugin_storelocator', 'longitude')
+
+ # Deleting field 'StoreLocator.address'
+ db.delete_column('cmsplugin_storelocator', 'address')
+
+ # Deleting field 'StoreLocator.latitude'
+ db.delete_column('cmsplugin_storelocator', 'latitude')
+
+ # Adding field 'StoreLocator.starting_location'
+ db.add_column('cmsplugin_storelocator', 'starting_location', self.gf('django.db.models.fields.CharField')(default='', max_length=255), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Adding field 'StoreLocator.longitude'
+ db.add_column('cmsplugin_storelocator', 'longitude', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False)
+
+ # Adding field 'StoreLocator.address'
+ db.add_column('cmsplugin_storelocator', 'address', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
+
+ # Adding field 'StoreLocator.latitude'
+ db.add_column('cmsplugin_storelocator', 'latitude', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False)
+
+ # Deleting field 'StoreLocator.starting_location'
+ db.delete_column('cmsplugin_storelocator', 'starting_location')
+
+
+ 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'}),
+ '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.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'}),
+ 'starting_location': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['store_locator']
Oops, something went wrong.

0 comments on commit 339b7d6

Please sign in to comment.