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

Django 1.10 support #248

Merged
merged 5 commits into from
Aug 19, 2016
Merged
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
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ env:
- TOXENV=py27-1.8
- TOXENV=py27-1.9
- TOXENV=py27-1.10
- TOXENV=py27-1.11
- TOXENV=py32-1.8
- TOXENV=py34-1.9
- TOXENV=py34-1.10
- TOXENV=py34-1.11

matrix:
allow_failures:
- env: TOXENV=py27-1.10
- env: TOXENV=py34-1.10
- env: TOXENV=py27-1.11
- env: TOXENV=py34-1.11

install:
- pip install tox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@

from __future__ import print_function

from optparse import make_option
from django.core.management.base import NoArgsCommand, CommandError
from django.core.management.base import BaseCommand, CommandError
from mapit.models import Generation, Area


class Command(NoArgsCommand):
class Command(BaseCommand):
help = 'Remove all areas from the new (inactive) generation'
args = '<GENERATION-ID>'
option_list = NoArgsCommand.option_list + (
make_option('--commit', action='store_true', dest='commit',
help='Actually update the database'),)

def add_arguments(self, parser):
parser.add_argument('--commit', action='store_true', dest='commit', help='Actually update the database')

def handle(self, **options):
new = Generation.objects.new()
Expand Down
11 changes: 5 additions & 6 deletions mapit/management/commands/mapit_generation_activate.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# This script activates the currently inactive generation.

from optparse import make_option
from django.core.management.base import NoArgsCommand
from django.core.management.base import BaseCommand
from mapit.models import Generation


class Command(NoArgsCommand):
class Command(BaseCommand):
help = 'Actives the inactive generation'
option_list = NoArgsCommand.option_list + (
make_option('--commit', action='store_true', dest='commit', help='Actually update the database'),
)

def add_arguments(self, parser):
parser.add_argument('--commit', action='store_true', dest='commit', help='Actually update the database')

def handle(self, **options):
new = Generation.objects.new()
Expand Down
13 changes: 6 additions & 7 deletions mapit/management/commands/mapit_generation_create.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# This script is used to create a new inactive generation for
# inputting new boundaries of some sort.

from optparse import make_option
from django.core.management.base import NoArgsCommand
from django.core.management.base import BaseCommand
from mapit.models import Generation


class Command(NoArgsCommand):
class Command(BaseCommand):
help = 'Create a new generation'
option_list = NoArgsCommand.option_list + (
make_option('--desc', action='store', dest='desc', help='Description of this generation'),
make_option('--commit', action='store_true', dest='commit', help='Actually update the database'),
)

def add_arguments(self, parser):
parser.add_argument('--desc', action='store', dest='desc', help='Description of this generation')
parser.add_argument('--commit', action='store_true', dest='commit', help='Actually update the database')

def handle(self, **options):
new_generation = Generation.objects.new()
Expand Down
11 changes: 5 additions & 6 deletions mapit/management/commands/mapit_generation_deactivate.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# This script deactivates a particular generation

from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from mapit.models import Generation


class Command(BaseCommand):
help = 'Deactivate a generation'
args = '<GENERATION-ID>'
option_list = BaseCommand.option_list + (
make_option('--commit', action='store_true', dest='commit',
help='Actually update the database'),
make_option('--force', action='store_true', dest='force',
help='Force deactivation, even if it would leave no active generations'))

def add_arguments(self, parser):
parser.add_argument('--commit', action='store_true', dest='commit', help='Actually update the database')
parser.add_argument('--force', action='store_true', dest='force',
help='Force deactivation, even if it would leave no active generations')

