Skip to content

Commit

Permalink
All 'usage' attributes retrieved with methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel2392 committed Apr 20, 2024
1 parent e8bc0d2 commit 79c2e80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions wagtail_fedit/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions wagtail_fedit/management/commands/adapter_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit 79c2e80

Please sign in to comment.