Ejemplo n.º 1
0
    def __call__(self, text, level=None, title=None, prefix=None, important=None):
        """
        Adds a new alert to the list, if theres a delay adds it to the database
        Returns the index at which the alert is at, so you can change it afterwards
        """
        alert = Alert(
            text=text or '',
            title=title or '',
            prefix=prefix or '',
            level=level or settings.ALERT_DEFAULT_LEVEL,
            owner=self.owner
        )
        if important is None:
            important = level in settings.ALERT_IMPORTANT_LEVELS
        alert.closable = not important

        self.append(alert)
        return alert