<commit_before>- content_for(:title) do
  = t(:curating)
  = @user ? @user.login : t(:users)
- content_for :extrajs do
  :javascript
    $( document ).ready( function( ) {
      $( "#reject_user_name" ).userAutocomplete( {
        idEl: $( "#reject_user_id" ),
        afterSelect: function( ui ) {
          $( "#reject_user_id" ).val( ui.item.user_id );
        }
      } );
      $( "#site-admins .dropdown-menu" ).on( "click", function( e ) {
        e.stopPropagation( );
      } );
    } );
  :javascript
    $( document ).ready( function( ) {
      $( "#site-admins input[type='checkbox']" ).on( "change", function( e ) {
        $.ajax({
          type: $( this ).is( ":checked" ) ? "POST" : "DELETE",
          url: "/site_admins",
          data: {
            site_admin: {
              user_id: #{ @display_user.id },
              site_id: $( this ).val( )
            }
          },
          success: function( data ) {
            console.log( "success" );
          },
          error: function( data ) {
            console.log( "error" );
          },
          dataType: "JSON"
        });
      } );
    } );
= content_for :extracss do
  :css
    .dropdown-menu.site-admins li {
      padding: 3px 10px;
    }
.container
  .row
    .col-xs-12
      %form.stacked.form-inline{ method: "get", action: users_admin_path }
        %input.form-control#id{ name: "q", type: "search", value: @q }
        %input.btn.btn-default{ type: "submit", value: "Search" }
  .row
    .col-xs-8
      %h3 Basics
      %table.table
        - basic_attrs = %w(id login name email created_at updated_at time_zone description last_ip last_active locale site_id place_id search_place_id spammer spam_count suspended_at suspension_reason suspended_by_user_id)
        - for user_attr in basic_attrs
          %tr
            %th= user_attr
            %td{ style: "width: 100%" }= @display_user.send(user_attr).to_s.html_safe
      %h3 Other Attributes
      %table.table
        - for user_attr in ( User.column_names - basic_attrs - %w(encrypted_password password_salt remember_token remember_token_expires_at confirmation_token deleted_at old_preferences state) ).sort
          %tr
            %th= user_attr
            %td{ style: "width: 100%" }= @display_user.send(user_attr).to_s.html_safe
      %h3 Preferences
      %table.table
        - @display_user.preferences.sort_by{|p,v| p}.each do |pref,val|
          %tr
            %th= pref
            %td= val
      %h3 Misc.
      %table.table
        %tr
          %th Recent user agents
          %td
            - if !<EMAIL>?
              %ul
                - for observation in @observations
                  - next if observation.user_agent.blank?
                  %li
                    = observation.user_agent.gsub(/(MSIE|Safari|Chrome|Opera|Firefox|iNaturalist)/, "<u>\\1</u>").html_safe
            - else
              No observations to check
        %tr
          %th Blocks
          %td
            - if @display_user.user_blocks.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_blocks.limit( 100 ).each do |ub|
                  %li= link_to_user ub.blocked_user
              %p.text-muted
                = @display_user.user_blocks.count
                total
        %tr
          %th Blocked by
          %td
            - if @display_user.user_blocks_as_blocked_user.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_blocks_as_blocked_user.limit( 100 ).each do |ub|
                  %li= link_to_user ub.user
              %p.text-muted
                = @display_user.user_blocks_as_blocked_user.count
                total
        %tr
          %th Mutes
          %td
            - if @display_user.user_mutes.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_mutes.limit( 100 ).each do |um|
                  %li= link_to_user um.muted_user
              %p.text-muted
                = @display_user.user_mutes.count
                total
        %tr
          %th Muted by
          %td
            - if @display_user.user_mutes_as_muted_user.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_mutes_as_muted_user.limit( 100 ).each do |um|
                  %li= link_to_user um.user
              %p.text-muted
                = @display_user.user_mutes_as_muted_user.count
                total
        - if @display_user.curator_sponsor
          %tr
            %th User who made this user a curator
            %td= link_to_user @display_user.curator_sponsor
        %tr
          %th User Privileges
          %td
            - if @display_user.user_privileges.blank?
              None yet
            - else
              %ul.plain
                - UserPrivilege::PRIVILEGES.each do |privilege|
                  %li.lined.clearfix
                    %strong= privilege
                    - if up = @display_user.user_privileges.where( privilege: privilege ).first
                      %p.success
                        Earned on
                        = up.created_at.to_date
                      - if up.revoked?
                        .alert.alert-warning
                          Revoked on
                          = up.revoked_at
                          by
                          = link_to_user up.revoke_user
                          %blockquote= up.revoke_reason
                          = button_to restore_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-success", form_class: "inlineblock" do
                            Restore
                            %code= privilege
                            privilege
                          = button_to reset_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-warning", title: "Remove the existing privilege record and check to see if the user has earned it agin", form_class: "inlineblock", style: "margin-left: 10px;" do
                            Reset
                            %code= privilege
                            privilege
                      - else
                        = link_to_toggle_box "Revoke" do
                          = form_tag revoke_user_privilege_admin_path, method: :put, class: "form-inline", style: "display: flex" do |f|
                            = hidden_field_tag :user_id, @display_user.id
                            = hidden_field_tag :privilege, privilege
                            = text_field_tag :reason, "", placeholder: "From whence springs thy judgement?", class: "form-control", style: "width: 100%; margin-right: 10px;"
                            = button_tag class: "btn btn-danger" do
                              Revoke
                              %code= privilege
                              privilege
                        = button_to reset_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-warning", style: "margin-top: 10px", title: "Remove the existing privilege record and check to see if the user has earned it again. If they've earned it, this will reset the date they earned the privilege to today." do
                          Reset
                          %code= privilege
                          privilege
                    - else
                      = button_to grant_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-success" do
                        Grant
                        %code= privilege
                        privilege
        %tr
          %th Parent
          %td<commit_msg>Admins should be able to grant privileges even if none have been earned yet<commit_after>- content_for(:title) do
  = t(:curating)
  = @user ? @user.login : t(:users)
