Skip to content
Snippets Groups Projects
Commit 6ec79bea authored by Jayesh's avatar Jayesh :cat2:
Browse files

csrf post

parent 629cddbc
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,8 @@
* See top-level LICENSE file for more information
*/
import {handleFetchError, csrfPost} from 'utils/functions';
export function onRequestDashboardLoad(requestId) {
populateRequestDetails(requestId);
......@@ -12,26 +14,23 @@ export function onRequestDashboardLoad(requestId) {
contactForgeAdmin(event);
});
$('#updateRequestForm').submit(function(event) {
$('#updateRequestForm').submit(async function(event) {
event.preventDefault();
$.ajax({
data: $(this).serialize(),
type: $(this).attr('method'),
url: $(this).attr('action'),
success: function(response) {
$('#userMessage').text('The request status has been updated ');
$('#userMessage').removeClass('badge-danger');
$('#userMessage').addClass('badge-success');
populateRequestDetails(requestId); // FIXME, this is not upating the options list; maybe we should clear everything before re-populating
},
error: function(request, status, error) {
// FIXME, show error response from server
$('#userMessage').text('Sorry following error happened, ' + error);
$('#userMessage').removeClass('badge-success');
$('#userMessage').addClass('badge-danger');
}
});
try {
const response = await csrfPost($(this).attr('action'),
{'Content-Type': 'application/x-www-form-urlencoded'},
$(this).serialize());
handleFetchError(response);
$('#userMessage').text('The request status has been updated ');
$('#userMessage').removeClass('badge-danger');
$('#userMessage').addClass('badge-success');
populateRequestDetails(requestId); // FIXME, this is not updating the options list; maybe we should clear everything before re-populating
} catch (response) {
// const responseText = await response.json();
$('#userMessage').text('Sorry; Updating the request failed');
$('#userMessage').removeClass('badge-success');
$('#userMessage').addClass('badge-danger');
}
});
}
......
......@@ -14,7 +14,7 @@ See top-level LICENSE file for more information
{% render_bundle 'add_forge' %}
{% endblock %}
{% block title %}{{ heading }} – Software Heritage archive{% endblock %}
{% block title %}Add forge request – Software Heritage archive{% endblock %}
{% block navbar-content %}
<h4>Add forge now request dashboard</h4>
......@@ -63,16 +63,6 @@ See top-level LICENSE file for more information
<span class="text-muted">Request History</span>
</h6>
<ul class="list-group mb-3" style="height: 100%;" id="swh-request-history">
<!-- <li class="list-group-item d-flex justify-content-between lh-condensed"> -->
<!-- <div> -->
<!-- <h6 class="my-0"> Date</h6> -->
<!-- </div> -->
<!-- <div> -->
<!-- <span class="text-muted">Moderator</span> -->
<!-- </div> -->
<!-- <span class="text-muted">kkk</span> -->
<!-- </li> -->
</ul>
</div>
</div>
......@@ -117,7 +107,7 @@ See top-level LICENSE file for more information
</div>
</div>
<div class="form-group col-md-6">
<button type="submit" class="btn btn-secondary mb-2">Submit your decision</button>
<button type="submit" class="btn btn-default mb-2">Submit your decision</button>
</div>
<div class="form-row">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment