wagtail_periodic_review/models.py
def clean_frequency_rules(self):
        """
        Called after saving to ensure rules exist for all subclasses of PeriodicReviewMixin,
        and rules that no longer meet that criteria are deleted.
        """
        target_models = set(get_periodic_review_models())
        covered_models = set()

        for obj in self.frequency_rules.all():
            if obj.model_class not in target_models:
                obj.delete()
            else:
                covered_models.add(obj.model_class)

        for model_class in target_models:
            if model_class not in covered_models:
                PeriodicReviewFrequencyRule.objects.create(
                    sitesettings=self,
                    content_type=ContentType.objects.get_for_model(model_class),
                    frequency=ReviewFrequencyChoices.TWELVE_MONTHS,
                )

        Called after saving to ensure rules exist for all subclasses of PeriodicReviewMixin,
        and rules that no longer meet that criteria are deleted.
        
Called after saving to ensure rules exist for all subclasses of PeriodicReviewMixin,
and rules that no longer meet that criteria are deleted.
Called after saving to ensure rules exist for all subclasses of PeriodicReviewMixin and rules that no longer meet that criteria are deleted .
def clean_frequency_rules(self):
        target_models = set(get_periodic_review_models())
        covered_models = set()
        for obj in self.frequency_rules.all():
            if obj.model_class not in target_models:
                obj.delete()
            else:
                covered_models.add(obj.model_class)
        for model_class in target_models:
            if model_class not in covered_models:
                PeriodicReviewFrequencyRule.objects.create(
                    sitesettings=self,
                    content_type=ContentType.objects.get_for_model(model_class),
                    frequency=ReviewFrequencyChoices.TWELVE_MONTHS,
                )
def clean_frequency_rules ( self ) : target_models = set ( get_periodic_review_models ( ) ) covered_models = set ( ) for obj in self . frequency_rules . all ( ) : if obj . model_class not in target_models : obj . delete ( ) else : covered_models . add ( obj . model_class ) for model_class in target_models : if model_class not in covered_models : PeriodicReviewFrequencyRule . objects . create ( sitesettings = self , content_type = ContentType . objects . get_for_model ( model_class ) , frequency = ReviewFrequencyChoices . TWELVE_MONTHS , )
Called after saving to ensure rules exist for all subclasses of PeriodicReviewMixin,
and rules that no longer meet that criteria are deleted.
Called after saving to ensure rules exist for all subclasses of PeriodicReviewMixin and rules that no longer meet that criteria are deleted .
"""
        Called after saving to ensure rules exist for all subclasses of PeriodicReviewMixin,
        and rules that no longer meet that criteria are deleted.
        """
self