Skip to content

Commit

Permalink
Merge branch 'release/0.9.3'
Browse files Browse the repository at this point in the history
* release/0.9.3: (34 commits)
  bump version number
  fixed broken tests
  fixed broken ``example`` project
  added responsive map as example, ref #53
  better ``TemplateSyntaxError`` exception handling
  added missing tests requirements
  make sure test suite is working...
  Add Google Maps API key configuration
  Fix Google Maps API warning: SensorNotRequired
  add django 1.9
  fix typos in readme
  pep8 cleanup
  improved test suite
  Update .travis.yml
  Update .landscape.yaml
  Update README.rst
  Update README.rst
  Update README.rst
  Update manage.py
  fix backward compatibility with python 2
  ...
  • Loading branch information
bashu committed Nov 11, 2016
2 parents a426959 + f85774a commit 7f5db66
Show file tree
Hide file tree
Showing 22 changed files with 347 additions and 135 deletions.
54 changes: 50 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
\.tox
*\.pyc
MANIFEST
/docs/_build
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
docs/_build/
4 changes: 4 additions & 0 deletions .landscape.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ignore-paths:
- south_migrations
- migrations
- example
29 changes: 11 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
language: python
python:
- "3.4"
- "3.3"
- "3.2"
- "2.7"
- "pypy"
env:
- DJANGO_VERSION=1.4.21
- DJANGO_VERSION=1.5.12
- DJANGO_VERSION=1.6.11
- DJANGO_VERSION=1.7.9
- DJANGO_VERSION=1.8.3
install:
- DJANGO_VERSION=1.4.2
- DJANGO_VERSION=1.5
- DJANGO_VERSION=1.6
- DJANGO_VERSION=1.7
- DJANGO_VERSION=1.8
- DJANGO_VERSION=1.9
before_install:
- pip install -q django==$DJANGO_VERSION
- pip install -q -r example/requirements.txt
install:
- python setup.py develop
script:
- env PYTHONPATH=`pwd` python example/manage.py test easy_maps
- python setup.py test
matrix:
exclude:
- python: "pypy3"
env: DJANGO_VERSION=1.4.21
- python: "3.4"
env: DJANGO_VERSION=1.4.21
- python: "3.3"
env: DJANGO_VERSION=1.4.21
- python: "3.2"
env: DJANGO_VERSION=1.4.21

env: DJANGO_VERSION=1.4.2
11 changes: 8 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
WIP
------------------

- Revert from setuptools back to distutils.
- Russian translation is added.

0.9.2 (2015-07-12)
------------------

- Replacing broken 0.9.1 release, back to setuptools
- Replacing broken 0.9.1 release, back to setuptools.

0.9.1 (2015-07-02)
------------------

- Resolve the 500 error when google send a no results info
- Resolving width / height and other variables in template
- Resolve the 500 error when google send a no results info.
- Resolving width / height and other variables in template.

0.9 (2014-02-11)
----------------
Expand Down
57 changes: 38 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
django-easy-maps
================

This app makes it easy to display a map for given address in django templates.
No API keys, manual geocoding, html/js copy-pasting or django model
changes is needed.
This app makes it easy to display a map for any given address in
`Django <https://www.djangoproject.com>`_ templates.
No API keys, manual geocoding, html/js copy-pasting or Django model
changes are needed.

Authored by `Mikhail Korobov <http://kmike.ru/>`_, and some great
`contributors <https://github.com/kmike/django-easy-maps/contributors>`_.
Expand All @@ -14,12 +15,12 @@ Authored by `Mikhail Korobov <http://kmike.ru/>`_, and some great
.. image:: https://img.shields.io/pypi/dm/django-easy-maps.svg
:target: https://pypi.python.org/pypi/django-easy-maps/

.. image:: https://img.shields.io/github/license/kmike/django-easy-maps.svg
.. image:: https://img.shields.io/github/license/bashu/django-easy-maps.svg
:target: https://pypi.python.org/pypi/django-easy-maps/

.. image:: https://img.shields.io/travis/kmike/django-easy-maps.svg
:target: https://travis-ci.org/kmike/django-easy-maps/
.. image:: https://img.shields.io/travis/bashu/django-easy-maps.svg
:target: https://travis-ci.org/bashu/django-easy-maps/

Installation
------------

Expand All @@ -41,27 +42,45 @@ You'll need to add ``easy_maps`` to ``INSTALLED_APPS`` in your project's ``setti
'south',
)
Then run ``./manage.py syncdb`` to create the required database tables
Then run ``./manage.py migrate`` to create the required database tables.

Upgrading from 0.9
~~~~~~~~~~~~~~~~~~

Upgrading from 0.9 is likely to cause problems trying to apply a
migration when the tables already exist. In this case a fake migration
needs to be applied:

.. code-block:: shell
./manage.py migrate easy_maps 0001 --fake
Configuration
-------------

The only mandatory configuration is the
``EASY_MAPS_GOOGLE_MAPS_API_KEY`` variable:

.. code-block:: python
Configuration (optional)
------------------------
EASY_MAPS_GOOGLE_MAPS_API_KEY = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___0123456789'
If you need a place where center the map when no address is inserted
yet add the latitude and longitude to the ``EASY_MAPS_CENTER`` variable in
If you need a place to center the map at when no address is inserted
yet, add the latitude and longitude to the ``EASY_MAPS_CENTER`` variable in
your ``settings.py`` like the following:

