<commit_before>- content_for(:title) do
  - @title = @user ? t(:flags_on_users_content, user: @user.login) : t(:flags)
- content_for(:extrajs) do
  :javascript
    $( document ).ready( function( ) {
      $( "form #user_name" ).userAutocomplete( { idEl: $( "#user_id" ) } );
      $( "form #flagger_name" ).userAutocomplete( { idEl: $( "#flagger_user_id" ) } );
      $( "form #flagger_name" ).on( "focus", function( ) {
        $( "form input[name='flagger_type']" ).click( );
      } );
      $( "form #resolver_name" ).userAutocomplete( { idEl: $( "#resolver_user_id" ) } );
      $( "form #taxon_name" ).taxonAutocomplete( { idEl: $( "#taxon_id" ) } );
      $( "form select[name='flaggable_type']" ).change( function( ) {
        if ( $( this ).val( ) === "all" ) {
          $( "form .content-deleted" ).hide( );
        } else {
          $( "form .content-deleted" ).show( );
        }
        $( "form select[name='deleted']" ).val( "any" );
      } );
    });
- content_for :extracss do
  :css
    #controls label { display: block; }
    #controls .flagger-type { padding-left: 20px;}
    #controls input[type=search]::-webkit-search-cancel-button {
      -webkit-appearance: searchfield-cancel-button;
    }
    td.actions { min-width: 150px; }
    .reason, .resolution { max-width: 300px; overflow: hidden; }
    .table img { max-width: 100%; }
    .table blockquote { font-size: 14px; }
.container
  .row
    .col-xs-12
      %h2= @title
      %p.text-muted= t(:flags_explanation, site_name: @site.name)
  .row
    .col-xs-12
      #controls.well
        = form_tag( flags_path, method: "get" ) do
          .row
            .col-xs-3
              .form-group
                %label=t :flagger
                .flagger-type
                  %label.radio
                    %input{ type: "radio", name: "flagger_type", value: "any", checked: @flagger_type == "any" }
                    =t :any_
                  %label.radio
                    %input{ type: "radio", name: "flagger_type", value: "auto", checked: @flagger_type == "auto" }
                    =t :automatic_short
                  %label.radio
                    %input{ type: "radio", name: "flagger_type", value: "user", checked: @flagger_type == "user" }
                    =t :user
                    .form-group
                      %input#flagger_name.form-control{ type: "search", name: "flagger_name", value: @flagger ? @flagger.login : nil, placeholder: t(:start_typing_someones_name) }
                      %input#flagger_user_id.form-control{ type: "hidden", name: "flagger_user_id", value: @flagger ? @flagger.id : nil }
            .col-xs-3
              %label#user-form-group.form-group
                =t :content_author
                %input#user_name.form-control{ type: "search", name: "user_name", value: @user ? @user.login : nil, placeholder: t(:start_typing_someones_name) }
                %input#user_id.form-control{ type: "hidden", name: "user_id", value: @user ? @user.id : nil }
              .form-group
                %label=t :content_type
                :ruby
                  flaggable_type_options = options_for_select( ( ["all"] + FlagsController::FLAG_MODELS.sort ).map {|t|
                    [I18n.t( t, default: t ), t]
                  }, @flaggable_type )
                = select_tag :flaggable_type, flaggable_type_options, class: "select form-control"
              - if @flaggable_type == "Taxon"
                %label.form-group
                  =t :taxon
                  %input{ type: "text", name: "taxon_name", id: "taxon_name", placeholder: t(:start_typing_taxon_name, default: "" ), class: "form-control" }
                  %input{ type: "hidden", name: "taxon_id", id: "taxon_id", value: @taxon.try(:id) }
              %div{ class: "content-deleted form-group #{%w(yes no).include?( @deleted ) ? "" : "hidden"}"}
                %label=t :content_deleted
                :ruby
                  deleted_options = options_for_select( %w(any yes no).map {|t|
                    [I18n.t( t, default: t ), t]
                  }, @deleted )
                = select_tag :deleted, deleted_options, class: "select form-control"
            .col-xs-3
              %label=t :reason
              .form-group
                - [Flag::SPAM, Flag::COPYRIGHT_INFRINGEMENT, Flag::INAPPROPRIATE, "other"].each do |f|
                  %label
                    %input{ type: "checkbox", name: "flags[]", value: f, checked: @flag_types.include?( f ) }
                    =t f.parameterize.underscore
              .form-group
                %input.form-control{ type: "search", name: "reason_query", value: @reason_query, placeholder: t(:search_reasons, default: "Search Reasons") }
            .col-xs-3
              .form-group
                %label=t :resolved
                :ruby
                  resolved_options = options_for_select( %w(any yes no).map {|t|
                    [I18n.t( t, default: t ), t]
                  }, @resolved )
                = select_tag :resolved, resolved_options, class: "select form-control"
              %label.form-group
                =t :resolver
                %input#resolver_name.form-control{ type: "search", name: "resolver_name", value: @resolver ? @resolver.login : nil, placeholder: t(:start_typing_someones_name) }
                %input#resolver_user_id.form-control{ type: "hidden", name: "resolver_user_id", value: @resolver ? @resolver.id : nil }
          .row
            .col-xs-12
              = submit_tag t(:filter), class: "btn btn-primary"
              = link_to t(:reset_filters_short), url_for, class: "btn btn-link"
              = hidden_fields_for_params( without: [:flaggable_type, :flag, :flags, :user_id, :user_name, :flagger_type, :flagger_name, :flagger_id, :resolved, :resolver_name, :resolver_user_id, :taxon_name, :taxon_id, :reason_query, :page, :deleted] )
  .row
    .col-xs-12
      %table.table
        %thead
          %tr
            %th=t :flagger
            %th=t :content_author
            %th=t :content_type
            %th=t :content
            %th.reason=t :reason
            %th=t :comments
            %th=t :actions
            %th.resolution=t :flag_resolution
        %tbody
          - for flag in @flags
            - flaggable = flag.flaggable
            - flaggable_class = flaggable.class
            - flaggable = flaggable.becomes( Photo ) if flaggable.is_a?( Photo )
            %tr
              %td
                - if flag.user
                  = link_to_user(flag.user) {|| char_wrap( flag.user.login, 20 )}
                  .small.text-muted
                    = link_to t(:view_all), url_for_params( flagger_type: "user", flagger_user_id: flag.user.id, without: [:flagger_type, :flagger_user_id, :user_id] )
                - elsif flag.user_id == 0
                  = @site.site_name_short
                - else
                  =t :deleted_user
              %td
                - if flag.flaggable_user
                  = link_to_user( flag.flaggable_user ) {|| char_wrap( flag.flaggable_user.login, 20 )}
                  .small.text-muted
                    = link_to t(:view_all), url_for_params( user_id: flag.flaggable_user.login, without: [:user_id] )
              %td= flag.flaggable_type.humanize
              %td
                - if flaggable
                  = link_to(flaggable.to_plain_s, flaggable) if flaggable.respond_to?(:to_plain_s)
                  - if !flaggable.is_a?( Message ) && flaggable.respond_to?( :body ) || flaggable.respond_to?( :description )
                    %blockquote= truncate_with_more( formatted_user_text( flaggable.try_methods(:body, :description) ), length: 200 )<commit_msg>Add link to edit flagged content on /flags<commit_after>- content_for(:title) do
  - @title = @user ? t(:flags_on_users_content, user: @user.login) : t(:flags)
