{% load i18n %}
{% load static %}
{% load mini_buildd_tags %}

<div class="mbd-api-box">
	{# <form action="/mini_buildd/api" method="post">{% csrf_token %}  # if we would support post... #}
	{% if auth_err %}<form action="/accounts/login/" method="get">{% else %}<form action="/mini_buildd/api" method="get">{% endif %}
		<input type="hidden" name="command" value="{{ api_cmd.name }}" />
		{# Pre-button args #}
		{% for arg in api_cmd.args.values %}
			{% if arg.raw_value is None %}
				{# Mandatory input #}
				{% include "includes/mbd_api_arg.html" %}
			{% endif %}
		{% endfor %}

		{# Submit button #}
		<input type="submit"
					 class="mbd-api mbd-api-{{ api_cmd.name }} {% if auth_err %}mbd-api-needs-login{% endif %} "
					 value="{{ name|default_if_none:api_cmd.name }}"
					 title="{% if auth_err %}{{ auth_err }}&#13;&#10;&#13;&#10;{% endif %}{{ title|default_if_none:api_cmd.doc }}" />

		<details class="mbd-api">
			<summary title="More arguments">&#8203;</summary>
			{% if show_doc %}<pre>{{ api_cmd.doc }}</pre>{% endif %}

			{# Optional parameters, presented on demand only #}
			{% for arg in api_cmd.args.values %}
				{% if arg.raw_value is not None %}
					{% include "includes/mbd_api_arg.html" %}<br/>
				{% endif %}
			{% endfor %}
			<label class="mbd-api" for="{{ tag_id }}-output" title="Output type">output</label>
			<select id="{{ tag_id }}-output" name="output" title="output">
				{% with "json plain html referer" as options %}
					{% for o in options.split %}
						<option value="{{ o }}" {% if o == output %}selected="selected"{% endif %}>{{ o }}</option>
					{% endfor %}
				{% endwith %}
			</select>
		</details>
	</form>
</div>
