Consolidated the video and channel attribute edits into one javascript function
This commit is contained in:
@ -79,14 +79,14 @@ namespace '/channel' do
|
||||
attrToEdit = params[:attr]
|
||||
|
||||
if attrToEdit == 'directory_path'
|
||||
File.rename(channel.directory_path, params[attrToEdit])
|
||||
File.rename(channel.directory_path, params[:value])
|
||||
channel.videos.each do |v|
|
||||
video_path = v.directory_path.sub(channel.directory_path, params[attrToEdit])
|
||||
video_path = v.directory_path.sub(channel.directory_path, params[:value])
|
||||
v.update(directory_path: video_path)
|
||||
end
|
||||
end
|
||||
|
||||
channel[attrToEdit.to_sym] = params[attrToEdit]
|
||||
channel[attrToEdit.to_sym] = params[:value]
|
||||
channel.save()
|
||||
|
||||
return "success"
|
||||
|
@ -111,7 +111,15 @@ namespace '/video' do
|
||||
video = Video.where(id: params[:video_id]).first()
|
||||
attrToEdit = params[:attr]
|
||||
|
||||
video[attrToEdit.to_sym] = params[attrToEdit]
|
||||
# if we update the video's serial, we need to also update the directory path
|
||||
if attrToEdit == 'serial'
|
||||
old_path = video.directory_path
|
||||
new_path = video.directory_path.sub("##{video.serial}", "##{params[:value]}")
|
||||
File.rename(old_path, new_path)
|
||||
video[:directory_path] = new_path
|
||||
end
|
||||
|
||||
video[attrToEdit.to_sym] = params[:value]
|
||||
video.save()
|
||||
|
||||
return "success"
|
||||
|
Reference in New Issue
Block a user