- content_for(:extrajs) do
  :javascript
    $( document ).ready( function( ) {
      $( "form #user_name" ).userAutocomplete( { idEl: $( "#user_id" ) } );
      $( "form #flagger_name" ).userAutocomplete( { idEl: $( "#flagger_user_id" ) } );
      $( "form #flagger_name" ).on( "focus", function( ) {
        $( "form input[name='flagger_type']" ).click( );
      } );
      $( "form #resolver_name" ).userAutocomplete( { idEl: $( "#resolver_user_id" ) } );
      $( "form #taxon_name" ).taxonAutocomplete( { idEl: $( "#taxon_id" ) } );
      $( "form select[name='flaggable_type']" ).change( function( ) {
        if ( $( this ).val( ) === "all" ) {
          $( "form .content-deleted" ).hide( );
        } else {
          $( "form .content-deleted" ).show( );
        }
        $( "form select[name='deleted']" ).val( "any" );
      } );
    });
- content_for :extracss do
  :css
    #controls label { display: block; }
    #controls .flagger-type { padding-left: 20px;}
    #controls input[type=search]::-webkit-search-cancel-button {
      -webkit-appearance: searchfield-cancel-button;
    }
    td.actions { min-width: 150px; }
    .reason, .resolution { max-width: 300px; overflow: hidden; }
    .table img { max-width: 100%; }
    .table blockquote { font-size: 14px; }
