Various changes

This commit is contained in:
2023-03-07 10:53:18 -05:00
parent 26a4f25631
commit 0d652ffc90
5 changed files with 60 additions and 19 deletions

View File

@ -73,4 +73,23 @@ namespace '/channel' do
redirect "/channel/#{channel.id}"
end
post '/:channel_id/edit/:attr' do
# find channel and temporarily save the old channel path
channel = Channel.where(id: params[:channel_id]).first()
attrToEdit = params[:attr]
if attrToEdit == 'directory_path'
File.rename(channel.directory_path, params[attrToEdit])
channel.videos.each do |v|
video_path = v.directory_path.sub(channel.directory_path, params[attrToEdit])
v.update(directory_path: video_path)
end
end
channel[attrToEdit.to_sym] = params[attrToEdit]
channel.save()
return "success"
end
end