Skip to content

Commit f1c0e88

Browse files
committed
feat(settings): Drop time_zone
1 parent e95592d commit f1c0e88

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

docs/content/en/open_source/upgrading/2.50.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
title: 'Upgrading to DefectDojo Version 2.50.x'
33
toc_hide: true
44
weight: -20250804
5-
description: No special instructions.
5+
description: Dropped support for time_zone in System settings.
66
---
7-
There are no special instructions for upgrading to 2.50.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.50.0) for the contents of the release.
7+
8+
To simplify the management of the DefectDojo application, it is not necessary to set the time zone in two places (environmental variables and system settings). From now on, environmental variable is supported.
9+
Please check that the environmental variable `DD_TIME_ZONE` is set based on your satisfaction. Any [TZ identifier](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) is a valid value. Default value is `UTC`.
10+
11+
There are other instructions for upgrading to 2.50.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.50.0) for the contents of the release.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Generated by Django 5.1.11 on 2025-08-15 16:30
2+
from django.db import migrations
3+
4+
class Migration(migrations.Migration):
5+
6+
dependencies = [
7+
('dojo', '0240_jira_instance_password_help_text_fix'),
8+
]
9+
10+
operations = [
11+
migrations.RemoveField(
12+
model_name='system_settings',
13+
name='time_zone',
14+
),
15+
]

dojo/filters.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import decimal
33
import logging
44
import warnings
5-
import zoneinfo
65
from datetime import datetime, timedelta
76

87
import six
@@ -14,7 +13,7 @@
1413
from django.contrib.contenttypes.models import ContentType
1514
from django.db.models import Count, JSONField, Q
1615
from django.forms import HiddenInput
17-
from django.utils import timezone
16+
from django.utils.timezone import now, tzinfo
1817
from django.utils.translation import gettext_lazy as _
1918
from django_filters import (
2019
BooleanFilter,
@@ -97,8 +96,6 @@
9796

9897
logger = logging.getLogger(__name__)
9998

100-
local_tz = zoneinfo.ZoneInfo(get_system_setting("time_zone"))
101-
10299
BOOLEAN_CHOICES = (("false", "No"), ("true", "Yes"))
103100
EARLIEST_FINDING = None
104101

@@ -124,10 +121,6 @@ def vulnerability_id_filter(queryset, name, value):
124121
return queryset.filter(id__in=ids)
125122

126123

127-
def now():
128-
return datetime.today().replace(tzinfo=local_tz)
129-
130-
131124
class NumberInFilter(filters.BaseInFilter, filters.NumberFilter):
132125
pass
133126

@@ -200,7 +193,7 @@ def filter(self, qs, value):
200193
earliest_finding = get_earliest_finding(qs)
201194
if earliest_finding is not None:
202195
start_date = datetime.combine(
203-
earliest_finding.date, datetime.min.time()).replace(tzinfo=local_tz)
196+
earliest_finding.date, datetime.min.time()).replace(tzinfo=tzinfo())
204197
self.start_date = _truncate(start_date - timedelta(days=1))
205198
self.end_date = _truncate(now() + timedelta(days=1))
206199
try:
@@ -216,7 +209,7 @@ def any(self, qs, name):
216209

217210
def sla_satisfied(self, qs, name):
218211
# return findings that have an sla expiration date after today or no sla expiration date
219-
return qs.filter(Q(sla_expiration_date__isnull=True) | Q(sla_expiration_date__gt=timezone.now().date()))
212+
return qs.filter(Q(sla_expiration_date__isnull=True) | Q(sla_expiration_date__gt=now().date()))
220213

221214
def sla_violated(self, qs, name):
222215
# return active findings that have an sla expiration date before today
@@ -229,7 +222,7 @@ def sla_violated(self, qs, name):
229222
risk_accepted=False,
230223
is_mitigated=False,
231224
mitigated=None,
232-
) & Q(sla_expiration_date__lt=timezone.now().date()),
225+
) & Q(sla_expiration_date__lt=now().date()),
233226
)
234227

235228
options = {
@@ -824,22 +817,22 @@ def any(self, qs, name):
824817
earliest_finding = get_earliest_finding(qs)
825818
if earliest_finding is not None:
826819
start_date = datetime.combine(
827-
earliest_finding.date, datetime.min.time()).replace(tzinfo=local_tz)
820+
earliest_finding.date, datetime.min.time()).replace(tzinfo=tzinfo())
828821
self.start_date = _truncate(start_date - timedelta(days=1))
829822
self.end_date = _truncate(now() + timedelta(days=1))
830823
return qs.all()
831824
return None
832825

833826
def current_month(self, qs, name):
834-
self.start_date = datetime(now().year, now().month, 1, 0, 0, 0).replace(tzinfo=local_tz)
827+
self.start_date = datetime(now().year, now().month, 1, 0, 0, 0).replace(tzinfo=tzinfo())
835828
self.end_date = now()
836829
return qs.filter(**{
837830
f"{name}__year": self.start_date.year,
838831
f"{name}__month": self.start_date.month,
839832
})
840833

841834
def current_year(self, qs, name):
842-
self.start_date = datetime(now().year, 1, 1, 0, 0, 0).replace(tzinfo=local_tz)
835+
self.start_date = datetime(now().year, 1, 1, 0, 0, 0).replace(tzinfo=tzinfo())
843836
self.end_date = now()
844837
return qs.filter(**{
845838
f"{name}__year": now().year,
@@ -890,7 +883,7 @@ def filter(self, qs, value):
890883
earliest_finding = get_earliest_finding(qs)
891884
if earliest_finding is not None:
892885
start_date = datetime.combine(
893-
earliest_finding.date, datetime.min.time()).replace(tzinfo=local_tz)
886+
earliest_finding.date, datetime.min.time()).replace(tzinfo=tzinfo())
894887
self.start_date = _truncate(start_date - timedelta(days=1))
895888
self.end_date = _truncate(now() + timedelta(days=1))
896889
try:

dojo/models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
import re
66
import warnings
7-
import zoneinfo
87
from contextlib import suppress
98
from datetime import datetime, timedelta
109
from decimal import Decimal
@@ -437,9 +436,6 @@ class System_Settings(models.Model):
437436

438437
url_prefix = models.CharField(max_length=300, default="", blank=True, help_text=_("URL prefix if DefectDojo is installed in it's own virtual subdirectory."))
439438
team_name = models.CharField(max_length=100, default="", blank=True)
440-
time_zone = models.CharField(max_length=50,
441-
choices=[(tz, tz) for tz in zoneinfo.available_timezones()],
442-
default="UTC", blank=False)
443439
enable_product_grade = models.BooleanField(default=False, verbose_name=_("Enable Product Grading"), help_text=_("Displays a grade letter next to a product to show the overall health."))
444440
product_grade = models.CharField(max_length=800, blank=True)
445441
product_grade_a = models.IntegerField(default=90,

0 commit comments

Comments
 (0)