code: def restricted_activities_available_to_user(cls, user):
          
          if not user:
              return []
  
          activities = set(user.restricted_activity_set.values_list("id", flat=True))
  
          if user and user.grade and user.grade.number and user.grade.name:
              grade = user.grade
          else:
              grade = None
  
          if grade is not None and 9 <= grade.number <= 12:
              activities |= set(EighthActivity.objects.filter(**{'{}_allowed'.format(grade.name_plural): True}).values_list("id", flat=True))
  
          for group in user.groups.all():
              activities |= set(group.restricted_activity_set.values_list("id", flat=True))
  
          return list(activities)
docs: Find the restricted activities available to the given user.