File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3632,13 +3632,13 @@ def clean_expiration(self):
36323632 if expiration < today :
36333633 msg = "The expiration cannot be in the past"
36343634 raise forms .ValidationError (msg )
3635- if expiration . day == today . day :
3635+ if expiration == today :
36363636 msg = "The expiration cannot be today"
36373637 raise forms .ValidationError (msg )
3638- else :
3639- msg = "An expiration for the survey must be supplied"
3640- raise forms . ValidationError ( msg )
3641- return expiration
3638+ aware_expiration = timezone . make_aware (
3639+ datetime . combine ( expiration , datetime . min . time ()),
3640+ )
3641+ return aware_expiration
36423642
36433643
36443644class Delete_Questionnaire_Form (forms .ModelForm ):
Original file line number Diff line number Diff line change @@ -4689,7 +4689,11 @@ class General_Survey(models.Model):
46894689 survey = models .ForeignKey (Engagement_Survey , on_delete = models .CASCADE )
46904690 num_responses = models .IntegerField (default = 0 )
46914691 generated = models .DateTimeField (auto_now_add = True , null = True )
4692- expiration = models .DateTimeField (null = False , blank = False )
4692+ expiration = models .DateTimeField (
4693+ null = False ,
4694+ blank = False ,
4695+ default = lambda : timezone .now () + timedelta (days = 7 ), # aware datetime
4696+ )
46934697
46944698 class Meta :
46954699 verbose_name = _ ("General Engagement Survey" )
@@ -4698,6 +4702,10 @@ class Meta:
46984702 def __str__ (self ):
46994703 return self .survey .name
47004704
4705+ def clean (self ):
4706+ if self .expiration and timezone .is_naive (self .expiration ):
4707+ self .expiration = timezone .make_aware (self .expiration )
4708+
47014709
47024710with warnings .catch_warnings (action = "ignore" , category = ManagerInheritanceWarning ):
47034711 class Answer (PolymorphicModel , TimeStampedModel ):
You can’t perform that action at this time.
0 commit comments