added approval step for aliases/implications

This commit is contained in:
albert
2011-10-23 18:50:18 -04:00
parent 34ae712be0
commit f94b65f5d5
11 changed files with 69 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
class TagAliasesController < ApplicationController
before_filter :admin_only, :only => [:new, :create, :destroy]
before_filter :admin_only, :only => [:approve, :destroy]
before_filter :member_only, :only => [:create]
respond_to :html, :xml, :json, :js
def new
@@ -9,13 +10,12 @@ class TagAliasesController < ApplicationController
def index
@search = TagAlias.search(params[:search])
@tag_aliases = @search.paginate(params[:page])
@tag_aliases = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page])
respond_with(@tag_aliases)
end
def create
@tag_alias = TagAlias.create(params[:tag_alias])
@tag_alias.delay.process!
respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id_eq => @tag_alias.id}))
end
@@ -25,6 +25,13 @@ class TagAliasesController < ApplicationController
respond_with(@tag_alias, :location => tag_aliases_path)
end
def approve
@tag_alias = TagAlias.find(params[:id])
@tag_alias.update_column(:status, "queued")
@tag_alias.delay.process!
respond_with(@tag_alias, :location => tag_alias_path(@tag_alias))
end
def cache
@tag_alias = TagAlias.find(params[:id])
@tag_alias.clear_cache

View File

@@ -1,5 +1,6 @@
class TagImplicationsController < ApplicationController
before_filter :admin_only, :only => [:new, :create, :destroy]
before_filter :admin_only, :only => [:approve, :destroy]
before_filter :member_only, :only => [:create]
respond_to :html, :xml, :json, :js
def new
@@ -9,13 +10,12 @@ class TagImplicationsController < ApplicationController
def index
@search = TagImplication.search(params[:search])
@tag_implications = @search.paginate(params[:page])
@tag_implications = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page])
respond_with(@tag_implicationes)
end
def create
@tag_implication = TagImplication.create(params[:tag_implication])
@tag_implication.delay.process!
respond_with(@tag_implication, :location => tag_implications_path(:search => {:id_eq => @tag_implication.id}))
end
@@ -24,4 +24,11 @@ class TagImplicationsController < ApplicationController
@tag_implication.destroy
respond_with(@tag_implication)
end
def approve
@tag_implication = TagImplication.find(params[:id])
@tag_implication.update_column(:status, "queued")
@tag_implication.delay.process!
respond_with(@tag_implication, :location => tag_implication_path(@tag_implication))
end
end