<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def clean(self, *args, **kwargs):
 """ Check if rating can be inserted for parent node or parent layer """

        if not self.pk:
            node = self.node
            layer = Layer.objects.get(pk=node.layer_id)
            if layer.participation_settings.rating_allowed is not True:
                raise ValidationError("Rating not allowed for this layer")
            if node.participation_settings.rating_allowed is not True:
                raise ValidationError("Rating not allowed for this node")