♻️(core) move app ready code to functions
For readability, we move the code block from the `ready` method to a dedicated function. This will allow to add more things to do in the `ready` with more focus.
This commit is contained in:
committed by
Sabrina Demagny
parent
2502ff0c99
commit
4ced342062
@@ -14,14 +14,7 @@ from people.celery_app import app as celery_app
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
"""Configuration class for the People core app."""
|
||||
|
||||
name = "core"
|
||||
app_label = "core"
|
||||
verbose_name = _("People core application")
|
||||
|
||||
def ready(self):
|
||||
def _register_management_commands_as_task():
|
||||
"""
|
||||
Register management command which are enabled via MANAGEMENT_COMMAND_AS_TASK setting.
|
||||
"""
|
||||
@@ -30,9 +23,7 @@ class CoreConfig(AppConfig):
|
||||
try:
|
||||
app_name = get_commands()[command_name]
|
||||
except KeyError:
|
||||
logging.error(
|
||||
"Command %s is not a valid management command.", command_name
|
||||
)
|
||||
logging.error("Command %s is not a valid management command.", command_name)
|
||||
continue
|
||||
|
||||
command_full_name = ".".join([app_name, command_name])
|
||||
@@ -64,3 +55,15 @@ class CoreConfig(AppConfig):
|
||||
|
||||
# Create the task with the current values
|
||||
create_task(command_name, command_full_name)
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
"""Configuration class for the People core app."""
|
||||
|
||||
name = "core"
|
||||
app_label = "core"
|
||||
verbose_name = _("People core application")
|
||||
|
||||
def ready(self):
|
||||
"""Run when the application is ready."""
|
||||
_register_management_commands_as_task()
|
||||
|
||||
Reference in New Issue
Block a user