Commits

Mikhail Korobov committed c6021b5

(migrate) longtitude -> longitude

Comments (0)

Files changed (6)

yandex_maps/api.py

 STATIC_MAPS_URL = 'http://static-maps.yandex.ru/1.x/?'
 GEOCODE_URL = 'http://geocode-maps.yandex.ru/1.x/?'
 
-def get_map_url(api_key, longtitude, latitude, zoom, width, height):
+def get_map_url(api_key, longitude, latitude, zoom, width, height):
     ''' returns URL of static yandex map '''
     params = [
-       'll=%0.7f,%0.7f' % (float(longtitude), float(latitude),),
+       'll=%0.7f,%0.7f' % (float(longitude), float(latitude),),
        'size=%d,%d' % (width, height,),
        'z=%d' % zoom,
        'l=map',
-       'pt=%0.7f,%0.7f' % (float(longtitude), float(latitude),),
+       'pt=%0.7f,%0.7f' % (float(longitude), float(latitude),),
        'key=%s' % api_key
     ]
     return STATIC_MAPS_URL + '&'.join(params)

yandex_maps/migrations/0002_rename_longtitude.py

+# -*- coding: 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):
+        db.rename_column('yandex_maps_mapandaddress', 'longtitude', 'longitude')
+
+    def backwards(self, orm):
+        db.rename_column('yandex_maps_mapandaddress', 'longitude', 'longtitude')
+
+    models = {
+        'yandex_maps.mapandaddress': {
+            'Meta': {'object_name': 'MapAndAddress'},
+            'address': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+            'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['yandex_maps']

yandex_maps/models.py

 
 class MapAndAddress(models.Model):
     address = models.CharField(u'Адрес', max_length=255, blank=True, db_index=True)
-    longtitude = models.FloatField(u'Долгота', null=True, blank=True)
+    longitude = models.FloatField(u'Долгота', null=True, blank=True)
     latitude = models.FloatField(u'Широта', null=True, blank=True)
 
     def get_detail_level(self):
         detail_level = int(detail_level) or self.get_detail_level()
 
         if YANDEX_KEY is not None:
-            return api.get_map_url(YANDEX_KEY, self.longtitude, self.latitude, detail_level, w, h)
+            return api.get_map_url(YANDEX_KEY, self.longitude, self.latitude, detail_level, w, h)
         else:
             return ''
 
     def fill_geocode_data(self):
         if YANDEX_KEY is not None:
-            self.longtitude, self.latitude = api.geocode(settings.YANDEX_MAPS_API_KEY, self.address)
+            self.longitude, self.latitude = api.geocode(settings.YANDEX_MAPS_API_KEY, self.address)
 
     def save(self, *args, **kwargs):
         # fill geocode data if it is unknown
-        if self.pk or (self.longtitude is None) or (self.latitude is None):
+        if self.pk or (self.longitude is None) or (self.latitude is None):
             self.fill_geocode_data()
         super(MapAndAddress, self).save(*args, **kwargs)
 

yandex_maps/templates/yandex_maps/map.html

         <script type="text/javascript">
             window.onload = function () {
                 var map = new YMaps.Map(document.getElementById("YMapsID"));
-                var map_center = new YMaps.GeoPoint({{ longtitude }}, {{ latitude }});
+                var map_center = new YMaps.GeoPoint({{ longitude }}, {{ latitude }});
                 map.setCenter(map_center, {{ detail }});
                 map.openBalloon(map_center, "{{ address }}");
 

yandex_maps/views.py

     map = get_object_or_404(MapAndAddress, id=map_id)
     api_key = settings.YANDEX_MAPS_API_KEY
     return direct_to_template(request, 'yandex_maps/map.html', {
-                                 'longtitude': map.longtitude,
+                                 'longitude': map.longitude,
                                  'latitude': map.latitude,
                                  'api_key': api_key,
                                  'detail': 15,

yandex_maps_tests/test_app/fixtures/yandex_maps.json

 [
     {
-        "pk": 1, 
-        "model": "yandex_maps.mapandaddress", 
+        "pk": 1,
+        "model": "yandex_maps.mapandaddress",
         "fields": {
-            "latitude": 56.834544999999999, 
-            "longtitude": 60.611083999999998, 
+            "latitude": 56.834544999999999,
+            "longitude": 60.611083999999998,
             "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0443\u043b \u041c\u0430\u043b\u044b\u0448\u0435\u0432\u0430, 43"
         }
-    }, 
+    },
     {
-        "pk": 2, 
-        "model": "yandex_maps.mapandaddress", 
+        "pk": 2,
+        "model": "yandex_maps.mapandaddress",
         "fields": {
-            "latitude": 55.768718999999997, 
-            "longtitude": 37.597422999999999, 
+            "latitude": 55.768718999999997,
+            "longitude": 37.597422999999999,
             "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u041c\u043e\u0441\u043a\u0432\u0430 \u0438 \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u041c\u043e\u0441\u043a\u0432\u0430, \u0422\u0432\u0435\u0440\u0441\u043a\u0430\u044f, \u0434\u043e\u043c 27, \u043a\u0432. 25"
         }
-    }, 
+    },
     {
-        "pk": 3, 
-        "model": "yandex_maps.mapandaddress", 
+        "pk": 3,
+        "model": "yandex_maps.mapandaddress",
         "fields": {
-            "latitude": 56.85371, 
-            "longtitude": 60.604624999999999, 
+            "latitude": 56.85371,
+            "longitude": 60.604624999999999,
             "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0430, \u0434. 27"
         }
-    }, 
+    },
     {
-        "pk": 9, 
-        "model": "yandex_maps.mapandaddress", 
+        "pk": 9,
+        "model": "yandex_maps.mapandaddress",
         "fields": {
-            "latitude": 56.854581000000003, 
-            "longtitude": 60.603825999999998, 
+            "latitude": 56.854581000000003,
+            "longitude": 60.603825999999998,
             "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0430, \u0434. 27"
         }
-    }, 
+    },
     {
-        "pk": 10, 
-        "model": "yandex_maps.mapandaddress", 
+        "pk": 10,
+        "model": "yandex_maps.mapandaddress",
         "fields": {
-            "latitude": 56.832141999999997, 
-            "longtitude": 60.587854, 
+            "latitude": 56.832141999999997,
+            "longitude": 60.587854,
             "address": "\u0420\u043e\u0441\u0441\u0438\u044f, \u0421\u0432\u0435\u0440\u0434\u043b\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b., \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433, \u041c\u0430\u043b\u044b\u0448\u0435\u0432\u0430, 12"
         }
     }