<commit_before># frozen_string_literal: true

module GobiertoAdmin
  module GobiertoParticipation
    module Processes
      class ProcessContributionContainersController < Processes::BaseController

        helper_method :gobierto_participation_contribution_container_preview_url

        def index
          @contribution_containers = find_process.contribution_containers
          @archived_contribution_containers = find_process.contribution_containers.only_archived
        end

        def show
          @contribution_container = find_contribution_container
          @process = @contribution_container.process
          @votes_headers = ::GobiertoParticipation::ContributionDecorator.headings
        end

        def new
          @process = find_process
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @contribution_container_form = ContributionContainerForm.new(site_id: current_site.id,
                                                                       process_id: @process.id,
                                                                       admin_id: current_admin.id)
        end

        def edit
          @contribution_container = find_contribution_container
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @contribution_container_form = ContributionContainerForm.new(
            @contribution_container.attributes.except(*ignored_contribution_container_attributes)
          )
        end

        def create
          @process = find_process
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @contribution_container_form = ContributionContainerForm.new(contribution_container_params.merge(site_id: current_site.id,
                                                                                                           process_id: @process.id,
                                                                                                           admin_id: current_admin.id))

          if @contribution_container_form.save
            track_create_activity

            redirect_to(
              edit_admin_participation_process_contribution_container_path(
                process_id: @process.id,
                id: @contribution_container_form.contribution_container.id), notice: t(".success_html",
                                                                             link: gobierto_participation_contribution_container_preview_url(@contribution_container_form.contribution_container))
            )
          else
            render :edit
          end
        end

        def update
          @contribution_container = find_contribution_container
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @process = @contribution_container.process
          @contribution_container_form = ContributionContainerForm.new(contribution_container_params.merge(id: @contribution_container.id,
                                                                                                           process_id: @process.id,
                                                                                                           admin_id: current_admin.id))
          if @contribution_container_form.save
            track_update_activity

            redirect_to(
              edit_admin_participation_process_contribution_container_path(
                id: @contribution_container_form.contribution_container.id,
                process_id: @process.id), notice: t(".success_html",
                                          link: gobierto_participation_contribution_container_preview_url(@contribution_container_form.contribution_container))
            )<commit_msg>Add host: current_site.domain to preview contribution container url<commit_after># frozen_string_literal: true

module GobiertoAdmin
  module GobiertoParticipation
    module Processes
      class ProcessContributionContainersController < Processes::BaseController

        helper_method :gobierto_participation_contribution_container_preview_url

        def index
          @contribution_containers = find_process.contribution_containers
          @archived_contribution_containers = find_process.contribution_containers.only_archived
        end

        def show
          @contribution_container = find_contribution_container
          @process = @contribution_container.process
          @votes_headers = ::GobiertoParticipation::ContributionDecorator.headings
        end

        def new
          @process = find_process
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @contribution_container_form = ContributionContainerForm.new(site_id: current_site.id,
                                                                       process_id: @process.id,
                                                                       admin_id: current_admin.id)
        end

        def edit
          @contribution_container = find_contribution_container
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @contribution_container_form = ContributionContainerForm.new(
            @contribution_container.attributes.except(*ignored_contribution_container_attributes)
          )
        end

        def create
          @process = find_process
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @contribution_container_form = ContributionContainerForm.new(contribution_container_params.merge(site_id: current_site.id,
                                                                                                           process_id: @process.id,
                                                                                                           admin_id: current_admin.id))

          if @contribution_container_form.save
            track_create_activity

            redirect_to(
              edit_admin_participation_process_contribution_container_path(
                process_id: @process.id,
                id: @contribution_container_form.contribution_container.id), notice: t(".success_html",
                                                                             link: gobierto_participation_contribution_container_preview_url(@contribution_container_form.contribution_container, host: current_site.domain))
            )
          else
            render :edit
          end
        end

        def update
          @contribution_container = find_contribution_container
          @contribution_container_visibility_levels = contribution_container_visibility_levels
          @process = @contribution_container.process
          @contribution_container_form = ContributionContainerForm.new(contribution_container_params.merge(id: @contribution_container.id,
                                                                                                           process_id: @process.id,
                                                                                                           admin_id: current_admin.id))
          if @contribution_container_form.save
            track_update_activity

            redirect_to(
              edit_admin_participation_process_contribution_container_path(
                id: @contribution_container_form.contribution_container.id,
                process_id: @process.id), notice: t(".success_html",
                                          link: gobierto_participation_contribution_container_preview_url(@contribution_container_form.contribution_container, host: current_site.domain))
            )
{'fraction_non_alphanumeric': 0.04314329738058552, 'fraction_numerical': 0.0, 'mean_word_length': 1.7768270944741533, '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': 62, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2150097', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1589, 'n_words': 237}