Small changes to test_formatter

This commit is contained in:
cuom1999 2024-01-08 13:06:18 -06:00
parent d7080a4d1b
commit 2b84d62260
4 changed files with 14 additions and 15 deletions

View file

@ -420,12 +420,12 @@ urlpatterns = [
url( url(
r"^edit_page$", r"^edit_page$",
test_formatter.EditTestFormatter.as_view(), test_formatter.EditTestFormatter.as_view(),
name="edit_page", name="test_formatter_edit",
), ),
url( url(
r"^download_page$", r"^download_page$",
test_formatter.DownloadTestFormatter.as_view(), test_formatter.DownloadTestFormatter.as_view(),
name="download_page", name="test_formatter_download",
), ),
] ]
), ),

View file

@ -33,7 +33,7 @@
event.preventDefault() event.preventDefault()
var file_path = document.getElementById('file_path').value; var file_path = document.getElementById('file_path').value;
$.ajax({ $.ajax({
url: "{{url('download_page')}}", url: "{{url('test_formatter_download')}}",
type: 'POST', type: 'POST',
data: { data: {
file_path: file_path file_path: file_path
@ -74,7 +74,7 @@
</div> </div>
<div class="button-container"> <div class="button-container">
<button type="submit" id="download" class="button">{{_('Download')}}</button> <button type="submit" id="download" class="button">{{_('Download')}}</button>
<a href="{{url('edit_page')}}?file_path={{file_path_getnames}}" id="edit" class="button">{{_('Edit')}}</a> <a href="{{url('test_formatter_edit')}}?file_path={{file_path_getnames}}" id="edit" class="button">{{_('Edit')}}</a>
</div> </div>
</div> </div>

View file

@ -45,7 +45,7 @@
$("#convert").on("click", function(event) { $("#convert").on("click", function(event) {
event.preventDefault() event.preventDefault()
$.ajax({ $.ajax({
url: "{{url('edit_page')}}", url: "{{url('test_formatter_edit')}}",
type: 'POST', type: 'POST',
data: { data: {
action: 'convert', action: 'convert',
@ -70,16 +70,15 @@
$(document).ready(function(){ $(document).ready(function(){
$("#download").on("click", function(event) { $("#download").on("click", function(event) {
event.preventDefault() event.preventDefault()
window.location.href = "{{url('edit_page')}}";
$.ajax({ $.ajax({
url: "{{url('edit_page')}}", url: "{{url('test_formatter_edit')}}",
type: 'POST', type: 'POST',
data: { data: {
action: 'download' action: 'download'
}, },
success: function(data) { success: function(data) {
var file_path = data; var file_path = data;
window.location.href = "{{url('download_page')}}" + "?file_path="+file_path; window.location.href = "{{url('test_formatter_download')}}" + "?file_path="+file_path;
}, },
error: function(error) { error: function(error) {
alert(error); alert(error);

View file

@ -1,11 +1,11 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block body %} {% block body %}
<form method="post" enctype="multipart/form-data"> <center>
{% csrf_token %} <form method="post" enctype="multipart/form-data">
{{ form }} {% csrf_token %}
<button type="submit">{{_('Upload')}}</button> {{ form }}
</form> <button type="submit" style="margin-top: 2em">{{_('Upload')}}</button>
</form>
</center>
{% endblock %} {% endblock %}