Coverage for benefits / core / apps.py: 94%
16 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-01 15:39 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-01 15:39 +0000
1"""
2The core application: Houses base templates and reusable models and components.
3"""
5from django.apps import AppConfig
6from django.db.models.signals import post_migrate
9class CoreAppConfig(AppConfig):
10 name = "benefits.core"
11 label = "core"
12 verbose_name = "Core"
14 # Create staff group here instead of in a data migration.
15 # Hat tip: https://lincolnloop.com/blog/ensuring-essential-data-exists-in-your-django-app-on-startup/
17 def ready(self):
18 # Connect a handler that runs after migrations
19 post_migrate.connect(self.setup_group, sender=self)
21 @staticmethod
22 def setup_group(**kwargs):
23 # Ensure the staff group exists.
24 import datetime
26 from django.conf import settings
27 from django.contrib.auth.models import Group
29 group, created = Group.objects.get_or_create(name=settings.STAFF_GROUP_NAME)
31 if created: 31 ↛ exitline 31 didn't return from function 'setup_group' because the condition on line 31 was always true
32 print(f"[{datetime.datetime.now().strftime("%d/%b/%Y %H:%M:%S")}] INFO Staff group '{group.name}' created.")