Merge branch 'develop' of ssh://gl.id-east.ru:222/gm/gm-backend into develop

This commit is contained in:
evgeniy-st 2019-10-23 17:03:52 +03:00
commit a7a83a8755
2 changed files with 23 additions and 3 deletions

View File

@ -8,7 +8,7 @@ def fill_establishment_subtype(apps, schema_editor):
# version than this migration expects. We use the historical version.
EstablishmentSubType = apps.get_model('establishment', 'EstablishmentSubType')
for n, et in enumerate(EstablishmentSubType.objects.all()):
et.index_name = f'Type {n}'
et.index_name = 'Type %s' % n
et.save()

View File

@ -5,6 +5,16 @@ import django.db.models.deletion
import utils.models
def fill_currency_name(apps, schema_editor):
# We can't import the Person model directly as it may be a newer
# version than this migration expects. We use the historical version.
Currency = apps.get_model('main', 'Currency')
for currency in Currency.objects.all():
currency.name_json = {'en-GB': currency.name}
currency.save()
class Migration(migrations.Migration):
dependencies = [
@ -29,9 +39,19 @@ class Migration(migrations.Migration):
name='currency',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='main.Currency'),
),
migrations.AlterField(
migrations.AddField(
model_name='currency',
name='name',
name='name_json',
field=utils.models.TJSONField(blank=True, default=None, help_text='{"en-GB":"some text"}', null=True, verbose_name='name'),
),
migrations.RunPython(fill_currency_name, migrations.RunPython.noop),
migrations.RemoveField(
model_name='currency',
name='name',
),
migrations.RenameField(
model_name='currency',
old_name='name_json',
new_name='name',
),
]