Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
WIP bug 1230584 - Fix raw data form
Browse files Browse the repository at this point in the history
The raw data form broke with recent Django REST Framework changes in how
non-POSTs are handled. This fixes it in DEBUG mode.

However, the code might not work in production, since the code is trying
to pull the CSRF token out of the headers. However, production uses
CSRF_COOKIE_HTTPONLY, which means JS can't access it. More testing, and
alternate code, is required.
  • Loading branch information
jwhitlock committed Mar 24, 2016
1 parent e4379be commit 1c2bd7c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions webplatformcompat/jinja2/rest_framework/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@
<div {% if put_form %}class="tabbable"{% endif %}>
{% if put_form %}
<ul class="nav nav-tabs form-switcher">
<li><a name='html-tab' href="#object-form" data-toggle="tab">HTML form</a></li>
<li><a name='raw-tab' href="#generic-content-form" data-toggle="tab">Raw data</a></li>
<li><a name='html-tab' href="#put-object-form" data-toggle="tab">HTML form</a></li>
<li><a name='raw-tab' href="#put-generic-content-form" data-toggle="tab">Raw data</a></li>
</ul>
{% endif %}
<div class="well tab-content">
{% if put_form %}
<div class="tab-pane" id="object-form">
<div class="tab-pane" id="put-object-form">
<form action="{{ request.get_full_path() }}" method="POST" enctype="multipart/form-data" class="form-horizontal">
<fieldset>
{{ put_form }}
Expand All @@ -138,17 +138,17 @@
</form>
</div>
{% endif %}
<div {% if put_form %}class="tab-pane"{% endif %} id="generic-content-form">
<div {% if put_form %}class="tab-pane"{% endif %} id="put-generic-content-form">
{% set form=raw_data_put_or_patch_form %}
<form action="{{ request.get_full_path() }}" method="POST" class="form-horizontal">
<form action="{{ request.get_full_path() }}" data-method="PUT" class="form-horizontal">
<fieldset>
{% include "rest_framework/raw_data_form.html" %}
<div class="form-actions">
{% if raw_data_put_form %}
<button class="btn btn-primary js-tooltip" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="PUT" title="Make a PUT request on the {{ name }} resource">PUT</button>
<button class="btn btn-primary js-tooltip" value="PUT" title="Make a PUT request on the {{ name }} resource">PUT</button>
{% endif %}
{% if raw_data_patch_form %}
<button class="btn btn-primary js-tooltip" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="PATCH" title="Make a PATCH request on the {{ name }} resource">PATCH</button>
<button class="btn btn-primary js-tooltip" value="PATCH" title="Make a PATCH request on the {{ name }} resource">PATCH</button>
{% endif %}
</div>
</fieldset>
Expand Down

0 comments on commit 1c2bd7c

Please sign in to comment.