Added ability to archive videos
This commit is contained in:
@ -117,13 +117,47 @@ namespace '/video' do
|
||||
return "success"
|
||||
end
|
||||
|
||||
get '/:video_id/delete' do
|
||||
# find the video and delete it
|
||||
get '/:video_id/archive' do
|
||||
# find the video
|
||||
video = Video.where(id: params[:video_id]).first()
|
||||
FileUtils.rm_rf(video.directory_path)
|
||||
video.delete()
|
||||
video_base = File.basename(video.directory_path)
|
||||
|
||||
redirect '/video'
|
||||
# move project to channel's archive
|
||||
archive_dir = File.join(
|
||||
video.channel.directory_path,
|
||||
'Archive',
|
||||
video_base
|
||||
)
|
||||
FileUtils.mv(video.directory_path, archive_dir)
|
||||
|
||||
# mark the video as archived and update directory
|
||||
video.update(
|
||||
directory_path: archive_dir,
|
||||
archived: true
|
||||
)
|
||||
|
||||
redirect '/video/' + video.id.to_s()
|
||||
end
|
||||
get '/:video_id/unarchive' do
|
||||
# find the video
|
||||
video = Video.where(id: params[:video_id]).first()
|
||||
video_base = File.basename(video.directory_path)
|
||||
|
||||
# move project to channel's archive
|
||||
active_dir = File.join(
|
||||
video.channel.directory_path,
|
||||
'Main',
|
||||
video_base
|
||||
)
|
||||
FileUtils.mv(video.directory_path, active_dir)
|
||||
|
||||
# mark the video as archived and update directory
|
||||
video.update(
|
||||
directory_path: active_dir,
|
||||
archived: false
|
||||
)
|
||||
|
||||
redirect '/video/' + video.id.to_s()
|
||||
end
|
||||
|
||||
get '/:video_id/edit/script' do
|
||||
|
Reference in New Issue
Block a user