mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-25 07:50:41 +03:00
Disable OPTIONS if method isn't allowed
This commit is contained in:
parent
94029acd28
commit
4cc3dd3b23
|
@ -31,3 +31,16 @@ h2, h3 {
|
||||||
.format-option {
|
.format-option {
|
||||||
font-family: Menlo, Consolas, "Andale Mono", "Lucida Console", monospace;
|
font-family: Menlo, Consolas, "Andale Mono", "Lucida Console", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#options-form {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* To allow tooltips to work on disabled elements */
|
||||||
|
.disabled-tooltip-shield {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
|
@ -64,11 +64,14 @@
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
{% if 'OPTIONS' in allowed_methods and api_settings.FORM_METHOD_OVERRIDE %}
|
{% if api_settings.FORM_METHOD_OVERRIDE %}
|
||||||
<form action="{{ request.get_full_path }}" method="post" class="pull-right">
|
<form id="options-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">OPTIONS</button>
|
<button class="btn js-tooltip" {% if 'OPTIONS' in allowed_methods %} title="Do an OPTIONS request on the {{ name }} resource"{% else %} disabled{% endif %}>OPTIONS</button>
|
||||||
|
{% if not 'OPTIONS' in allowed_methods %}
|
||||||
|
<div class="js-tooltip disabled-tooltip-shield" title="OPTIONS request not allowed for resource {{ name }}"></div>
|
||||||
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user