From 79c2e8065516d4b63c23997f7459b72bac561e5e Mon Sep 17 00:00:00 2001 From: Nigel van Keulen Date: Sat, 20 Apr 2024 16:32:59 +0200 Subject: [PATCH] All 'usage' attributes retrieved with methods --- wagtail_fedit/adapters/base.py | 11 +++++++++-- wagtail_fedit/management/commands/adapter_help.py | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wagtail_fedit/adapters/base.py b/wagtail_fedit/adapters/base.py index a5a146a..ad03415 100644 --- a/wagtail_fedit/adapters/base.py +++ b/wagtail_fedit/adapters/base.py @@ -96,7 +96,7 @@ def __init__(self, object: models.Model, field_name: str, request: HttpRequest, self.kwargs = kwargs @classmethod - def usage_string(cls) -> str: + def get_usage_string(cls) -> str: """ Return a string which describes how to use the adapter. """ @@ -128,7 +128,14 @@ def usage_string(cls) -> str: return "".join(s) @classmethod - def usage_help_text(cls) -> list[str]: + def get_usage_description(cls) -> str: + """ + Return a description of how the adapter is used. + """ + return cls.usage_description + + @classmethod + def get_usage_help_text(cls) -> list[str]: """ Return a help text which describes how to use the adapter. This might be a good time to exalain the kwargs. diff --git a/wagtail_fedit/management/commands/adapter_help.py b/wagtail_fedit/management/commands/adapter_help.py index 59e8f56..84f412b 100644 --- a/wagtail_fedit/management/commands/adapter_help.py +++ b/wagtail_fedit/management/commands/adapter_help.py @@ -33,17 +33,17 @@ def handle(self, *args, **options): DISTANCE = " " s.append( - f"{DISTANCE}{{% {TEMPLATE_TAG_NAME} {identifier} instance.modelfield {adapter_class.usage_string()} %}}", + f"{DISTANCE}{{% {TEMPLATE_TAG_NAME} {identifier} instance.modelfield {adapter_class.get_usage_string()} %}}", ) HELP_DISTANCE = DISTANCE + " " - description = adapter_class.usage_description + description = adapter_class.get_usage_description() if description: s.append( f"{HELP_DISTANCE}{description}", ) - help_text = adapter_class.usage_help_text() + help_text = adapter_class.get_usage_help_text() if help_text: mid = f"{HELP_DISTANCE} * " help_text = f"{LB}{mid}".join([