from django.apps import AppConfig


class MissionConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'mission'
    verbose_name = '任务管理'

    def ready(self):
        from . import handlers
        from .models import Mission, MissionReply
        from .signals import (
            mission_cancelled,
            mission_completed,
            mission_created,
            mission_reopened,
            mission_replied,
            mission_reply_rejected,
        )

        mission_created.connect(
            handlers.on_mission_created,
            sender=Mission,
            dispatch_uid="mission.on_mission_created",
        )
        mission_replied.connect(
            handlers.on_mission_replied,
            sender=MissionReply,
            dispatch_uid="mission.on_mission_replied",
        )
        mission_completed.connect(
            handlers.on_mission_completed,
            sender=Mission,
            dispatch_uid="mission.on_mission_completed",
        )
        mission_reply_rejected.connect(
            handlers.on_mission_reply_rejected,
            sender=MissionReply,
            dispatch_uid="mission.on_mission_reply_rejected",
        )
        mission_reopened.connect(
            handlers.on_mission_reopened,
            sender=Mission,
            dispatch_uid="mission.on_mission_reopened",
        )
        mission_cancelled.connect(
            handlers.on_mission_cancelled,
            sender=Mission,
            dispatch_uid="mission.on_mission_cancelled",
        )