.. code-block:: python
EASY_MAPS_CENTER = (-41.3, 32)
To use a custom geocoder set ``EASY_MAPS_GEOCODE`` option:
To use a custom geocoder set the ``EASY_MAPS_GEOCODE`` option:

.. code-block:: python
# Default: 'easy_maps.geocode.google_v3'
EASY_MAPS_GEOCODE = 'example.custom_geocode'
Please see ``example`` application. This application is used to
Please see the ``example`` application. This application is used to
manually test the functionalities of this package. This also serves as
a good example.

Expand Down Expand Up @@ -109,7 +128,7 @@ later in order to prevent DB access on each map render:
Templates
---------

If the default map template is not sufficient then custom map template can be
If the default map template is not sufficient then a custom map template can be
used. For example:

.. code-block:: html+django
Expand All @@ -119,20 +138,20 @@ used. For example:

The template will have ``map`` (``easy_maps.Address`` instance
auto-created for passed address on first access), ``width``, ``height``
and ``zoom`` variables. The outer template context is passed to rendered
and ``zoom`` variables. The outer template context is passed to the rendered
template as well.

You can start your own template from scratch or just override some blocks in the
default template.

Please refer to http://code.google.com/apis/maps/documentation/javascript/ for
Please refer to https://developers.google.com/maps/documentation/javascript/ for
detailed Google Maps JavaScript API help.

Widgets
-------

``django-easy-maps`` provides basic widget that displays a map under the address
field. It can be used in admin for map previews. For example:
``django-easy-maps`` provides a basic widget that displays a map under the address
field. It can be used in the admin for map previews. For example:

.. code-block:: python
Expand Down
4 changes: 3 additions & 1 deletion easy_maps/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = '0.9.2'
VERSION = (0, 9, 3)

__version__ = '.'.join([str(n) for n in VERSION])
2 changes: 1 addition & 1 deletion easy_maps/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class AddressAdmin(admin.ModelAdmin):
list_display = [
'address', 'computed_address', 'latitude', 'longitude', 'geocode_error']
'address', 'computed_address', 'latitude', 'longitude']
list_filter = ['geocode_error']
search_fields = ['address']

Expand Down
1 change: 1 addition & 0 deletions easy_maps/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class EasyMapsSettings(AppConf):
CENTER = (-41.3, 32)
GEOCODE = 'easy_maps.geocode.google_v3'
GOOGLE_MAPS_API_KEY = None

class Meta:
prefix = 'easy_maps'
Expand Down
Binary file modified easy_maps/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
13 changes: 6 additions & 7 deletions easy_maps/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
# This file is distributed under the same license as the PACKAGE package.
# Sebastian Rahlf <[email protected]>, 2013.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Project-Id-Version: django-easy-maps\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-06-30 20:59+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Sebastian Rahlf <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"PO-Revision-Date: 2015-08-07 14:36+0500\n"
"Last-Translator: Basil Shubin <[email protected]>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.7\n"

#: models.py:14
msgid "Address"
Expand Down
Binary file added easy_maps/locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
47 changes: 47 additions & 0 deletions easy_maps/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: django-easy-maps\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-08-07 14:19+0600\n"
"PO-Revision-Date: 2015-08-07 14:39+0500\n"
"Last-Translator: Basil Shubin <[email protected]>\n"
"Language-Team: <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Poedit 1.5.7\n"

#: models.py:40
msgid "address"
msgstr "адрес"

#: models.py:44
msgid "computed address"
msgstr "вычисленный адрес"

#: models.py:45
msgid "latitude"
msgstr "широта"

#: models.py:46
msgid "longitude"
msgstr "долгота"

#: models.py:49
msgid "geocode error"
msgstr "ошибка геокодирования"

#: models.py:54
msgid "EasyMaps Address"
msgstr "Адрес"

#: models.py:55
msgid "Address Geocoding Cache"
msgstr "Адреса"
17 changes: 10 additions & 7 deletions easy_maps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import collections

from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

from . import geocode
Expand All @@ -30,31 +31,34 @@ def for_address(self, address):
try:
logger.error(e)
except Exception:
logger.error("Geocoding error for address '%s'", address)
logger.error(
"Geocoding error for address '%s'", address)

return None



@python_2_unicode_compatible
class Address(models.Model):

address = models.CharField(_('address'), max_length=255, unique=True)

# for internal use...

computed_address = models.CharField(_('computed address'), max_length=255, null=True, blank=True)

computed_address = models.CharField(
_('computed address'), max_length=255, null=True, blank=True)
latitude = models.FloatField(_('latitude'), null=True, blank=True)
longitude = models.FloatField(_('longitude'), null=True, blank=True)

# TODO: replace this crap with something better
geocode_error = models.BooleanField(_('geocode error'), default=False)

objects = AddressManager()

class Meta:
verbose_name = _("EasyMaps Address")
verbose_name_plural = _("Address Geocoding Cache")

def __unicode__(self):
def __str__(self):
return self.address

def save(self, *args, **kwargs):
Expand All @@ -65,4 +69,3 @@ def save(self, *args, **kwargs):
else: # TODO: replace this crap with something better
self.computed_address = None
super(Address, self).save(*args, **kwargs)

Loading

0 comments on commit 7f5db66

Please sign in to comment.