update forum topic when alias/implication/update request is updated
This commit is contained in:
@@ -44,9 +44,7 @@ class TagAliasesController < ApplicationController
|
||||
def destroy
|
||||
@tag_alias = TagAlias.find(params[:id])
|
||||
if @tag_alias.deletable_by?(CurrentUser.user)
|
||||
@tag_alias.update_column(:status, "deleted")
|
||||
@tag_alias.clear_all_cache
|
||||
@tag_alias.destroy
|
||||
@tag_alias.reject!
|
||||
respond_with(@tag_alias, :location => tag_aliases_path)
|
||||
else
|
||||
access_denied
|
||||
|
||||
@@ -44,7 +44,7 @@ class TagImplicationsController < ApplicationController
|
||||
def destroy
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
if @tag_implication.deletable_by?(CurrentUser.user)
|
||||
@tag_implication.destroy
|
||||
@tag_implication.reject!
|
||||
respond_with(@tag_implication) do |format|
|
||||
format.html do
|
||||
flash[:notice] = "Tag implication was deleted"
|
||||
|
||||
@@ -31,6 +31,7 @@ class BulkUpdateRequest < ActiveRecord::Base
|
||||
extend SearchMethods
|
||||
|
||||
def approve!
|
||||
update_forum_topic_for_approve
|
||||
AliasAndImplicationImporter.new(script, forum_topic_id, "1").process!
|
||||
update_attribute(:status, "approved")
|
||||
end
|
||||
@@ -70,6 +71,7 @@ class BulkUpdateRequest < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def reject!
|
||||
update_forum_topic_for_reject
|
||||
update_attribute(:status, "rejected")
|
||||
end
|
||||
|
||||
@@ -91,4 +93,25 @@ class BulkUpdateRequest < ActiveRecord::Base
|
||||
errors.add(:base, "Forum topic ID is invalid")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def update_forum_topic_for_approve
|
||||
if forum_topic
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
forum_topic.posts.create(
|
||||
:body => "The bulk update request ##{id} has been approved."
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_forum_topic_for_reject
|
||||
if forum_topic
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
forum_topic.posts.create(
|
||||
:body => "The bulk update request ##{id} has been rejected."
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,6 +86,7 @@ class TagAlias < ActiveRecord::Base
|
||||
clear_all_cache
|
||||
ensure_category_consistency
|
||||
update_posts
|
||||
update_forum_topic_for_approve
|
||||
update_column(:status, "active")
|
||||
rescue Exception => e
|
||||
update_column(:status, "error: #{e}")
|
||||
@@ -226,4 +227,31 @@ class TagAlias < ActiveRecord::Base
|
||||
def editable_by?(user)
|
||||
deletable_by?(user)
|
||||
end
|
||||
|
||||
def update_forum_topic_for_approve
|
||||
if forum_topic
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
forum_topic.posts.create(
|
||||
:body => "The tag alias #{antecedent_name} -> #{consequent_name} has been approved."
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_forum_topic_for_reject
|
||||
if forum_topic
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
forum_topic.posts.create(
|
||||
:body => "The tag alias #{antecedent_name} -> #{consequent_name} has been rejected."
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reject!
|
||||
update_column(:status, "deleted")
|
||||
clear_all_cache
|
||||
update_forum_topic_for_reject
|
||||
destroy
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@ class TagImplication < ActiveRecord::Base
|
||||
after_save :update_descendant_names_for_parents
|
||||
after_destroy :update_descendant_names_for_parents
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :forum_topic
|
||||
before_validation :initialize_creator, :on => :create
|
||||
before_validation :normalize_names
|
||||
validates_presence_of :creator_id, :antecedent_name, :consequent_name
|
||||
@@ -127,6 +128,7 @@ class TagImplication < ActiveRecord::Base
|
||||
update_posts
|
||||
update_column(:status, "active")
|
||||
update_descendant_names_for_parents
|
||||
update_forum_topic_for_approve
|
||||
rescue Exception => e
|
||||
update_column(:status, "error: #{e}")
|
||||
end
|
||||
@@ -213,4 +215,29 @@ class TagImplication < ActiveRecord::Base
|
||||
def editable_by?(user)
|
||||
deletable_by?(user)
|
||||
end
|
||||
|
||||
def update_forum_topic_for_approve
|
||||
if forum_topic
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
forum_topic.posts.create(
|
||||
:body => "The tag implication #{antecedent_name} -> #{consequent_name} has been approved."
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_forum_topic_for_reject
|
||||
if forum_topic
|
||||
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
|
||||
forum_topic.posts.create(
|
||||
:body => "The tag implication #{antecedent_name} -> #{consequent_name} has been rejected."
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reject!
|
||||
update_forum_topic_for_reject
|
||||
destroy
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user