Various changes
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user