<commit_before><% if can?(:create, User) and (controller.action_name == "edit" or (controller.action_name == "update" and !@user.errors.empty?)) %>

  <%= simple_form_for @user, :url => user_path(@user), :html => { :remote => true } do |f| %>
    <fieldset>
      <legend>Edit Your Account</legend>

      <%= f.input :name, input_html: { class: "form-user" } %>
      <%= f.input :authentication_token, label: "API key", input_html: { class: "form-user" } %>
      <%= f.input :password, input_html: { class: "form-user" } %>
      <%= f.input :password_confirmation, input_html: { class: "form-user" } %>
      <%= f.association :publisher, collection: Publisher.order('name').map { |publisher| [publisher.name, publisher.crossref_id] }, input_html: { class: "form-user" } %>

      <div class="form-group">
        <%= f.submit "Save ", class: "btn btn-default" %>
        <%= link_to 'Cancel', user_path(@user), { remote: true, class: 'btn' } %>
      </div>
    </fieldset>
  <% end %>

<% else %>
  <div class="page-header">
    <div class="btn-toolbar btn-sm pull-right">
      <div class="btn-group">
        <%= link_to '<span class="glyphicon glyphicon-pencil"></span>'.html_safe, edit_user_path(@user), { remote: true, class: 'btn btn-default btn-sm', id: 'edit' } %>
      </div>
    </div>
    <h1>
      <%= <EMAIL> %>
    </h1>
  </div>

  <dl class="dl-horizontal">
    <dt>Username</dt>
    <dd><%= @user.username %></dd>
    <% if @user.email.present? %>
      <dt>Email</dt>
      <dd><%= h(@user.email) %></dd>
    <% end %>
    <dt>Role</dt>
    <% if @user.role == "admin" %>
      <dd>Admin - full access to the ALM application</dd>
    <% elsif @user.role == "staff" %>
      <dd>Staff - read access to the admin dashboard</dd>
    <% elsif @user.publisher_id.present? %>
      <dd>Publisher - read/write access to the API</dd>
    <% else %>
      <dd>User - read access to the API</dd>
    <% end %>
    <% if @user.publisher %>
      <dt>Publisher</dt>
      <dd><%= h(@user.publisher.name) %></dd>
    <% end %>
    <dt>API Key</dt>
    <dd><%= @user.authentication_token %></dd>
  </dl>

  <ul class="nav nav-tabs">
    <li class="active"><a href="#reports" data-toggle="tab">Reports</a></li>
    <li><a href="#documentation" data-toggle="tab" title="Documentation">Documentation</a></li>
  </ul>

  <div class="tab-content">
    <div class="tab-pane active" id="reports">
      <%= render :partial => 'reports' %>
    </div>
    <div class="tab-pane" id="documentation">
      <h1>API</h1>
      <%= render :partial => 'docs/show' %>
    </div>
  </div>
<% end %><commit_msg>don't show edit link for regular users<commit_after><% if can?(:create, User) and (controller.action_name == "edit" or (controller.action_name == "update" and !@user.errors.empty?)) %>

  <%= simple_form_for @user, :url => user_path(@user), :html => { :remote => true } do |f| %>
    <fieldset>
      <legend>Edit Your Account</legend>

      <%= f.input :name, input_html: { class: "form-user" } %>
      <%= f.input :authentication_token, label: "API key", input_html: { class: "form-user" } %>
      <%= f.input :password, input_html: { class: "form-user" } %>
      <%= f.input :password_confirmation, input_html: { class: "form-user" } %>
      <%= f.association :publisher, collection: Publisher.order('name').map { |publisher| [publisher.name, publisher.crossref_id] }, input_html: { class: "form-user" } %>

      <div class="form-group">
        <%= f.submit "Save ", class: "btn btn-default" %>
        <%= link_to 'Cancel', user_path(@user), { remote: true, class: 'btn' } %>
      </div>
    </fieldset>
  <% end %>

<% else %>
  <div class="page-header">
    <% if can?(:create, User) %>
      <div class="btn-toolbar btn-sm pull-right">
        <div class="btn-group">
          <%= link_to '<span class="glyphicon glyphicon-pencil"></span>'.html_safe, edit_user_path(@user), { remote: true, class: 'btn btn-default btn-sm', id: 'edit' } %>
        </div>
      </div>
    <% end %>
    <h1>
      <%= <EMAIL> %>
    </h1>
  </div>

  <dl class="dl-horizontal">
    <dt>Username</dt>
    <dd><%= @user.username %></dd>
    <% if @user.email.present? %>
      <dt>Email</dt>
      <dd><%= h(@user.email) %></dd>
    <% end %>
    <dt>Role</dt>
    <% if @user.role == "admin" %>
      <dd>Admin - full access to the ALM application</dd>
    <% elsif @user.role == "staff" %>
      <dd>Staff - read access to the admin dashboard</dd>
    <% else %>
      <dd>User - read access to the API</dd>
    <% end %>
    <% if can?(:create, User) && @user.publisher %>
      <dt>Publisher</dt>
      <dd><%= link_to h(@user.publisher.name), publisher_path(@user.publisher) %></dd>
    <% end %>
    <dt>API Key</dt>
    <dd><%= @user.authentication_token %></dd>
  </dl>

  <ul class="nav nav-tabs">
    <li class="active"><a href="#reports" data-toggle="tab">Reports</a></li>
    <li><a href="#documentation" data-toggle="tab" title="Documentation">Documentation</a></li>
  </ul>

  <div class="tab-content">
    <div class="tab-pane active" id="reports">
      <%= render :partial => 'reports' %>
    </div>
    <div class="tab-pane" id="documentation">
      <h1>API</h1>
      <%= render :partial => 'docs/show' %>
    </div>
  </div>
<% end %>
{'fraction_non_alphanumeric': 0.21898782343987824, 'fraction_numerical': 0.0015220700152207, 'mean_word_length': 2.9977186311787074, 'pattern_counts': {'":': 0, '<': 186, '<?xml version=': 0, '>': 196, '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': '5500300', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1846, 'n_words': 402}