{% extends "admin/change_form.html" %} 
{% load i18n admin_modify %} 
{% load static %}

{% block content %}<div id="content-main">
{% block object-tools %}
{% if change %}{% if not is_popup %}
  <ul class="object-tools"><li><a href="history/" class="historylink">{% trans "History" %}</a></li>
  {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
  </ul>
{% endif %}{% endif %}
{% endblock %}
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %}
{% csrf_token %}
<div>
{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
{% if save_on_top %}{% submit_row %}{% endif %}
{% if errors %}
    <p class="errornote">
    {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
    </p>
    <ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}

{% for fieldset in adminform %}

<fieldset class="module aligned {{ fieldset.classes }}">
	{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
	{% if fieldset.description %}<div class="description">{{ fieldset.description|safe }}</div>{% endif %}
    {% for line in fieldset %}


            {% for field in line %}

		    {% if not change %}
				{% ifequal field.field.name "data" %}
                                <div class="form-row"><p><img src="{% static "admin/img/icon_alert.gif" %}" >&nbsp;{% trans "In order to upload data, first create the timeseries and then try to edit them" %}</p>
			    {% else %}
				  	{% ifequal field.field.name "data_policy" %}
				  	{% else  %}
						<div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ field.field.name }} {% endfor %} ">
						{{ line.errors }}
						<div{% if not line.fields|length_is:"1" %} class="field-box"{% endif %}>
						  {% if field.is_checkbox %}
							  {{ field.field }}{{ field.label_tag }}
						  {% else %}
							  {{ field.label_tag }}{{ field.field }}
						  {% endif %}
						  {% if field.field.field.help_text %}<p class="help">{{ field.field.field.help_text|safe }}</p>{% endif %}
						  </div>
				  {% endifequal %}
				{% endifequal %}
			{% else %} 

				<div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ field.field.name }} {% endfor %} ">
				{{ line.errors }}
				<div{% if not line.fields|length_is:"1" %} class="field-box"{% endif %}>
				  {% if field.is_checkbox %}
					  {{ field.field }}{{ field.label_tag }}
				  {% else %}
					  {{ field.label_tag }}{{ field.field }}
				  {% endif %}
				  {% if field.field.field.help_text %}<p class="help">{{ field.field.field.help_text|safe }}</p>{% endif %}
			  </div>

			{% endif %}
			
		  	{% endfor %}
		  </div>
	 {% endfor %}
</fieldset>


{% endfor %}

{% block after_field_sets %}{% endblock %}

{% for inline_admin_formset in inline_admin_formsets %}
	{% include inline_admin_formset.opts.template %}
{% endfor %}

{% block after_related_objects %}{% endblock %}

{% submit_row %}

{% if adminform and add %}
   <script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script>
{% endif %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}

</div>
</form></div>
{% endblock %}
