<commit_before><% content_for :page_title do %>
  <%= Spree.t(:promotions) %>
<% end %>

<% content_for :page_actions do %>
  <%= button_link_to Spree.t(:new_promotion), spree.new_admin_promotion_path, :class => "btn-success", :icon => 'add' %>
<% end %>

<% content_for :table_filter do %>
  <div data-hook="admin_promotions_index_search">
    <%= search_form_for [:admin, @search] do |f| %>
      <div class="form-group">
        <%= label_tag :q_name_cont, Spree.t(:name) %>
        <%= f.text_field :name_cont, tabindex: 1, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= label_tag :q_code_cont, Spree.t(:code) %>
        <%= f.text_field :code_cont, tabindex: 1, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= label_tag :q_path_cont, Spree.t(:path) %>
        <%= f.text_field :path_cont, tabindex: 1, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= label_tag :q_promotion_category_id_eq, Spree.t(:promotion_category) %>
        <%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { :include_blank => Spree.t('match_choices.all') }, { :class => 'select2' }) %>
      </div>

      <div data-hook="admin_promotions_index_search_buttons" class="form-actions">
        <%= button Spree.t(:filter_results), 'search' %>
      </div>
    <% end %>
  </div>
<% end %>

<%= paginate @promotions %>

<% if @promotions.any? %>
  <table class="table table-hover index">
    <thead>
      <tr>
        <th><%= Spree.t(:name) %></th>
        <th><%= Spree.t(:code) %></th>
        <th><%= Spree.t(:description) %></th>
        <th><%= Spree.t(:usage_limit) %></th>
        <th><%= Spree.t(:promotion_uses) %></th>
        <th><%= Spree.t(:expiration) %></th>
        <th class="actions"></th>
      </tr>
    </thead>
    <tbody>
      <% @promotions.each do |promotion| %>
        <tr id="<%= spree_dom_id promotion %>">
          <td><%= promotion.name %></td>
          <td><%= promotion.code %></td>
          <td><%= promotion.description %></td>
          <td><%= promotion.usage_limit.nil? ? "∞" : promotion.usage_limit  %></td>
          <td><%= Spree.t(:current_promotion_usage, :count => promotion.credits_count) %></td>
          <td><%= promotion.expires_at.to_date.to_s(:short_date) if promotion.expires_at %></td>
          <td class="actions actions-2">
            <%= link_to_edit promotion, :no_text => true %>
            <%= link_to_delete promotion, :no_text => true %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <div class="alert alert-info no-objects-found">
    <%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/promotion')) %>,
    <%= link_to Spree.t(:add_one), spree.new_admin_promotion_path %>!
  </div>
<% end %><commit_msg>Link to promotion name on promo index<commit_after><% content_for :page_title do %>
  <%= Spree.t(:promotions) %>
<% end %>

<% content_for :page_actions do %>
  <%= button_link_to Spree.t(:new_promotion), spree.new_admin_promotion_path, :class => "btn-success", :icon => 'add' %>
<% end %>

<% content_for :table_filter do %>
  <div data-hook="admin_promotions_index_search">
    <%= search_form_for [:admin, @search] do |f| %>
      <div class="form-group">
        <%= label_tag :q_name_cont, Spree.t(:name) %>
        <%= f.text_field :name_cont, tabindex: 1, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= label_tag :q_code_cont, Spree.t(:code) %>
        <%= f.text_field :code_cont, tabindex: 1, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= label_tag :q_path_cont, Spree.t(:path) %>
        <%= f.text_field :path_cont, tabindex: 1, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= label_tag :q_promotion_category_id_eq, Spree.t(:promotion_category) %>
        <%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { :include_blank => Spree.t('match_choices.all') }, { :class => 'select2' }) %>
      </div>

      <div data-hook="admin_promotions_index_search_buttons" class="form-actions">
        <%= button Spree.t(:filter_results), 'search' %>
      </div>
    <% end %>
  </div>
<% end %>

<%= paginate @promotions %>

<% if @promotions.any? %>
  <table class="table table-hover index">
    <thead>
      <tr>
        <th><%= Spree.t(:name) %></th>
        <th><%= Spree.t(:code) %></th>
        <th><%= Spree.t(:description) %></th>
        <th><%= Spree.t(:usage_limit) %></th>
        <th><%= Spree.t(:promotion_uses) %></th>
        <th><%= Spree.t(:expiration) %></th>
        <th class="actions"></th>
      </tr>
    </thead>
    <tbody>
      <% @promotions.each do |promotion| %>
        <tr id="<%= spree_dom_id promotion %>">
          <td><%= link_to promotion.name, edit_admin_promotion_path(promotion) %></td>
          <td><%= promotion.code %></td>
          <td><%= promotion.description %></td>
          <td><%= promotion.usage_limit.nil? ? "∞" : promotion.usage_limit  %></td>
          <td><%= Spree.t(:current_promotion_usage, :count => promotion.credits_count) %></td>
          <td><%= promotion.expires_at.to_date.to_s(:short_date) if promotion.expires_at %></td>
          <td class="actions actions-2">
            <%= link_to_edit promotion, :no_text => true %>
            <%= link_to_delete promotion, :no_text => true %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <div class="alert alert-info no-objects-found">
    <%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/promotion')) %>,
    <%= link_to Spree.t(:add_one), spree.new_admin_promotion_path %>!
  </div>
<% end %>
{'fraction_non_alphanumeric': 0.20514147688060733, 'fraction_numerical': 0.0024154589371980675, 'mean_word_length': 2.978723404255319, 'pattern_counts': {'":': 0, '<': 191, '<?xml version=': 0, '>': 205, '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': '412587', 'n_tokens_mistral': 2239, 'n_tokens_neox': 2065, 'n_words': 372}