Skip to content

Commit

Permalink
Fix tasks initialization (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tansito authored Jul 17, 2024
1 parent 6b1003d commit d30ecb0
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions gateway/api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@
from django.db.models.signals import post_migrate


def on_migrations_applied(sender, **kwargs): # pylint: disable=unused-argument
"""
This method will run tasks to populate the DB after the migration
"""
# This import may be here for the correct initialization of the App
from api.tasks import ( # pylint: disable=import-outside-toplevel
programs,
providers,
)

providers.assign_admin_group()
programs.assign_run_permission()


class ApiConfig(AppConfig):
"""ApiConfig."""

default_auto_field = "django.db.models.BigAutoField"
name = "api"

def ready(self):
def on_migrations_applied(**kwargs):
# This import may be here for the correct initialization of the App
from api.tasks import ( # pylint: disable=import-outside-toplevel
programs,
providers,
)

providers.assign_admin_group()
programs.assign_run_permission()

post_migrate.connect(on_migrations_applied)
post_migrate.connect(on_migrations_applied, sender=self)

0 comments on commit d30ecb0

Please sign in to comment.