-
Notifications
You must be signed in to change notification settings - Fork 11
/
video_controller.rb
75 lines (55 loc) · 1.65 KB
/
video_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class VideoController < ApplicationController
include ExtendedContentController
def index
redirect_to_search_for('Video')
end
def list
index
end
def show
prepare_item_variables_for("Video", true)
@video = @item
respond_to do |format|
format.html
format.xml { render_oai_record_xml(:item => @video) }
end
end
def new
@video = Video.new
end
def create
@video = Video.new(params[:video])
@successful = @video.save
# add this to the user's empire of creations
# TODO: allow current_user whom is at least moderator to pick another user
# as creator
if @successful
@video.creator = current_user
@video.do_notifications_if_pending(1, current_user)
end
setup_related_topic_and_zoom_and_redirect(@video, nil, :private => (params[:video][:private] == "true"))
end
def edit
@video = Video.find(params[:id])
public_or_private_version_of(@video)
end
def update
@video = Video.find(params[:id])
version_after_update = @video.max_version + 1
@successful = ensure_no_new_insecure_elements_in('video')
@video.attributes = params[:video]
@successful = @video.save if @successful
if @successful
after_successful_zoom_item_update(@video)
@video.do_notifications_if_pending(version_after_update, current_user) if
@video.versions.exists?(:version => version_after_update)
flash[:notice] = 'Video was successfully updated.'
redirect_to_show_for(@video, :private => (params[:video][:private] == "true"))
else
render :action => 'edit'
end
end
def destroy
zoom_destroy_and_redirect('Video')
end
end