<commit_before>class Management::WidgetsController < ManagementController
  before_action :set_site
  before_action :authenticate_user_for_site!
  before_action :ensure_management_user, only: :destroy

  def index
    dataset_ids = @site.contexts
                       .map { |c| c.context_datasets.pluck(:dataset_id) }
                       .flatten.uniq

    @widgets = WidgetService.from_datasets dataset_ids
    @widgets = @widgets.map do |x|
      { widget: x,
        edit_url: edit_management_site_widget_step_path(params[:site_slug], x.id),
        delete_url: management_site_widget_step_path(params[:site_slug], x.id) }
    end
    @widgets
  end

  def destroy<commit_msg>Added the revised permission for Contexts Datasets and Widgets<commit_after>class Management::WidgetsController < ManagementController
  before_action :set_site
  before_action :authenticate_user_for_site!
  before_action :ensure_management_user, only: :destroy

  def index
    dataset_ids = @site.get_datasets(current_user).map(&:id)
    @widgets = WidgetService.from_datasets dataset_ids
    @widgets = @widgets.map do |x|
      { widget: x,
        edit_url: edit_management_site_widget_step_path(params[:site_slug], x.id),
        delete_url: management_site_widget_step_path(params[:site_slug], x.id) }
    end
    @widgets
  end

  def destroy
{'fraction_non_alphanumeric': 0.08464419475655431, 'fraction_numerical': 0.0, 'mean_word_length': 3.948148148148148, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2266883', 'n_tokens_mistral': 425, 'n_tokens_neox': 414, 'n_words': 81}