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

[WIP] Boundary Fields #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,6 @@ Data will only be downloaded/imported if it is newer than your data, and only ma

The cities manage command has options, see `--help`. Verbosity is controlled through the `LOGGING` setting.



## Running Tests

1. Install postgres, postgis and libgdal-dev
Expand All @@ -549,6 +547,23 @@ The cities manage command has options, see `--help`. Verbosity is controlled th
# changes to github and specify commit and repo variables:
TRAVIS_COMMIT=`git rev-parse HEAD` TRAVIS_REPO_SLUG='github-username/django-cities' POSTGRES_USER=some_username POSTGRES_PASSWORD='password from createuser ste' tox

## Running Django command

If you need to run django comamnds, like ```makemigrations``` or ```makemessages``` (I guess the next step is
to make the software more compatible with other languages), you can do so easily, by configuring a few environment
variables **before** the actual command, like so:

```bash
cd django-cities/
POSTGRES_USER=<postgres_user> POSTGRES_PASSWORD=<postgres_pass> PYTHONPATH=. python test_project/manage.py makemigrations cities
```

A few things should be noted:

1. The ```cd``` command should point at the repository root;
1. The ```<postgres_user>``` and ```<postgres_pass>``` are placeholders. That mean that you should substitute
them for the actual values of your database.

#### Useful test options:

* `TRAVIS_LOG_LEVEL` - defaults to `INFO`, but set to `DEBUG` to see a (very) large and (very) complete log of the import script
Expand Down
51 changes: 51 additions & 0 deletions cities/migrations/0011_auto_20170126_1717.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-26 17:17
from __future__ import unicode_literals

import django.contrib.gis.db.models.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('cities', '0010_adjust_unique_attributes'),
]

operations = [
migrations.AddField(
model_name='city',
name='boundary',
field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
),
migrations.AddField(
model_name='continent',
name='boundary',
field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
),
migrations.AddField(
model_name='country',
name='boundary',
field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
),
migrations.AddField(
model_name='district',
name='boundary',
field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
),
migrations.AddField(
model_name='postalcode',
name='boundary',
field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
),
migrations.AddField(
model_name='region',
name='boundary',
field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
),
migrations.AddField(
model_name='subregion',
name='boundary',
field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
),
]
8 changes: 4 additions & 4 deletions cities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class Place(models.Model):
name = models.CharField(max_length=200, db_index=True, verbose_name="ascii name")
alt_names = models.ManyToManyField('AlternativeName')

boundary = models.MultiPolygonField(null=True)

objects = models.GeoManager()

class Meta:
Expand Down Expand Up @@ -86,6 +88,8 @@ def save(self, *args, **kwargs):
class BaseContinent(Place, SlugModel):
code = models.CharField(max_length=2, unique=True, db_index=True)

objects = models.GeoManager()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obsolete now!


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

Expand Down Expand Up @@ -258,8 +262,6 @@ class AlternativeName(SlugModel):
is_colloquial = models.BooleanField(default=False)
is_historic = models.BooleanField(default=False)

objects = AlternativeNameManager()

def __str__(self):
return "%s (%s)" % (force_text(self.name), force_text(self.language_code))

Expand Down Expand Up @@ -290,8 +292,6 @@ class PostalCode(Place, SlugModel):
blank=True, null=True, related_name='postal_codes')
district = models.ForeignKey(District, blank=True, null=True, related_name='postal_codes')

objects = models.GeoManager()

class Meta:
unique_together = (
('country', 'region', 'subregion', 'city', 'district', 'name', 'id', 'code'),
Expand Down
4 changes: 2 additions & 2 deletions test_project/test_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'test_project.urls'
ROOT_URLCONF = 'test_app.urls'

WSGI_APPLICATION = 'test_project.wsgi.application'
WSGI_APPLICATION = 'test_app.wsgi.application'


# Database
Expand Down