Tweak browseable API

This commit is contained in:
Tom Christie 2012-09-25 13:35:41 +01:00
parent b7b7ca5af9
commit 758bcf5b1e
2 changed files with 18 additions and 29 deletions

View File

@ -40,8 +40,9 @@ h2, h3 {
font-family: Menlo, Consolas, "Andale Mono", "Lucida Console", monospace; font-family: Menlo, Consolas, "Andale Mono", "Lucida Console", monospace;
} }
#options-form { .button-form {
position: relative; float: right;
margin-right: 1em;
} }
/* To allow tooltips to work on disabled elements */ /* To allow tooltips to work on disabled elements */
@ -53,10 +54,6 @@ h2, h3 {
left: 0; left: 0;
} }
#options-form {
margin-right: 1em;
}
.errorlist { .errorlist {
margin-top: 0.5em; margin-top: 0.5em;
} }

View File

@ -71,7 +71,7 @@
<form id="get-form" class="pull-right"> <form id="get-form" class="pull-right">
<fieldset> <fieldset>
<div class="btn-group format-selection"> <div class="btn-group format-selection">
<a class="btn btn-primary js-tooltip" href='{{ request.get_full_path }}' rel="nofollow" title="Do a GET request on the {{ name }} resource">GET</a> <a class="btn btn-primary js-tooltip" href='{{ request.get_full_path }}' rel="nofollow" title="Make a GET request on the {{ name }} resource">GET</a>
<button class="btn btn-primary dropdown-toggle js-tooltip" data-toggle="dropdown" title="Specify a format for the GET request"> <button class="btn btn-primary dropdown-toggle js-tooltip" data-toggle="dropdown" title="Specify a format for the GET request">
<span class="caret"></span> <span class="caret"></span>
@ -79,7 +79,7 @@
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{% for format in available_formats %} {% for format in available_formats %}
<li> <li>
<a class="js-tooltip format-option" href='{% add_query_param request api_settings.URL_FORMAT_OVERRIDE format %}' rel="nofollow" title="Do a GET request on the {{ name }} resource with the format set to `{{ format }}`">{{ format }}</a> <a class="js-tooltip format-option" href='{% add_query_param request api_settings.URL_FORMAT_OVERRIDE format %}' rel="nofollow" title="Make a GET request on the {{ name }} resource with the format set to `{{ format }}`">{{ format }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -89,14 +89,19 @@
</form> </form>
{% endif %} {% endif %}
{% if api_settings.FORM_METHOD_OVERRIDE %} {% if 'OPTIONS' in allowed_methods and api_settings.FORM_METHOD_OVERRIDE %}
<form id="options-form" action="{{ request.get_full_path }}" method="post" class="pull-right"> <form class="button-form" action="{{ request.get_full_path }}" method="POST" class="pull-right">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="OPTIONS" /> <input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="OPTIONS" />
<button class="btn btn-info js-tooltip" {% if 'OPTIONS' in allowed_methods %} title="Do an OPTIONS request on the {{ name }} resource"{% else %} disabled{% endif %}>OPTIONS</button> <button class="btn btn-info js-tooltip" title="Make an OPTIONS request on the {{ name }} resource">OPTIONS</button>
{% if not 'OPTIONS' in allowed_methods %} </form>
<div class="js-tooltip disabled-tooltip-shield" title="OPTIONS request not allowed for resource {{ name }}"></div>
{% endif %} {% endif %}
{% if 'DELETE' in allowed_methods and api_settings.FORM_METHOD_OVERRIDE %}
<form class="button-form" action="{{ request.get_full_path }}" method="POST" class="pull-right">
{% csrf_token %}
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="DELETE" />
<button class="btn btn-danger js-tooltip" title="Make a DELETE request on the {{ name }} resource">DELETE</button>
</form> </form>
{% endif %} {% endif %}
@ -133,7 +138,7 @@
</div> </div>
{% endfor %} {% endfor %}
<div class="form-actions"> <div class="form-actions">
<button class="btn btn-primary" title="Do a POST request on the {{ name }} resource">POST</button> <button class="btn btn-primary" title="Make a POST request on the {{ name }} resource">POST</button>
</div> </div>
</fieldset> </fieldset>
</form> </form>
@ -157,26 +162,13 @@
</div> </div>
{% endfor %} {% endfor %}
<div class="form-actions"> <div class="form-actions">
<button class="btn btn-primary js-tooltip" title="Do a PUT request on the {{ name }} resource">PUT</button> <button class="btn btn-primary js-tooltip" title="Make a PUT request on the {{ name }} resource">PUT</button>
</div> </div>
</fieldset> </fieldset>
</form> </form>
{% endif %} {% endif %}
{% if 'DELETE' in allowed_methods and api_settings.FORM_METHOD_OVERRIDE %}
<form action="{{ request.get_full_path }}" method="POST" class="form-horizontal">
<fieldset>
<h2>DELETE: {{ name }}</h2>
{% csrf_token %}
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="DELETE" />
<div class="form-actions">
<button class="btn btn-danger js-tooltip" title="Do a DELETE request on the {{ name }} resource">DELETE</button>
</div>
</fieldset>
</form>
{% endif %}
{% endif %} {% endif %}
</div> </div>