Feature: Use drf-api for Pin-creation

This commit is contained in:
winkidney
2019-02-21 17:45:22 +08:00
parent 6f6d858f8c
commit 4029107b5d
2 changed files with 7 additions and 5 deletions

View File

@@ -77,7 +77,7 @@ function deletePinData(pinId) {
function postPinData(data) {
return $.ajax({
type: "post",
url: "/api/v1/pin/",
url: API_BASE + "pins/",
contentType: 'application/json',
data: JSON.stringify(data)
});

View File

@@ -141,7 +141,7 @@ $(window).load(function() {
var data = {
description: $('#pin-form-description').val(),
tags: cleanTags($('#pin-form-tags').val())
}
};
var promise = $.ajax({
type: "patch",
url: apiUrl,
@@ -166,13 +166,15 @@ $(window).load(function() {
});
} else {
var data = {
submitter: '/api/v1/user/'+currentUser.id+'/',
referer: $('#pin-form-referer').val(),
description: $('#pin-form-description').val(),
tags: cleanTags($('#pin-form-tags').val())
};
if (uploadedImage) data.image = '/api/v1/image/'+uploadedImage+'/';
else data.url = $('#pin-form-image-url').val();
if (uploadedImage) {
data.image_id = uploadedImage;
} else {
data.url = $('#pin-form-image-url').val();
}
var promise = postPinData(data);
promise.success(function(pin) {
if (pinFromUrl) return window.close();