<commit_before><div>
  <% if @model.attachments.empty? -%>
  <p>No files</p>
  <% else -%>
  <table id="file-table" border="1">
    <thead>
      <tr>
        <th>File</th>
        <th>Type</th>
        <th>Description</th>
        <th>Last updated</th>
        <th></th>
      </tr>
    </thead>

    <tbody>
      <% @model.attachments.sort_by {|f| f.filename.downcase}.each do |f| -%>

      <tr>
        <td><%= f.filename -%></td>
        <td><%= f.type -%></td>
        <td><%= f.description %></td>
        <td><%= distance_of_time_in_words(Time.now, f.updated_at) -%> ago, by <%= person_link(f.person) %></td>
        <td><%= link_to("Delete", {:controller => :file, :action => :delete, :id => @model.id, :file_id => f.id}, :confirm => "Really delete '#{f.filename}'?" ) %></td>
      </tr>
      <% end -%>
    </tbody>

  </table>

  <% end -%>

  <% if @person %>
  <h2>Add or update a file</h2>

  <% form_tag({:controller => :file, :action => :create}, {:multipart => true}) do %>
  <table>
    <tr>
      <td>File</td>
      <td><%= file_field_tag :uploaded_file, :size => 60 %>
        <%= hidden_field_tag :id, @model.id %></td>
    </tr>

    <tr>
      <td>Description</td>
      <td><%= text_field_tag :description, nil, :size => 80 %></td>
    </tr>

    <tr>
      <td>File type:</td>
      <td><%= select("document", "type", NodeAttachment::TYPES.keys.sort, { :include_blank => true }) %></td>
    </tr>

    <tr>
      <td colspan="2"><%= submit_tag "Upload file", :class => "submit" %></td>
    </tr>

  </table>
  <% end %>
  <% end %>
</div><commit_msg>Added validation for form upload<commit_after><div>
  <% if @model.attachments.empty? -%>
  <p>No files</p>
  <% else -%>
  <table id="file-table" border="1">
    <thead>
      <tr>
        <th>File</th>
        <th>Type</th>
        <th>Description</th>
        <th>Last updated</th>
        <th></th>
      </tr>
    </thead>

    <tbody>
      <% @model.attachments.sort_by {|f| f.filename.downcase}.each do |f| -%>

      <tr>
        <td><%= f.filename -%></td>
        <td><%= f.type -%></td>
        <td><%= f.description %></td>
        <td><%= distance_of_time_in_words(Time.now, f.updated_at) -%> ago, by <%= person_link(f.person) %></td>
        <td><%= link_to("Delete", {:controller => :file, :action => :delete, :id => @model.id, :file_id => f.id}, :confirm => "Really delete '#{f.filename}'?" ) %></td>
      </tr>
      <% end -%>
    </tbody>

  </table>

  <% end -%>

  <% if @person %>
  <h2>Add or update a file</h2>

  <% form_tag({:controller => :file, :action => :create}, {:multipart => true, :id => 'new-file-form'}) do %>
  <table>
    <tr>
      <td>File</td>
      <td><%= file_field_tag :uploaded_file, :size => 60 %>
        <%= hidden_field_tag :id, @model.id %></td>
    </tr>

    <tr>
      <td>Description</td>
      <td><%= text_field_tag :description, nil, :size => 80 %></td>
    </tr>

    <tr>
      <td>File type:</td>
      <td><%= select("document", "type", NodeAttachment::TYPES.keys.sort, { :include_blank => true }) %></td>
    </tr>

    <tr>
      <td colspan="2"><%= submit_tag "Upload file", :class => "submit" %></td>
    </tr>

  </table>
  <% end %>
  <% end %>
</div>

<script>
  $("#new-file-form").validate({
  rules: {
      'document[type]': 'required',
      'uploaded_file': 'required',
      'description': 'required'
   } } );
</script>

{'fraction_non_alphanumeric': 0.2465226398342705, 'fraction_numerical': 0.004735128736312519, 'mean_word_length': 2.4106962663975784, 'pattern_counts': {'":': 0, '<': 165, '<?xml version=': 0, '>': 190, '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': '5096259', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1287, 'n_words': 263}