cmsmanage/doorcontrol/apps.py

40 lines
996 B
Python
Raw Normal View History

from django.apps import AppConfig
from django.db.models.signals import post_migrate
def post_migrate_callback(sender, **kwargs):
from django_q.models import Schedule
from cmsmanage.django_q2_helper import ensure_scheduled
from .tasks.scrapehidevents import q_getMessagesAllDoors
from .tasks.update_doors import q_update_all_doors
from .tasks.update_unifi_access import update_access
ensure_scheduled(
q_getMessagesAllDoors,
schedule_type=Schedule.MINUTES,
minutes=15,
)
ensure_scheduled(
q_update_all_doors,
schedule_type=Schedule.MINUTES,
minutes=15,
)
ensure_scheduled(
update_access,
schedule_type=Schedule.MINUTES,
minutes=5,
)
class DoorControlConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "doorcontrol"
verbose_name = "Door Control"
def ready(self):
post_migrate.connect(post_migrate_callback, sender=self)