fix: Do not cache official_timeslotassignment when None (#5830)

This commit is contained in:
Jennifer Richards 2023-06-15 11:27:31 -03:00 committed by GitHub
parent 6f361f9574
commit f04d356834
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1254,7 +1254,8 @@ class Session(models.Model):
return Constraint.objects.filter(target=self.group, meeting=self.meeting).order_by('name__name')
def official_timeslotassignment(self):
if not hasattr(self, "_cache_official_timeslotassignment"):
# cache only non-None values
if getattr(self, "_cache_official_timeslotassignment", None) is None:
self._cache_official_timeslotassignment = self.timeslotassignments.filter(schedule__in=[self.meeting.schedule, self.meeting.schedule.base if self.meeting.schedule else None]).first()
return self._cache_official_timeslotassignment