mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Merge pull request #724 from ae-utbm/ninja
Use django-ninja for the API
This commit is contained in:
@ -14,26 +14,21 @@
|
||||
document.head.innerHTML += '<link rel="stylesheet" href="' + css + '">';
|
||||
}
|
||||
|
||||
// Custom markdown parser
|
||||
function customMarkdownParser(plainText, cb) {
|
||||
$.ajax({
|
||||
url: "{{ markdown_api_url }}",
|
||||
method: "POST",
|
||||
data: { text: plainText, csrfmiddlewaretoken: getCSRFToken() },
|
||||
}).done(cb);
|
||||
}
|
||||
|
||||
// Pretty markdown input
|
||||
const easymde = new EasyMDE({
|
||||
element: document.getElementById("{{ widget.attrs.id }}"),
|
||||
spellChecker: false,
|
||||
autoDownloadFontAwesome: false,
|
||||
previewRender: function(plainText, preview) { // Async method
|
||||
previewRender: function (plainText, preview) {
|
||||
clearTimeout(lastAPICall);
|
||||
lastAPICall = setTimeout(() => {
|
||||
customMarkdownParser(plainText, (msg) => preview.innerHTML = msg);
|
||||
lastAPICall = setTimeout(async () => {
|
||||
const res = await fetch("{{ markdown_api_url }}", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ text: plainText }),
|
||||
});
|
||||
preview.innerHTML = await res.text();
|
||||
}, 300);
|
||||
return preview.innerHTML;
|
||||
return null;
|
||||
},
|
||||
forceSync: true, // Avoid validation error on generic create view
|
||||
toolbar: [
|
||||
|
@ -84,10 +84,10 @@
|
||||
}
|
||||
function download_pictures() {
|
||||
$("#download_all_pictures").prop("disabled", true);
|
||||
var xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "{{ url('api:all_pictures_of_user', user=object.id) }}",
|
||||
url: "{{ url('api:pictures') }}?users_identified={{ object.id }}",
|
||||
tryCount: 0,
|
||||
xhr: function(){
|
||||
return xhr;
|
||||
|
Reference in New Issue
Block a user