# Path: cities/conf.py
# ALTERNATIVE_NAME_TYPES = getattr(django_settings, 'CITIES_ALTERNATIVE_NAME_TYPES', _ALTERNATIVE_NAME_TYPES)
# 
# SLUGIFY_FUNCTION = getattr(import_module(module_name), function_name)
# 
# DJANGO_VERSION = float('.'.join(map(str, django.VERSION[:2])))
# 
# Path: cities/managers.py
# class AlternativeNameManager(models.Manager):
#     def get_queryset(self):
#         return super(AlternativeNameManager, self).get_queryset().exclude(kind='link')
# 
# Path: cities/util.py
# def geo_distance(a, b):
# def add_continents(continent_model):
# def default_slugify(obj, value):
# def patterns(prefix, *args):


from random import choice
from string import ascii_uppercase, digits
    from django.utils.encoding import force_unicode as force_text
    from django.utils.encoding import force_text
from django.db import transaction
from django.contrib.gis.db.models import PointField
from django.db import models
from django.contrib.gis.geos import Point
from model_utils import Choices
from .conf import (ALTERNATIVE_NAME_TYPES, SLUGIFY_FUNCTION, DJANGO_VERSION)
from .managers import AlternativeNameManager
from .util import unicode_func
    from django.contrib.gis.db.models import GeoManager
    from django.db.models import Manager as GeoManager
import swapper

__all__ = [
    'Point', 'Continent', 'Country', 'Region', 'Subregion', 'City', 'District',
    'PostalCode', 'AlternativeName',
]


if DJANGO_VERSION < 2:
else:

slugify_func = SLUGIFY_FUNCTION


def SET_NULL_OR_CASCADE(collector, field, sub_objs, using):
    if field.null is True:
        models.SET_NULL(collector, field, sub_objs, using)
    else:
        models.CASCADE(collector, field, sub_objs, using)


class SlugModel(models.Model):
    slug = models.CharField(blank=True, max_length=255, null=True)

    class Meta:
        abstract = True

    def slugify(self):
        raise NotImplementedError("Subclasses of Place must implement slugify()")

    def save(self, *args, **kwargs):

# Path: cities/conf.py
# ALTERNATIVE_NAME_TYPES = getattr(django_settings, 'CITIES_ALTERNATIVE_NAME_TYPES', _ALTERNATIVE_NAME_TYPES)
# 
# SLUGIFY_FUNCTION = getattr(import_module(module_name), function_name)
# 
# DJANGO_VERSION = float('.'.join(map(str, django.VERSION[:2])))
# 
# Path: cities/managers.py
# class AlternativeNameManager(models.Manager):
#     def get_queryset(self):
#         return super(AlternativeNameManager, self).get_queryset().exclude(kind='link')
# 
# Path: cities/util.py
# def geo_distance(a, b):
# def add_continents(continent_model):
# def default_slugify(obj, value):
# def patterns(prefix, *args):


# Path: cities/models.py
from random import choice
from string import ascii_uppercase, digits
    from django.utils.encoding import force_unicode as force_text
    from django.utils.encoding import force_text
from django.db import transaction
from django.contrib.gis.db.models import PointField
from django.db import models
from django.contrib.gis.geos import Point
from model_utils import Choices
from .conf import (ALTERNATIVE_NAME_TYPES, SLUGIFY_FUNCTION, DJANGO_VERSION)
from .managers import AlternativeNameManager
from .util import unicode_func
    from django.contrib.gis.db.models import GeoManager
    from django.db.models import Manager as GeoManager
import swapper


__all__ = [
    'Point', 'Continent', 'Country', 'Region', 'Subregion', 'City', 'District',
    'PostalCode', 'AlternativeName',
]


if DJANGO_VERSION < 2:
else:

slugify_func = SLUGIFY_FUNCTION


def SET_NULL_OR_CASCADE(collector, field, sub_objs, using):
    if field.null is True:
        models.SET_NULL(collector, field, sub_objs, using)
    else:
        models.CASCADE(collector, field, sub_objs, using)


class SlugModel(models.Model):
    slug = models.CharField(blank=True, max_length=255, null=True)

    class Meta:
        abstract = True

    def slugify(self):
        raise NotImplementedError("Subclasses of Place must implement slugify()")

    def save(self, *args, **kwargs):

        self.slug = slugify_func(self, self.slugify())