# -*- coding: utf-8 -*-

import logging

from idm.core.management.base import IdmBaseCommand
from idm.core.models import ApproveRequest

log = logging.getLogger(__name__)


class Command(IdmBaseCommand):
    help = 'Посылаем уведомления о зависших аппрувах.'

    intranet_only = True

    def idm_handle(self, *args, **options):
        try:
            ApproveRequest.objects.send_pending_approval_reminders()
        except Exception:
            log.exception('error during command execution')
            raise
