mirror of
https://github.com/pinry/pinry.git
synced 2025-11-13 08:35:41 +01:00
Feature: Update Pin via drf-api
This commit is contained in:
@@ -97,6 +97,7 @@ class PinSerializer(serializers.HyperlinkedModelSerializer):
|
||||
tags = TagSerializer(
|
||||
many=True,
|
||||
source="tag_list",
|
||||
required=False,
|
||||
)
|
||||
image = ImageSerializer(required=False, read_only=True)
|
||||
image_by_id = serializers.PrimaryKeyRelatedField(
|
||||
@@ -122,5 +123,6 @@ class PinSerializer(serializers.HyperlinkedModelSerializer):
|
||||
tags = validated_data.pop('tag_list')
|
||||
if tags:
|
||||
instance.tags.set(*tags)
|
||||
validated_data.pop('image_id')
|
||||
# change for image-id is not allowed
|
||||
validated_data.pop('image_by_id', None)
|
||||
return super(PinSerializer, self).update(instance, validated_data)
|
||||
|
||||
@@ -68,7 +68,7 @@ function getPinData(pinId) {
|
||||
|
||||
|
||||
function deletePinData(pinId) {
|
||||
var apiUrl = '/api/v1/pin/'+pinId+'/?format=json';
|
||||
var apiUrl = API_BASE + 'pins/' +pinId + '/?format=json';
|
||||
return $.ajax(apiUrl, {
|
||||
type: 'DELETE'
|
||||
});
|
||||
|
||||
@@ -137,13 +137,13 @@ $(window).load(function() {
|
||||
$(this).off('click');
|
||||
$(this).addClass('disabled');
|
||||
if (editedPin) {
|
||||
var apiUrl = '/api/v1/pin/'+editedPin.id+'/?format=json';
|
||||
var apiUrl = API_BASE + 'pins/' + editedPin.id + '/?format=json';
|
||||
var data = {
|
||||
description: $('#pin-form-description').val(),
|
||||
tags: cleanTags($('#pin-form-tags').val())
|
||||
}
|
||||
var promise = $.ajax({
|
||||
type: "put",
|
||||
type: "patch",
|
||||
url: apiUrl,
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(data)
|
||||
|
||||
Reference in New Issue
Block a user