.container
  .row
    .col-xs-12
      %h2= @title
      %p.text-muted= t(:flags_explanation, site_name: @site.name)
  .row
    .col-xs-12
      #controls.well
        = form_tag( flags_path, method: "get" ) do
          .row
            .col-xs-3
              .form-group
                %label=t :flagger
                .flagger-type
                  %label.radio
                    %input{ type: "radio", name: "flagger_type", value: "any", checked: @flagger_type == "any" }
                    =t :any_
                  %label.radio
                    %input{ type: "radio", name: "flagger_type", value: "auto", checked: @flagger_type == "auto" }
                    =t :automatic_short
                  %label.radio
                    %input{ type: "radio", name: "flagger_type", value: "user", checked: @flagger_type == "user" }
                    =t :user
                    .form-group
                      %input#flagger_name.form-control{ type: "search", name: "flagger_name", value: @flagger ? @flagger.login : nil, placeholder: t(:start_typing_someones_name) }
                      %input#flagger_user_id.form-control{ type: "hidden", name: "flagger_user_id", value: @flagger ? @flagger.id : nil }
            .col-xs-3
              %label#user-form-group.form-group
                =t :content_author
                %input#user_name.form-control{ type: "search", name: "user_name", value: @user ? @user.login : nil, placeholder: t(:start_typing_someones_name) }
                %input#user_id.form-control{ type: "hidden", name: "user_id", value: @user ? @user.id : nil }
              .form-group
                %label=t :content_type
                :ruby
                  flaggable_type_options = options_for_select( ( ["all"] + FlagsController::FLAG_MODELS.sort ).map {|t|
                    [I18n.t( t, default: t ), t]
                  }, @flaggable_type )
                = select_tag :flaggable_type, flaggable_type_options, class: "select form-control"
              - if @flaggable_type == "Taxon"
                %label.form-group
                  =t :taxon
                  %input{ type: "text", name: "taxon_name", id: "taxon_name", placeholder: t(:start_typing_taxon_name, default: "" ), class: "form-control" }
                  %input{ type: "hidden", name: "taxon_id", id: "taxon_id", value: @taxon.try(:id) }
              %div{ class: "content-deleted form-group #{%w(yes no).include?( @deleted ) ? "" : "hidden"}"}
                %label=t :content_deleted
                :ruby
                  deleted_options = options_for_select( %w(any yes no).map {|t|
                    [I18n.t( t, default: t ), t]
                  }, @deleted )
                = select_tag :deleted, deleted_options, class: "select form-control"
            .col-xs-3
              %label=t :reason
              .form-group
                - [Flag::SPAM, Flag::COPYRIGHT_INFRINGEMENT, Flag::INAPPROPRIATE, "other"].each do |f|
                  %label
                    %input{ type: "checkbox", name: "flags[]", value: f, checked: @flag_types.include?( f ) }
                    =t f.parameterize.underscore
              .form-group
                %input.form-control{ type: "search", name: "reason_query", value: @reason_query, placeholder: t(:search_reasons, default: "Search Reasons") }
            .col-xs-3
              .form-group
                %label=t :resolved
                :ruby
                  resolved_options = options_for_select( %w(any yes no).map {|t|
                    [I18n.t( t, default: t ), t]
                  }, @resolved )
                = select_tag :resolved, resolved_options, class: "select form-control"
              %label.form-group
                =t :resolver
                %input#resolver_name.form-control{ type: "search", name: "resolver_name", value: @resolver ? @resolver.login : nil, placeholder: t(:start_typing_someones_name) }
                %input#resolver_user_id.form-control{ type: "hidden", name: "resolver_user_id", value: @resolver ? @resolver.id : nil }
          .row
            .col-xs-12
              = submit_tag t(:filter), class: "btn btn-primary"
              = link_to t(:reset_filters_short), url_for, class: "btn btn-link"
              = hidden_fields_for_params( without: [:flaggable_type, :flag, :flags, :user_id, :user_name, :flagger_type, :flagger_name, :flagger_id, :resolved, :resolver_name, :resolver_user_id, :taxon_name, :taxon_id, :reason_query, :page, :deleted] )
  .row
    .col-xs-12
      %table.table
        %thead
          %tr
            %th=t :flagger
            %th=t :content_author
            %th=t :content_type
            %th=t :content
            %th.reason=t :reason
            %th=t :comments
            %th=t :actions
            %th.resolution=t :flag_resolution
        %tbody
          - for flag in @flags
            - flaggable = flag.flaggable
            - flaggable_class = flaggable.class
            - flaggable = flaggable.becomes( Photo ) if flaggable.is_a?( Photo )
            %tr
              %td
                - if flag.user
                  = link_to_user(flag.user) {|| char_wrap( flag.user.login, 20 )}
                  .small.text-muted
                    = link_to t(:view_all), url_for_params( flagger_type: "user", flagger_user_id: flag.user.id, without: [:flagger_type, :flagger_user_id, :user_id] )
                - elsif flag.user_id == 0
                  = @site.site_name_short
                - else
                  =t :deleted_user
              %td
                - if flag.flaggable_user
                  = link_to_user( flag.flaggable_user ) {|| char_wrap( flag.flaggable_user.login, 20 )}
                  .small.text-muted
                    = link_to t(:view_all), url_for_params( user_id: flag.flaggable_user.login, without: [:user_id] )
              %td= flag.flaggable_type.humanize
              %td
                - if flaggable
                  = link_to(flaggable.to_plain_s, flaggable) if flaggable.respond_to?(:to_plain_s)
                  - if flaggable.respond_to?( :editable_by? ) && flaggable.editable_by?( current_user ) && defined? "edit_#{flaggable.class.name.underscore}_path"
                    = link_to send( "edit_#{flaggable.class.name.underscore}_path", flaggable ) do
                      %i.fa.fa-pencil
                  - if !flaggable.is_a?( Message ) && flaggable.respond_to?( :body ) || flaggable.respond_to?( :description )
                    %blockquote= truncate_with_more( formatted_user_text( flaggable.try_methods(:body, :description) ), length: 200 )
{'fraction_non_alphanumeric': 0.13924693631341672, 'fraction_numerical': 0.0050796875992126485, 'mean_word_length': 1.880921895006402, 'pattern_counts': {'":': 0, '<': 3, '<?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': '351990', 'n_tokens_mistral': 5113, 'n_tokens_neox': 4921, 'n_words': 1010}