- content_for :extrajs do
  :javascript
    $( document ).ready( function( ) {
      $( "#reject_user_name" ).userAutocomplete( {
        idEl: $( "#reject_user_id" ),
        afterSelect: function( ui ) {
          $( "#reject_user_id" ).val( ui.item.user_id );
        }
      } );
      $( "#site-admins .dropdown-menu" ).on( "click", function( e ) {
        e.stopPropagation( );
      } );
    } );
  :javascript
    $( document ).ready( function( ) {
      $( "#site-admins input[type='checkbox']" ).on( "change", function( e ) {
        $.ajax({
          type: $( this ).is( ":checked" ) ? "POST" : "DELETE",
          url: "/site_admins",
          data: {
            site_admin: {
              user_id: #{ @display_user.id },
              site_id: $( this ).val( )
            }
          },
          success: function( data ) {
            console.log( "success" );
          },
          error: function( data ) {
            console.log( "error" );
          },
          dataType: "JSON"
        });
      } );
    } );
= content_for :extracss do
  :css
    .dropdown-menu.site-admins li {
      padding: 3px 10px;
    }
.container
  .row
    .col-xs-12
      %form.stacked.form-inline{ method: "get", action: users_admin_path }
        %input.form-control#id{ name: "q", type: "search", value: @q }
        %input.btn.btn-default{ type: "submit", value: "Search" }
  .row
    .col-xs-8
      %h3 Basics
      %table.table
        - basic_attrs = %w(id login name email created_at updated_at time_zone description last_ip last_active locale site_id place_id search_place_id spammer spam_count suspended_at suspension_reason suspended_by_user_id)
        - for user_attr in basic_attrs
          %tr
            %th= user_attr
            %td{ style: "width: 100%" }= @display_user.send(user_attr).to_s.html_safe
      %h3 Other Attributes
      %table.table
        - for user_attr in ( User.column_names - basic_attrs - %w(encrypted_password password_salt remember_token remember_token_expires_at confirmation_token deleted_at old_preferences state) ).sort
          %tr
            %th= user_attr
            %td{ style: "width: 100%" }= @display_user.send(user_attr).to_s.html_safe
      %h3 Preferences
      %table.table
        - @display_user.preferences.sort_by{|p,v| p}.each do |pref,val|
          %tr
            %th= pref
            %td= val
      %h3 Misc.
      %table.table
        %tr
          %th Recent user agents
          %td
            - if !<EMAIL>?
              %ul
                - for observation in @observations
                  - next if observation.user_agent.blank?
                  %li
                    = observation.user_agent.gsub(/(MSIE|Safari|Chrome|Opera|Firefox|iNaturalist)/, "<u>\\1</u>").html_safe
            - else
              No observations to check
        %tr
          %th Blocks
          %td
            - if @display_user.user_blocks.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_blocks.limit( 100 ).each do |ub|
                  %li= link_to_user ub.blocked_user
              %p.text-muted
                = @display_user.user_blocks.count
                total
        %tr
          %th Blocked by
          %td
            - if @display_user.user_blocks_as_blocked_user.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_blocks_as_blocked_user.limit( 100 ).each do |ub|
                  %li= link_to_user ub.user
              %p.text-muted
                = @display_user.user_blocks_as_blocked_user.count
                total
        %tr
          %th Mutes
          %td
            - if @display_user.user_mutes.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_mutes.limit( 100 ).each do |um|
                  %li= link_to_user um.muted_user
              %p.text-muted
                = @display_user.user_mutes.count
                total
        %tr
          %th Muted by
          %td
            - if @display_user.user_mutes_as_muted_user.count == 0
              None
            - else
              %ul.plain
                - @display_user.user_mutes_as_muted_user.limit( 100 ).each do |um|
                  %li= link_to_user um.user
              %p.text-muted
                = @display_user.user_mutes_as_muted_user.count
                total
        - if @display_user.curator_sponsor
          %tr
            %th User who made this user a curator
            %td= link_to_user @display_user.curator_sponsor
        %tr
          %th User Privileges
          %td
            %ul.plain
              - UserPrivilege::PRIVILEGES.each do |privilege|
                %li.lined.clearfix
                  %strong= privilege
                  - if up = @display_user.user_privileges.where( privilege: privilege ).first
                    %p.success
                      Earned on
                      = up.created_at.to_date
                    - if up.revoked?
                      .alert.alert-warning
                        Revoked on
                        = up.revoked_at
                        by
                        = link_to_user up.revoke_user
                        %blockquote= up.revoke_reason
                        = button_to restore_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-success", form_class: "inlineblock" do
                          Restore
                          %code= privilege
                          privilege
                        = button_to reset_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-warning", title: "Remove the existing privilege record and check to see if the user has earned it agin", form_class: "inlineblock", style: "margin-left: 10px;" do
                          Reset
                          %code= privilege
                          privilege
                    - else
                      = link_to_toggle_box "Revoke" do
                        = form_tag revoke_user_privilege_admin_path, method: :put, class: "form-inline", style: "display: flex" do |f|
                          = hidden_field_tag :user_id, @display_user.id
                          = hidden_field_tag :privilege, privilege
                          = text_field_tag :reason, "", placeholder: "From whence springs thy judgement?", class: "form-control", style: "width: 100%; margin-right: 10px;"
                          = button_tag class: "btn btn-danger" do
                            Revoke
                            %code= privilege
                            privilege
                      = button_to reset_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-warning", style: "margin-top: 10px", title: "Remove the existing privilege record and check to see if the user has earned it again. If they've earned it, this will reset the date they earned the privilege to today." do
                        Reset
                        %code= privilege
                        privilege
                  - else
                    = button_to grant_user_privilege_admin_path( user_id: @display_user.id, privilege: privilege ), method: :put, class: "btn btn-success" do
                      Grant
                      %code= privilege
                      privilege
        %tr
          %th Parent
          %td
{'fraction_non_alphanumeric': 0.09518909184461023, 'fraction_numerical': 0.005402624131721122, 'mean_word_length': 1.3947327891575543, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, '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': '3207638', 'n_tokens_mistral': 4497, 'n_tokens_neox': 4321, 'n_words': 1029}