docs: def get_user_group_perms(user_or_group, obj):
      """Get permissins for user groups.
  
      Based on guardian.core.ObjectPermissionChecker.
  
      """
      user, group = get_identity(user_or_group)
  
      if user and not user.is_active:
          return [], []
      user_model = get_user_model()
      ctype = ContentType.objects.get_for_model(obj)
  
      group_model = get_group_obj_perms_model(obj)
      group_rel_name = group_model.permission.field.related_query_name()
      if user:
          user_rel_name = user_model.groups.field.related_query_name()
          group_filters = {user_rel_name: user}
      else:
          group_filters = {'pk': group.pk}
      if group_model.objects.is_generic():
          group_filters.update({
              '{}__content_type'.format(group_rel_name): ctype,
              '{}__object_pk'.format(group_rel_name): obj.pk,
          })
      else:
          group_filters['{}__content_object'.format(group_rel_name)] = obj
  
      user_perms, group_perms = [], []
  
      if user:
          perms_qs = Permission.objects.filter(content_type=ctype)
          if user.is_superuser:
              user_perms = list(chain(perms_qs.values_list("codename", flat=True)))
          else:
              model = get_user_obj_perms_model(obj)
              related_name = model.permission.field.related_query_name()
              user_filters = {'{}__user'.format(related_name): user}
              if model.objects.is_generic():
                  user_filters.update({
                      '{}__content_type'.format(related_name): ctype,
                      '{}__object_pk'.format(related_name): obj.pk,
                  })
              else:
                  user_filters['{}__content_object'.format(related_name)] = obj
  
              user_perms_qs = perms_qs.filter(**user_filters)
              user_perms = list(chain(user_perms_qs.values_list("codename", flat=True)))
  
      group_perms_qs = Group.objects.filter(**group_filters)
      group_perms = list(chain(group_perms_qs.order_by("pk").values_list(
          "pk", "name", "{}__permission__codename".format(group_rel_name))))
  
      group_perms = _group_groups(group_perms)
  
      return user_perms, group_perms