Skip to content

Commit

Permalink
update mitigated on to be a range for simple date
Browse files Browse the repository at this point in the history
  • Loading branch information
hblankenship committed Jan 16, 2025
1 parent 9799405 commit 59a5669
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions dojo/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ class ApiFindingFilter(DojoFilter):
jira_change = DateRangeFilter(field_name="jira_issue__jira_change")
last_reviewed = DateRangeFilter()
mitigated = DateRangeFilter()
mitigated_on = DateTimeFilter(field_name="mitigated", lookup_expr="exact")
mitigated_on = DateTimeFilter(field_name="mitigated", lookup_expr="exact", method="filter_mitigated_on")
mitigated_before = DateTimeFilter(field_name="mitigated", lookup_expr="lt")
mitigated_after = DateTimeFilter(field_name="mitigated", lookup_expr="gt", label="Mitigated After", method="filter_mitigated_after")
# NumberInFilter
Expand Down Expand Up @@ -1550,7 +1550,14 @@ def filter_mitigated_after(self, queryset, name, value):
value = value.replace(hour=23, minute=59, second=59)

return queryset.filter(mitigated__gt=value)


Check failure on line 1553 in dojo/filters.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (W293)

dojo/filters.py:1553:1: W293 Blank line contains whitespace
def filter_mitigated_on(self, queryset, name, value):
if value.hour == 0 and value.minute == 0 and value.second == 0:
# we have a simple date without a time, lets get a range from this morning to tonight at 23:59:59:999
nextday = value + timedelta(days=1)
return queryset.filter(mitigated__gte=value, mitigated__lt=nextday)

Check failure on line 1559 in dojo/filters.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (W293)

dojo/filters.py:1559:1: W293 Blank line contains whitespace
return queryset.filter(mitigated=value)

class PercentageFilter(NumberFilter):

Check failure on line 1562 in dojo/filters.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E302)

dojo/filters.py:1562:1: E302 Expected 2 blank lines, found 1
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -1594,7 +1601,7 @@ class FindingFilterHelper(FilterSet):
duplicate = ReportBooleanFilter()
is_mitigated = ReportBooleanFilter()
mitigated = DateRangeFilter(field_name="mitigated", label="Mitigated Date")
mitigated_on = DateTimeFilter(field_name="mitigated", lookup_expr="exact", label="Mitigated On")
mitigated_on = DateTimeFilter(field_name="mitigated", lookup_expr="exact", label="Mitigated On", method="filter_mitigated_on")
mitigated_before = DateTimeFilter(field_name="mitigated", lookup_expr="lt", label="Mitigated Before")
mitigated_after = DateTimeFilter(field_name="mitigated", lookup_expr="gt", label="Mitigated After", method="filter_mitigated_after")
planned_remediation_date = DateRangeOmniFilter()
Expand Down Expand Up @@ -1718,6 +1725,13 @@ def filter_mitigated_after(self, queryset, name, value):

return queryset.filter(mitigated__gt=value)

def filter_mitigated_on(self, queryset, name, value):
if value.hour == 0 and value.minute == 0 and value.second == 0:
# we have a simple date without a time, lets get a range from this morning to tonight at 23:59:59:999
nextday = value + timedelta(days=1)
return queryset.filter(mitigated__gte=value, mitigated__lt=nextday)

Check failure on line 1733 in dojo/filters.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (W293)

dojo/filters.py:1733:1: W293 Blank line contains whitespace
return queryset.filter(mitigated=value)

class FindingFilterWithoutObjectLookups(FindingFilterHelper, FindingTagStringFilter):

Check failure on line 1736 in dojo/filters.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E302)

dojo/filters.py:1736:1: E302 Expected 2 blank lines, found 1
test__engagement__product__prod_type = NumberFilter(widget=HiddenInput())
Expand Down

0 comments on commit 59a5669

Please sign in to comment.