add method for label
This commit is contained in:
parent
45b0b93068
commit
ad3966b2aa
|
|
@ -43,11 +43,11 @@ def metadata_tags_sql():
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
value,
|
value,
|
||||||
`key` as category,
|
`key` as category,
|
||||||
establishment_id
|
establishment_id
|
||||||
FROM metadata
|
FROM metadata
|
||||||
WHERE establishment_id is not null"""
|
WHERE establishment_id is not null"""
|
||||||
)
|
)
|
||||||
return namedtuplefetchall(cursor)
|
return namedtuplefetchall(cursor)
|
||||||
|
|
||||||
|
|
@ -64,6 +64,11 @@ class Command(BaseCommand):
|
||||||
meta_type = 'bool'
|
meta_type = 'bool'
|
||||||
return meta_type
|
return meta_type
|
||||||
|
|
||||||
|
def get_label(self, text):
|
||||||
|
sp = text.key.split('_')
|
||||||
|
label = ' '.join([sp[0].capitalize()] + sp[1:])
|
||||||
|
return label
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
existing_establishment = Establishment.objects.filter(
|
existing_establishment = Establishment.objects.filter(
|
||||||
old_id__isnull=False
|
old_id__isnull=False
|
||||||
|
|
@ -86,7 +91,7 @@ class Command(BaseCommand):
|
||||||
defaults={
|
defaults={
|
||||||
"public": True if meta.public == 1 else False,
|
"public": True if meta.public == 1 else False,
|
||||||
"value_type": self.get_type(meta),
|
"value_type": self.get_type(meta),
|
||||||
"label": {"en-GB": meta.key}
|
"label": {"en-GB": self.get_label(meta.key)}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -102,7 +107,7 @@ class Command(BaseCommand):
|
||||||
category=TagCategory.objects.get(index_name=meta_tag.category),
|
category=TagCategory.objects.get(index_name=meta_tag.category),
|
||||||
value=meta_tag.value,
|
value=meta_tag.value,
|
||||||
defaults={
|
defaults={
|
||||||
"label": {"en-GB": meta_tag.value}
|
"label": {"en-GB": self.get_label(meta_tag.value)}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
establishment = existing_establishment.filter(old_id=meta_tag.establishment_id).first()
|
establishment = existing_establishment.filter(old_id=meta_tag.establishment_id).first()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user