def handle(self, generation_id, **options):
generation_to_deactivate = Generation.objects.get(id=int(generation_id, 10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# safe way of raising the generation_high of all active areas to the
# ID of the new inactive generation.

from optparse import make_option

from django.core.management.base import BaseCommand, CommandError

from mapit.models import Area, Generation, Type, Country
Expand Down Expand Up @@ -36,14 +34,11 @@ def check_option(option_name, options, model_class):

class Command(BaseCommand):
help = "Raise generation_high on active areas to the new generation's ID"
option_list = BaseCommand.option_list + (
make_option('--commit', action='store_true', dest='commit',
help='Actually update the database'),
make_option('--country',
help='Only raise the generation on areas with this country code'),
make_option('--type',
help='Only raise the generation on areas with this area type code'),
)

def add_arguments(self, parser):
parser.add_argument('--commit', action='store_true', dest='commit', help='Actually update the database')
parser.add_argument('--country', help='Only raise the generation on areas with this country code')
parser.add_argument('--type', help='Only raise the generation on areas with this area type code')

def handle(self, **options):
area_type = check_option('type', options, Type)
Expand Down
70 changes: 35 additions & 35 deletions mapit/management/commands/mapit_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org

import re
from optparse import make_option

from django.core.management.base import LabelCommand, CommandError
# Not using LayerMapping as want more control, but what it does is what this does
Expand All @@ -22,103 +21,104 @@
class Command(LabelCommand):
help = 'Import geometry data from .shp, .kml or .geojson files'
args = '<SHP/KML/GeoJSON files>'
option_list = LabelCommand.option_list + (
make_option(

def add_arguments(self, parser):
super(Command, self).add_arguments(parser)
parser.add_argument(
'--commit',
action='store_true',
dest='commit',
help='Actually update the database'
),
make_option(
)
parser.add_argument(
'--generation_id',
action="store",
dest='generation_id',
help='Which generation ID should be used',
),
make_option(
)
parser.add_argument(
'--country_code',
action="store",
dest='country_code',
help='Which country should be used',
),
make_option(
)
parser.add_argument(
'--area_type_code',
action="store",
dest='area_type_code',
help='Which area type should be used (specify using code)',
),
make_option(
)
parser.add_argument(
'--name_type_code',
action="store",
dest='name_type_code',
help='Which name type should be used (specify using code)',
),
make_option(
)
parser.add_argument(
'--code_type',
action="store",
dest='code_type',
help='Which code type should be used (specify using its code)',
),
make_option(
)
parser.add_argument(
'--name_field',
action="store",
dest='name_field',
help="The field name (or names separated by comma) to look at for the area's name"
),
make_option(
)
parser.add_argument(
'--override_name',
action="store",
dest='override_name',
help="The name to use for the area"
),
make_option(
)
parser.add_argument(
'--code_field',
action="store",
dest='code_field',
help="The field name containing the area's ID code"
),
make_option(
)
parser.add_argument(
'--override_code',
action="store",
dest='override_code',
help="The ID code to use for the area"
),
make_option(
)
parser.add_argument(
'--use_code_as_id',
action="store_true",
dest='use_code_as_id',
help="Set to use the code from code_field as the MapIt ID"
),
make_option(
)
parser.add_argument(
'--preserve',
action="store_true",
dest='preserve',
help="Create a new area if the name's the same but polygons differ"
),
make_option(
)
parser.add_argument(
'--new',
action="store_true",
dest='new',
help="Don't look for existing areas at all, just import everything as new areas"
),
make_option(
)
parser.add_argument(
'--encoding',
action="store",
dest='encoding',
help="The encoding of names in this dataset"
),
make_option(
)
parser.add_argument(
'--fix_invalid_polygons',
action="store_true",
dest='fix_invalid_polygons',
help="Try to fix any invalid polygons and multipolygons found"
),
make_option(
)
parser.add_argument(
'--ignore_blank',
action="store_true",
help="Skip over any entry with an empty name, rather than abort"
),
)
)

def handle_label(self, filename, **options):

Expand Down
8 changes: 4 additions & 4 deletions mapit/management/commands/mapit_import_area_unions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# the GPL. Based on import_norway_osm.py by Matthew Somerville

import csv
from optparse import make_option

from django.core.management.base import LabelCommand
from django.contrib.gis.geos import GEOSGeometry
Expand Down Expand Up @@ -39,9 +38,10 @@ def __iter__(self):
class Command(LabelCommand):
help = 'Import region data'
args = '<CSV file listing name and which existing areas to combine into regions>'
option_list = LabelCommand.option_list + (
make_option('--commit', action='store_true', dest='commit', help='Actually update the database'),
)

def add_arguments(self, parser):
super(Command, self).add_arguments(parser)
parser.add_argument('--commit', action='store_true', dest='commit', help='Actually update the database')

def handle_label(self, filename, **options):
current_generation = Generation.objects.current()
Expand Down
Loading