Skip to content

Commit

Permalink
PEP8 fixes in migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk Ściborek committed Jan 6, 2016
1 parent 88079ec commit a744e10
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
21 changes: 14 additions & 7 deletions teryt/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Migration(migrations.Migration):
name='JednostkaAdministracyjna',
fields=[
('stan_na', models.DateField()),
('id', models.CharField(max_length=7, serialize=False, primary_key=True)),
('id', models.CharField(max_length=7, serialize=False,
primary_key=True)),
('nazwa', models.CharField(max_length=50)),
('nazwa_dod', models.CharField(max_length=50)),
],
Expand All @@ -28,10 +29,13 @@ class Migration(migrations.Migration):
name='Miejscowosc',
fields=[
('stan_na', models.DateField()),
('symbol', models.CharField(max_length=7, serialize=False, primary_key=True)),
('symbol', models.CharField(max_length=7, serialize=False,
primary_key=True)),
('nazwa', models.CharField(max_length=100)),
('jednostka', models.ForeignKey(to='teryt.JednostkaAdministracyjna')),
('miejscowosc_nadrzedna', models.ForeignKey(blank=True, to='teryt.Miejscowosc', null=True)),
('jednostka', models.ForeignKey(
to='teryt.JednostkaAdministracyjna')),
('miejscowosc_nadrzedna', models.ForeignKey(
blank=True, to='teryt.Miejscowosc', null=True)),
],
options={
'abstract': False,
Expand All @@ -42,7 +46,8 @@ class Migration(migrations.Migration):
name='RodzajMiejsowosci',
fields=[
('stan_na', models.DateField()),
('id', models.CharField(max_length=2, serialize=False, primary_key=True)),
('id', models.CharField(max_length=2, serialize=False,
primary_key=True)),
('nazwa', models.CharField(max_length=30)),
],
options={
Expand All @@ -54,11 +59,13 @@ class Migration(migrations.Migration):
name='Ulica',
fields=[
('stan_na', models.DateField()),
('id', models.CharField(max_length=12, serialize=False, primary_key=True)),
('id', models.CharField(max_length=12, serialize=False,
primary_key=True)),
('symbol_ulicy', models.CharField(max_length=10)),
('cecha', models.CharField(max_length=10)),
('nazwa_1', models.CharField(max_length=100)),
('nazwa_2', models.CharField(max_length=100, null=True, blank=True)),
('nazwa_2', models.CharField(max_length=100, null=True,
blank=True)),
('miejscowosc', models.ForeignKey(to='teryt.Miejscowosc')),
],
options={
Expand Down
9 changes: 6 additions & 3 deletions teryt/migrations/0003_update_aktywny.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ def update_aktywny(apps, schema_editor):
print("Updating: {}".format(model_name))
model_class = apps.get_model("teryt", model_name)

akt_stan = model_class.objects.all().aggregate(models.Max('stan_na'))['stan_na__max']
model_class.objects.filter(stan_na__exact=akt_stan).update(aktywny=True)
model_class.objects.exclude(stan_na__exact=akt_stan).update(aktywny=False)
akt_stan = model_class.objects.all().aggregate(
models.Max('stan_na'))['stan_na__max']
model_class.objects.filter(stan_na__exact=akt_stan).update(
aktywny=True)
model_class.objects.exclude(stan_na__exact=akt_stan).update(
aktywny=False)


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion teryt/migrations/0005_rename_RodzajMiejsowosci.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
6 changes: 4 additions & 2 deletions teryt/migrations/0006_add_JednostkaAdministracyjna_typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.manager


def update_type(apps, schema_editor):
# Update typ attribute of JednostkaAdministracyjna

JednostkaAdministracyjna = apps.get_model("teryt", "JednostkaAdministracyjna")
JednostkaAdministracyjna = apps.get_model("teryt",
"JednostkaAdministracyjna")
LEN_TYPE = {
7: 'GMI',
4: 'POW',
Expand All @@ -18,6 +19,7 @@ def update_type(apps, schema_editor):
ja.typ = LEN_TYPE[len(ja.id)]
ja.save()


class Migration(migrations.Migration):

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion teryt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class JednostkaAdministracyjna(CommonInfo):
nazwa = models.CharField(max_length=50)
nazwa_dod = models.CharField(max_length=50)
typ = models.CharField(max_length=3)
#typ = models.CharField(max_length=3, null=True, blank=True)

wojewodztwa = WojewodztwoManager()
powiaty = PowiatManager()
Expand Down

0 comments on commit a744e10

Please sign in to comment.