Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove slug from PostalCode #151

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cities/management/commands/cities.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from ...conf import (city_types, district_types, import_opts, import_opts_all,
HookException, settings, ALTERNATIVE_NAME_TYPES,
CONTINENT_DATA, CURRENCY_SYMBOLS, IGNORE_EMPTY_REGIONS,
INCLUDE_AIRPORT_CODES, NO_LONGER_EXISTENT_COUNTRY_CODES)
INCLUDE_AIRPORT_CODES, NO_LONGER_EXISTENT_COUNTRY_CODES, VALIDATE_POSTAL_CODES)
from ...models import (Region, Subregion, District, PostalCode, AlternativeName)
from ...util import geo_distance

Expand Down Expand Up @@ -553,7 +553,6 @@ def import_district(self):
district.code = item['admin3Code']
except AttributeError:
pass
district.slug = slugify(district.name_std)
district.location = Point(float(item['longitude']), float(item['latitude']))
district.population = int(item['population'])

Expand Down
2 changes: 0 additions & 2 deletions cities/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=200, verbose_name='ascii name', db_index=True)),
('slug', models.CharField(max_length=200)),
('name_std', models.CharField(max_length=200, verbose_name='standard name', db_index=True)),
('location', django.contrib.gis.db.models.fields.PointField(srid=4326)),
('population', models.IntegerField()),
Expand All @@ -92,7 +91,6 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=200, verbose_name='ascii name', db_index=True)),
('slug', models.CharField(max_length=200)),
('code', models.CharField(max_length=20)),
('location', django.contrib.gis.db.models.fields.PointField(srid=4326)),
('region_name', models.CharField(max_length=100, db_index=True)),
Expand Down
10 changes: 0 additions & 10 deletions cities/migrations/0009_add_slug_fields_to_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ class Migration(migrations.Migration):
name='slug',
field=models.CharField(max_length=255, unique=True),
),
migrations.AlterField(
model_name='district',
name='slug',
field=models.CharField(max_length=255, unique=True),
),
migrations.AlterField(
model_name='postalcode',
name='slug',
field=models.CharField(max_length=255, unique=True),
),
migrations.AlterField(
model_name='region',
name='slug',
Expand Down
12 changes: 2 additions & 10 deletions cities/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import uuid

try:
from django.utils.encoding import force_unicode as force_text
Expand All @@ -21,7 +20,6 @@
'PostalCode', 'AlternativeName',
]


if sys.version_info >= (3, 0):
unicode = str

Expand Down Expand Up @@ -195,7 +193,7 @@ class Meta(BaseCity.Meta):
swappable = swapper.swappable_setting('cities', 'City')


class District(Place, SlugModel):
class District(Place):
name_std = models.CharField(max_length=200, db_index=True, verbose_name="standard name")
code = models.CharField(blank=True, db_index=True, max_length=200, null=True)
location = models.PointField()
Expand All @@ -206,9 +204,6 @@ class District(Place, SlugModel):
def parent(self):
return self.city

def slugify(self):
return slugify_func(self, unicode(self.id))


@python_2_unicode_compatible
class AlternativeName(SlugModel):
Expand All @@ -232,7 +227,7 @@ def slugify(self):


@python_2_unicode_compatible
class PostalCode(Place, SlugModel):
class PostalCode(Place):
code = models.CharField(max_length=20)
location = models.PointField()

Expand Down Expand Up @@ -274,6 +269,3 @@ def names(self):

def __str__(self):
return force_text(self.code)

def slugify(self):
return slugify_func(self, unicode(self.id))