add method for label
This commit is contained in:
parent
45b0b93068
commit
ad3966b2aa
|
|
@ -43,11 +43,11 @@ def metadata_tags_sql():
|
|||
cursor.execute(
|
||||
"""
|
||||
SELECT
|
||||
value,
|
||||
`key` as category,
|
||||
establishment_id
|
||||
FROM metadata
|
||||
WHERE establishment_id is not null"""
|
||||
value,
|
||||
`key` as category,
|
||||
establishment_id
|
||||
FROM metadata
|
||||
WHERE establishment_id is not null"""
|
||||
)
|
||||
return namedtuplefetchall(cursor)
|
||||
|
||||
|
|
@ -64,6 +64,11 @@ class Command(BaseCommand):
|
|||
meta_type = 'bool'
|
||||
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):
|
||||
existing_establishment = Establishment.objects.filter(
|
||||
old_id__isnull=False
|
||||
|
|
@ -86,7 +91,7 @@ class Command(BaseCommand):
|
|||
defaults={
|
||||
"public": True if meta.public == 1 else False,
|
||||
"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),
|
||||
value=meta_tag.value,
|
||||
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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user