Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added ability to remove tasks from rss links

  • Loading branch information...
commit 07f6db9cb70696c422bbf9876aa5c1069e123e2b 1 parent 75c4f3a
@bthesorceror authored
View
23 app/controllers/tasks_controller.rb
@@ -1,10 +1,11 @@
class TasksController < ApplicationController
unloadable
- accept_key_auth :feed
+ accept_key_auth :feed, :destroy
- before_filter :require_logged, :except => [:feed]
+ before_filter :require_logged, :except => [:feed, :destroy]
before_filter :require_key, :only => [:feed]
+ before_filter :require_logged_or_key, :only => [:destroy]
def index
@tasks = User.current.tasks
@@ -21,10 +22,14 @@ def create
end
def destroy
- task = User.current.tasks.find(params[:id])
+ task = @current_user.tasks.find(params[:id])
task.destroy
- flash[:notice] = "Task removed!"
- redirect_to(:action => :index)
+ if params[:key]
+ render :text => "Task Removed!", :status => 200
+ else
+ flash[:notice] = "Task removed!"
+ redirect_to(:action => :index)
+ end
end
def feed
@@ -50,5 +55,13 @@ def require_key
return false
end
end
+
+ def require_logged_or_key
+ if params[:key]
+ require_key
+ else
+ require_logged
+ end
+ end
end
View
2  app/views/tasks/feed.html.builder
@@ -10,7 +10,7 @@ xml.rss :version => "2.0" do
xml.title "Mark Task As Complete"
xml.description task.body
xml.pubDate task.created_at.to_s(:rfc822)
- xml.link url_for(:action => :destroy, :id => task.id, :only_path => false)
+ xml.link url_for(:action => :destroy, :id => task.id, :key => @current_user.rss_key, :only_path => false)
xml.guid task.id
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.