{% extends 'tom_common/base.html' %}
{% load bootstrap4 static observation_extras dataproduct_extras tom_education_extras %}
{% block title %} Observation record: {{ object.id }} {% endblock %}
{% block additional_css %}
<link rel="stylesheet" href="{% static 'tom_observations/css/main.css' %}">
{% endblock %}
{% block content %}
<h2>&crarr;&nbsp;<a href="{% url 'tom_education:target_detail' object.target.pk %}"> {{ object.target.name }}</a></h2>
<div class="row">
  <div class="col-md-8">
    <a class="btn btn-success" href="{{ object.url }}">View at observatory »</a>
    <p><strong>Created:</strong> {{ object.created }} <strong>Modified:</strong> {{ object.modified }}</p>
    <p><strong>Status:</strong> {{ object.status }}</p>
    <p></p>
    {% include 'tom_dataproducts/upload_dataproduct.html' %}

    <h4>Saved Data Products</h4>
    <form method="POST" action="{% url 'tom_dataproducts:group-data' %}">
      {% csrf_token %}
      <div class="form-row">
        <div class="col-sm-4">
          {% bootstrap_field form.group layout='inline' %}
          {% for product in data_products.saved %}
            <input type="hidden" name="products" value="{{ product.id }}">
          {% endfor %}
        </div>
        <div class="col-sm-8">
          {% buttons %}
          <input type="submit" value="Add to group" class="btn btn-primary">
          <a href="{% url 'dataproducts:group-list' %}">Manage groups</a>
          {% endbuttons %}
        </div>
      </div>
      {% dataproduct_list_for_observation_saved data_products request %}
    </form>

    <form method="POST" action="{% url 'tom_dataproducts:save' object.id %}">
      {% csrf_token %}
      <input type="hidden" value="{{ object.facility }}" name="facility">
      <input type="hidden" value="ALL" name="products">
      <input type="submit" value="Save All" class="btn btn-primary float-right">
    </form>
    <form method="POST" action="{% url 'tom_dataproducts:save' object.id %}">
      {% csrf_token %}
      <input type="hidden" value="{{ object.facility }}" name="facility">
      <div class="row">
        <div class="col-md-9">
          <h4>Unsaved data products</h4>
        </div>
        <div class="col-md-3">
          <input type="submit" value="Save Selected" class="btn btn-primary">
        </div>
      </div>
      <div class="row">
        <div class="col-md-9">
            {% dataproduct_selection_buttons false %}
        </div>
      </div>
      {% dataproduct_list_for_observation_unsaved data_products %}
    </form>
  </div>
  <div class="col-md-4">
    <h4>Request Parameters</h4>
    <dl class="row">
      {% for k,v in object.parameters_as_dict.items %}
      <dt class="col-sm-6">{{ k }}</dt>
      <dd class="col-sm-6">{{ v }}</dd>
      {% endfor %}
    </dl>
  </div>
</div>

<script type='text/javascript' src='{% static 'tom_education/dataproduct_checklist_utils.js' %}'></script>

{% endblock %}
