-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from hmpf/fallback-filter
Add a fallback filter for notifications, currently in order to suppress notifications on acks for everyone, since the frontend does not support setting that particular filter yet.
- Loading branch information
Showing
13 changed files
with
164 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Prevent import loops | ||
# DO NOT import anything here, ever | ||
|
||
INCIDENT_LEVELS = (1, 2, 3, 4, 5) | ||
INCIDENT_LEVEL_CHOICES = zip(INCIDENT_LEVELS, map(str, INCIDENT_LEVELS)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.conf import settings | ||
from django.core.checks import Warning | ||
|
||
from .validators import validate_jsonfilter | ||
|
||
|
||
__all__ = ["fallback_filter_check"] | ||
|
||
|
||
def fallback_filter_check(app_configs, **kwargs): | ||
errors = [] | ||
fallback_filter = getattr(settings, "ARGUS_FALLBACK_FILTER", {}) | ||
if not validate_jsonfilter(fallback_filter): | ||
errors.append( | ||
Warning( | ||
'The ARGUS_FALLBACK_FILTER setting is invalid and has been set to "{}"', | ||
hint="See the docs for the format of the ARGUS_FALLBACK_FILTER setting", | ||
obj=fallback_filter, | ||
id="argus_notificationprofile.W001", | ||
) | ||
) | ||
return errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEPRECATED_FILTER_NAMES = ("sourceSystemIds", "tags") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from rest_framework import serializers | ||
|
||
from argus.incident.constants import INCIDENT_LEVELS | ||
|
||
|
||
class FilterBlobSerializer(serializers.Serializer): | ||
sourceSystemIds = serializers.ListField( | ||
child=serializers.IntegerField(min_value=1), | ||
allow_empty=True, | ||
required=False, | ||
) | ||
tags = serializers.ListField( | ||
child=serializers.CharField(min_length=3), | ||
allow_empty=True, | ||
required=False, | ||
) | ||
open = serializers.BooleanField(required=False, allow_null=True) | ||
acked = serializers.BooleanField(required=False, allow_null=True) | ||
stateful = serializers.BooleanField(required=False, allow_null=True) | ||
maxlevel = serializers.IntegerField( | ||
required=False, allow_null=True, max_value=max(INCIDENT_LEVELS), min_value=min(INCIDENT_LEVELS) | ||
) | ||
|
||
|
||
class FilterPreviewSerializer(serializers.Serializer): | ||
sourceSystemIds = serializers.ListField(serializers.IntegerField(min_value=1), allow_empty=True) | ||
tags = serializers.ListField(serializers.CharField(min_length=3), allow_empty=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters