Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- can now upload video

- WIP to delete interview
  • Loading branch information...
commit e4f8afdda7838f54aa8f72bf9ed30c8561a142e6 1 parent 052cbb0
@sr3d authored
View
21 app/controllers/interviews_controller.rb
@@ -1,5 +1,5 @@
class InterviewsController < ApplicationController
- before_filter :authenticate_user!
+ before_filter :authenticate_user!, :except => [:upload_video]
def show
@event = Event.find params[:event_id]
@@ -11,6 +11,12 @@ def new
@event = Event.find params[:event_id]
@interview = current_user.interviews.new
end
+
+ def destroy
+ @interview = Interview.find params[:id]
+ @interview.destroy
+ redirect_to event_path @event.id
+ end
def create
@@ -18,4 +24,17 @@ def create
@video = Video.create_from_params params[:interview], current_user
redirect_to event_path @event.id # :controller => "events", :action => "show", :
end
+
+ def upload_video
+ video_id = params[:video_id]
+ email = params[:email]
+ user = User.find_by_email(email) || User.get_demo_user
+
+ Video.create_from_video_id video_id, user
+
+ respond_to do |format|
+ format.html { render :text => :ok }
+ end
+ end
+
end
View
10 app/models/video.rb
@@ -10,12 +10,16 @@ def self.create_from_params params, user
# debugger
file = IO.read(params[:video].path)
client = YouTubeG::Upload::VideoUpload.new
- debugger
youtube_code = client.upload file, nil
- video = Video.create :video_id => youtube_code, :url => "http://", :user_id => user.id
- interview = Interview.new :user_id => user.id, :video_id => video.id
+ video = Video.create :video_id => youtube_code, :url => "http://", :user_id => user.id, :description => params[:description]
+ interview = Interview.create :user_id => user.id, :video_id => video.id
interview # BLAH! blaspheme!
end
+
+ def self.create_from_video_id video_id, user
+ video = Video.create :video_id => video_id, :url => "http://", :user_id => user.id
+ interview = Interview.create :user_id => user.id, :video_id => video.id
+ end
def thumbnail(size = :small)
"http://img.youtube.com/vi/#{video_id}/#{size == :small ? 1 : 0}.jpg"
View
2  app/views/events/show.html.erb
@@ -6,7 +6,7 @@
<div>Interviews: <span style="float: right">To Interview, call 415-599-2671, pin 9441-2138</span></div>
</div><!-- .module_header -->
<div class="module_padding">
- <a href="<%= new_event_interview_path(@event) %>">Upload New Video</a>
+ <a href="<%= new_event_interview_path(@event) %>" class="purple_link">Upload New Video</a>
<br/><br/>
<% if @interviews.empty? %>
<h3>Not interviews yet!. Go out there!</h3>
View
2  app/views/interviews/new.html.erb
@@ -14,7 +14,7 @@
<%= form.input :description, :as => :text, :input_html => {:rows => 10} %>
<% end %>
<%= form.buttons do %>
- <%= form.commit_button %>
+ <%= form.commit_button :disable_with, :button_html => { :disable_with => "Please wait..." } %>
<% end %>
</div><!-- .module_padding -->
</div><!-- .module_wrapper -->
View
7 config/routes.rb
@@ -73,7 +73,12 @@
end
- resources :interviews, :only => [:create]
+ resources :interviews, :only => [:create] do
+ collection do
+ get :upload_video
+ post :upload_video
+ end
+ end
# The priority is based upon order of creation:
# first created -> highest priority.
Please sign in to comment.
Something went wrong with that request. Please try again.