from django.core.management.base import BaseCommand
from apps.pages.models import HomeAbout


class Command(BaseCommand):
    help = 'Set the homepage About body text'

    def handle(self, *args, **options):
        try:
            from apps.tenants.models import Tenant
            tenant = Tenant.objects.get(is_master=True)
        except Exception:
            tenant = None

        obj, created = HomeAbout.objects.get_or_create(tenant=tenant)
        obj.body = (
            '<h2 style="text-align:justify;">'
            '<strong>25 Years of Getting It Right,</strong><br>'
            "<strong>So You Don’t Have To.</strong>"
            '</h2>'
        )
        obj.save()
        self.stdout.write(self.style.SUCCESS('About body updated.'))
