Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dojo/db_migrations/0248_alter_general_survey_expiration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.1.14 on 2025-11-17 20:31

import dojo.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dojo', '0247_remove_finding_insert_insert_and_more'),
]

operations = [
migrations.AlterField(
model_name='general_survey',
name='expiration',
field=models.DateTimeField(default=dojo.models.default_expiration),
),
]
11 changes: 6 additions & 5 deletions dojo/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3632,13 +3632,14 @@ def clean_expiration(self):
if expiration < today:
msg = "The expiration cannot be in the past"
raise forms.ValidationError(msg)
if expiration.day == today.day:
if expiration == today:
msg = "The expiration cannot be today"
raise forms.ValidationError(msg)
else:
msg = "An expiration for the survey must be supplied"
raise forms.ValidationError(msg)
return expiration
return timezone.make_aware(
datetime.combine(expiration, datetime.min.time()),
)
msg = "An expiration for the survey must be supplied"
raise forms.ValidationError(msg)


class Delete_Questionnaire_Form(forms.ModelForm):
Expand Down
10 changes: 9 additions & 1 deletion dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4692,11 +4692,15 @@ def __str__(self):
return self.survey.name


def default_expiration():
return timezone.now() + timedelta(days=7)


class General_Survey(models.Model):
survey = models.ForeignKey(Engagement_Survey, on_delete=models.CASCADE)
num_responses = models.IntegerField(default=0)
generated = models.DateTimeField(auto_now_add=True, null=True)
expiration = models.DateTimeField(null=False, blank=False)
expiration = models.DateTimeField(default=default_expiration)

class Meta:
verbose_name = _("General Engagement Survey")
Expand All @@ -4705,6 +4709,10 @@ class Meta:
def __str__(self):
return self.survey.name

def clean(self):
if self.expiration and timezone.is_naive(self.expiration):
self.expiration = timezone.make_aware(self.expiration)


with warnings.catch_warnings(action="ignore", category=ManagerInheritanceWarning):
class Answer(PolymorphicModel, TimeStampedModel):
Expand Down