Skip to content

Commit 1d2335d

Browse files
authored
Updated _schedule_at to use local time when _interval is set (#12006)
* updated _schedule_at to use local time when _interval is set * updated schedule_at to use local time when interval is set
1 parent ad03061 commit 1d2335d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

netbox/extras/forms/reports.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ class ReportForm(BootstrapMixin, forms.Form):
2525
help_text=_("Interval at which this report is re-run (in minutes)")
2626
)
2727

28-
def clean_schedule_at(self):
28+
def clean(self):
2929
scheduled_time = self.cleaned_data['schedule_at']
30-
if scheduled_time and scheduled_time < timezone.now():
30+
if scheduled_time and scheduled_time < local_now():
3131
raise forms.ValidationError(_('Scheduled time must be in the future.'))
3232

33-
return scheduled_time
33+
# When interval is used without schedule at, raise an exception
34+
if self.cleaned_data['interval'] and not scheduled_time:
35+
self.cleaned_data['schedule_at'] = local_now()
36+
37+
return self.cleaned_data
3438

3539
def __init__(self, *args, **kwargs):
3640
super().__init__(*args, **kwargs)

netbox/extras/forms/scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def clean(self):
5252

5353
# When interval is used without schedule at, raise an exception
5454
if self.cleaned_data['_interval'] and not scheduled_time:
55-
raise forms.ValidationError(_('Scheduled time must be set when recurs is used.'))
55+
self.cleaned_data['_schedule_at'] = local_now()
5656

5757
return self.cleaned_data
5858

0 commit comments

Comments
 (0)