<commit_before>{% extends 'dat/base.html' %}

{% block content %}
<div class="container">

  <form method="post" action=".">
    {% csrf_token %}
    {% for field in form %}
    <div class="form-group">
      {{ field.label_tag }}{{ field }}{{ field.errors }}
    </div>
    {% endfor %}
    {{ formset.management_form }}
    <table class="table table-condensed">
      <thead>
        <tr>
          <th>Product</th><th>Disc Dollar</th><th>Disc Percent</th><th>Qty Ordered</th>
        </tr>
      </thead>
      <tbody>
        {% for form in formset %}
        <tr>
          {% for field in form %}
          <td style="width:25%;">{{ field }}{{ field.errors }}</td>
          {% endfor %}
        </tr>
        {% endfor %}
      </tbody>
    </table>
    <input type="submit" value="Save" class="btn btn-primary default" name="save">
  </form>
</div>
{% endblock %}

{% block contentjs %}
<script>
$(document).ready(function(){
  // load up contacts and products from supplier choice
  $('select#supplier').change(function(){
    // contacts
    $.ajax({
      url: '/api/dat/contacts/?represents__id=' + $(this).val(),
      type: 'GET',
      dataType: 'json',
      success: function(xhr, status){
        var options = '<option></option>';
        $(xhr.objects).each(function(i){
          options += '<option value="' + xhr.objects[i].id + '">' + xhr.objects[i].name + '</option>';
        });
        $('select#contact').html(options);
      },
      error: function(xhr, status){
        $('div#errors').html().append('<span>contacts [' + status + ']: ' + xhr.responseText + '</span><br />');
      },
      beforeSend: function(xhr){
        xhr.setRequestHeader('Authorization', 'ApiKey vince:<PASSWORD>');
      }
    });
    // products
    $.ajax({
      url: '/api/inventory-manager/products/?supplier__id=' + $(this).val(),
      type: 'GET',
      dataType: 'json',
      success: function(xhr, status){
        var options = '<option></option>';
        $(xhr.objects).each(function(i){
          options += '<option value="' + xhr.objects[i].sku + '">[' + xhr.objects[i].sku + '] ' + xhr.objects[i].name + '</option>';
        });
        $('select.product').html(options);
      },
      error: function(xhr, status){
        $('div#errors').html().append('<span>contacts [' + status + ']: ' + xhr.responseText + '</span><br />');
      },
      beforeSend: function(xhr){
        xhr.setRequestHeader('Authorization', 'ApiKey <PASSWORD>:<PASSWORD>');
      }
    });
    // deselect products
    $('select.product').val('');
  });
});
</script>
{% endblock %}
<commit_msg>cleaned pocreate<commit_after>{% extends 'dat/base.html' %}

{% block content %}
<div class="container">
  <form method="post" action=".">
    {% csrf_token %}
    {% for field in form %}
    <div class="form-group">
      {{ field.label_tag }}{{ field }}{{ field.errors }}
    </div>
    {% endfor %}
    {{ formset.management_form }}
    <table class="table table-condensed">
      <thead>
        <tr>
          <th>Product</th><th>Disc Dollar</th><th>Disc Percent</th><th>Qty Ordered</th>
        </tr>
      </thead>
      <tbody>
        {% for form in formset %}
        <tr>
          {% for field in form %}
          <td style="width:25%;">{{ field }}{{ field.errors }}</td>
          {% endfor %}
        </tr>
        {% endfor %}
      </tbody>
    </table>
    <input type="submit" value="Save" class="btn btn-primary default" name="save">
  </form>
</div>
{% endblock %}

{% block contentjs %}
<script>
$(document).ready(function(){
  // load up contacts and products from supplier choice
  $('select#supplier').change(function(){
    // contacts
    $.ajax({
      url: '/api/dat/contacts/?represents__id=' + $(this).val(),
      type: 'GET',
      dataType: 'json',
      success: function(xhr, status){
        var options = '<option></option>';
        $(xhr.objects).each(function(i){
          options += '<option value="' + xhr.objects[i].id + '">' + xhr.objects[i].name + '</option>';
        });
        $('select#contact').html(options);
      },
      error: function(xhr, status){
        $('div#errors').html().append('<span>contacts [' + status + ']: ' + xhr.responseText + '</span><br />');
      },
      beforeSend: function(xhr){
        xhr.setRequestHeader('Authorization', 'ApiKey vince:<PASSWORD>');
      }
    });
    // products
    $.ajax({
      url: '/api/inventory-manager/products/?supplier__id=' + $(this).val(),
      type: 'GET',
      dataType: 'json',
      success: function(xhr, status){
        var options = '<option></option>';
        $(xhr.objects).each(function(i){
          options += '<option value="' + xhr.objects[i].sku + '">[' + xhr.objects[i].sku + '] ' + xhr.objects[i].name + '</option>';
        });
        $('select.product').html(options);
      },
      error: function(xhr, status){
        $('div#errors').html().append('<span>contacts [' + status + ']: ' + xhr.responseText + '</span><br />');
      },
      beforeSend: function(xhr){
        xhr.setRequestHeader('Authorization', 'ApiKey vince:<PASSWORD>');
      }
    });
    // deselect products
    $('select.product').val('');
  });
});
</script>
{% endblock %}

{'fraction_non_alphanumeric': 0.2176006162141344, 'fraction_numerical': 0.0007702676680146351, 'mean_word_length': 2.5070898041863607, 'pattern_counts': {'":': 0, '<': 94, '<?xml version=': 0, '>': 94, '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': '1679646', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1659, 'n_words': 307}