@login_required
def delete_media(request, media_id, media_type='image'):
 (media, media_format) = _get_media_info(media_id, media_type)
 check_media_permissions(media, request.user, 'delete')
 if (request.method == 'GET'):
  return render(request, 'gallery/confirm_media_delete.html', {'media': media, 'media_type': media_type, 'media_format': media_format})
 log.warning(('User %s is deleting %s with id=%s' % (request.user, media_type, media.id)))
 media.delete()
 schedule_rebuild_kb()
 return HttpResponseRedirect(reverse('gallery.gallery', args=[media_type]))

@ login_required def delete_media ( request , media_id , media_type = 'image' ) : ( media , media_format ) = _get_media_info ( media_id , media_type ) check_media_permissions ( media , request . user , 'delete' ) if ( request . method == 'GET' ) : return render ( request , 'gallery/confirm_media_delete.html' , { 'media' : media , 'media_type' : media_type , 'media_format' : media_format } ) log . warning ( ( 'User %s is deleting %s with id=%s' % ( request . user , media_type , media . id ) ) ) media . delete ( ) schedule_rebuild_kb ( ) return HttpResponseRedirect ( reverse ( 'gallery.gallery' , args = [ media_type ] ) )
delete media and redirect to gallery view .