add some change for add translations for tags
This commit is contained in:
parent
9f03da9bef
commit
82c79091a3
|
|
@ -1,19 +1,17 @@
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
from establishment.models import Establishment, EstablishmentType
|
from tag.models import Tag
|
||||||
from transfer import models as legacy
|
from transfer import models as legacy
|
||||||
from tag.models import Tag, TagCategory
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'Add tags translation from old db to new db'
|
help = 'Add tags translation from old db to new db'
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def humanization_tag(self):
|
||||||
translation = legacy.MetadatumAliases.objects.all()
|
"""Humanisation for default values"""
|
||||||
# Humanisation for default values
|
|
||||||
|
|
||||||
tags = Tag.objects.all()
|
tags = Tag.objects.all()
|
||||||
for tag in tags:
|
for tag in tqdm(tags):
|
||||||
value = tag.label
|
value = tag.label
|
||||||
for k, v in value.items():
|
for k, v in value.items():
|
||||||
if isinstance(v, str) and '_' in v:
|
if isinstance(v, str) and '_' in v:
|
||||||
|
|
@ -22,7 +20,10 @@ class Command(BaseCommand):
|
||||||
tag.label[k] = v
|
tag.label[k] = v
|
||||||
tag.save()
|
tag.save()
|
||||||
|
|
||||||
for trans in translation:
|
def handle(self, *args, **kwargs):
|
||||||
|
translation = legacy.MetadatumAliases.objects.all()
|
||||||
|
# self.humanization_tag()
|
||||||
|
for trans in tqdm(translation):
|
||||||
tag = Tag.objects.filter(value=trans.value).first()
|
tag = Tag.objects.filter(value=trans.value).first()
|
||||||
if tag:
|
if tag:
|
||||||
tag.label.update(
|
tag.label.update(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user