Skip to content

Commit

Permalink
New feature: delete videos
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Brazhkin committed Sep 23, 2010
1 parent 946425a commit df71540
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/enigmamachine.rb
Expand Up @@ -270,5 +270,13 @@ class EnigmaMachine < Sinatra::Base
end
end

# Deletes a video.
#
delete '/videos/:id' do |id|
@video = Video.get(id)
@video.destroy
redirect "/videos"
end

end

10 changes: 10 additions & 0 deletions lib/enigmamachine/models/video.rb
Expand Up @@ -21,6 +21,8 @@ class Video
:message => "Same file with same encoder already exist"
belongs_to :encoder

before :destroy, :check_destroy

# Notifies a calling application that processing has completed by sending
# a GET request to the video's callback_url.
#
Expand Down Expand Up @@ -79,5 +81,13 @@ def check_file
return true
end

def check_destroy
return true if (self.state != 'encoding')
#TODO Killing encoding process
result = false
return true if result
throw :halt
end

end

7 changes: 6 additions & 1 deletion lib/enigmamachine/views/videos/video.erb
@@ -1,6 +1,11 @@
<% video = videos_video %>
<li>
<strong><%= video.state %></strong> - <%=h video.file %> -
created at <%=h video.created_at.strftime("%m/%d/%Y at %H:%M:%S")%><br/>
created at <%=h video.created_at.strftime("%m/%d/%Y at %H:%M:%S")%>
<form action="/videos/<%= video.id %>" method="POST">
<input name="_method" value="DELETE" type="hidden"/>
<input type="submit" value="Delete"/>
</form>
<br/>
</li>

0 comments on commit df71540

Please sign in to comment.