# Path: statusboard/settings.py
# DEFAULTS = {
#     # Number of incidents in index (1 = today, 0 = deactivate)
#     "INCIDENT_DAYS_IN_INDEX": 7,
#     # Show or not all the open incidents in index
#     "OPEN_INCIDENT_IN_INDEX": True,
#     # Automatic refresth the home page in seconds (disable with 0)
#     "AUTO_REFRESH_INDEX_SECONDS": 0,
#     # Default favicon
#     "FAVICON_DEFAULT": static(
#         "statusboard/favicons/statusboard-icon-default.ico"
#     ),
#     # Favicons for index
#     "FAVICON_INDEX_DICT": {
#         0: static("statusboard/favicons/statusboard-icon-operational.ico"),
#         1: static("statusboard/favicons/statusboard-icon-performance.ico"),
#         2: static("statusboard/favicons/statusboard-icon-partial.ico"),
#         3: static("statusboard/favicons/statusboard-icon-major.ico"),
#     },
# }
# class Settings(object):
#     def __getattr__(self, name):


from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.dispatch import receiver
from model_utils.models import TimeStampedModel
from .settings import statusconf
    (2, _("Watching")),
    (3, _("Fixed")),
)


class IncidentQuerySet(models.QuerySet):
    def occurred_in_last_n_days_q(self, days):
        """Q obects for the incidents occurred in last N days (1 = today)."""
        threshold = timezone.now() - timezone.timedelta(days=days - 1)
        threshold = threshold.replace(
            hour=0, minute=0, second=0, microsecond=0
        )
        return models.Q(occurred__gte=threshold)

    def last_occurred_q(self):
        return self.occurred_in_last_n_days_q(
            statusconf.INCIDENT_DAYS_IN_INDEX
        )

    def occurred_in_last_n_days(self, days=7):
        """Return incidents occurred in last N days (1 = today)."""
        return self.filter(self.occurred_in_last_n_days_q(days))

    def last_occurred(self):
        """Return incidents occurred in last days. The number of days is
        defined in STATUSBOARD["INCIDENT_DAYS_IN_INDEX"]."""
        return self.filter(self.last_occurred_q())

    def in_index(self):
        q = self.last_occurred_q()

# Path: statusboard/settings.py
# DEFAULTS = {
#     # Number of incidents in index (1 = today, 0 = deactivate)
#     "INCIDENT_DAYS_IN_INDEX": 7,
#     # Show or not all the open incidents in index
#     "OPEN_INCIDENT_IN_INDEX": True,
#     # Automatic refresth the home page in seconds (disable with 0)
#     "AUTO_REFRESH_INDEX_SECONDS": 0,
#     # Default favicon
#     "FAVICON_DEFAULT": static(
#         "statusboard/favicons/statusboard-icon-default.ico"
#     ),
#     # Favicons for index
#     "FAVICON_INDEX_DICT": {
#         0: static("statusboard/favicons/statusboard-icon-operational.ico"),
#         1: static("statusboard/favicons/statusboard-icon-performance.ico"),
#         2: static("statusboard/favicons/statusboard-icon-partial.ico"),
#         3: static("statusboard/favicons/statusboard-icon-major.ico"),
#     },
# }
# class Settings(object):
#     def __getattr__(self, name):


# Path: statusboard/models.py
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.dispatch import receiver
from model_utils.models import TimeStampedModel
from .settings import statusconf

    (2, _("Watching")),
    (3, _("Fixed")),
)


class IncidentQuerySet(models.QuerySet):
    def occurred_in_last_n_days_q(self, days):
        """Q obects for the incidents occurred in last N days (1 = today)."""
        threshold = timezone.now() - timezone.timedelta(days=days - 1)
        threshold = threshold.replace(
            hour=0, minute=0, second=0, microsecond=0
        )
        return models.Q(occurred__gte=threshold)

    def last_occurred_q(self):
        return self.occurred_in_last_n_days_q(
            statusconf.INCIDENT_DAYS_IN_INDEX
        )

    def occurred_in_last_n_days(self, days=7):
        """Return incidents occurred in last N days (1 = today)."""
        return self.filter(self.occurred_in_last_n_days_q(days))

    def last_occurred(self):
        """Return incidents occurred in last days. The number of days is
        defined in STATUSBOARD["INCIDENT_DAYS_IN_INDEX"]."""
        return self.filter(self.last_occurred_q())

    def in_index(self):
        q = self.last_occurred_q()

        if statusconf.OPEN_INCIDENT_IN_INDEX: