<commit_before>from django.contrib.gis.db import models
from django.conf import settings
from django.templatetags.l10n import localize
from django.core.urlresolvers import reverse
from django.utils.functional import cached_property
from django import forms

from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as trans

from wagtail.wagtailcore.models import Page, Orderable
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel, FieldRowPanel, \
    MultiFieldPanel, InlinePanel, ObjectList
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsnippets.models import register_snippet

from bitfield import BitField
from location_field.models.spatial import LocationField
from input_mask.widgets import DecimalInputMask
from modelcluster.fields import ParentalKey

from .edit_handlers import ListingTabbedInterface
from .mixins import ListingPageViewMixin
from .widgets import NeighbourhoodWidget, CondominiumWidget


@register_snippet
class City(models.Model):
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)

    panels = [
        FieldPanel('name'),
        FieldPanel('slug'),
        InlinePanel('condominiums', label='Condomínios', panels=[
            FieldRowPanel([
                FieldPanel('name', classname='col6'),
                FieldPanel('slug', classname='col6'),
            ]),<commit_msg>Makes it easier to write fixtures when City handles natural keys<commit_after>from django.contrib.gis.db import models
from django.conf import settings
from django.templatetags.l10n import localize
from django.core.urlresolvers import reverse
from django.utils.functional import cached_property
from django import forms

from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as trans

from wagtail.wagtailcore.models import Page, Orderable
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel, FieldRowPanel, \
    MultiFieldPanel, InlinePanel, ObjectList
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsnippets.models import register_snippet

from bitfield import BitField
from location_field.models.spatial import LocationField
from input_mask.widgets import DecimalInputMask
from modelcluster.fields import ParentalKey

from .edit_handlers import ListingTabbedInterface
from .mixins import ListingPageViewMixin
from .widgets import NeighbourhoodWidget, CondominiumWidget


class CityManager(models.Manager):
    def get_by_natural_key(self, slug):
        return self.get(slug=slug)


@register_snippet
class City(models.Model):
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)

    objects = CityManager()

    """
    Panels
    """
    panels = [
        FieldPanel('name'),
        FieldPanel('slug'),
        InlinePanel('condominiums', label='Condomínios', panels=[
            FieldRowPanel([
                FieldPanel('name', classname='col6'),
                FieldPanel('slug', classname='col6'),
            ]),
{'fraction_non_alphanumeric': 0.06988404888749608, 'fraction_numerical': 0.006267627702914447, 'mean_word_length': 4.751351351351351, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1154352', 'n_tokens_mistral': 929, 'n_tokens_neox': 897, 'n_words': 232}