Skip to content

Commit

Permalink
feat: Add ajax delete to audio fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Ale committed Apr 8, 2020
1 parent c55bdd9 commit b901799
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,14 @@ def clip_update(request):
instance=clip
)
if clipform.is_valid():
if 'image_delete' in data:
clip.image = None
for field in [
'image',
'audio_mp3',
'audio_wav',
'audio_ogg'
]:
if '%s_delete'%field in data:
setattr(clip, field, None)
clipform.save()
else:
return HttpResponse(
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/static/dashboard/js/tracklist-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jQuery(document).ready( function()
// Checkbox to delete the image
var delete_input = document.createElement('input');
delete_input.type = 'checkbox';
delete_input.name = 'audio_delete';
delete_input.name = audio_field + '_delete';
delete_input.classList.add('form-field__delete--audio');
var delete_input_label = document.createElement('label');
delete_input_label.innerHTML = 'Borrar el audio';
Expand Down

0 comments on commit b901799

Please sign in to comment.