forked from e621ng/e621ng
support dynamic updates of forum for bulk update requests
This commit is contained in:
parent
cbc886e140
commit
db4fa8c7da
@ -1,5 +1,5 @@
|
||||
class BulkUpdateRequest < ActiveRecord::Base
|
||||
attr_accessor :title, :reason, :skip_secondary_validations
|
||||
attr_accessor :reason, :skip_secondary_validations
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :forum_topic
|
||||
@ -13,7 +13,7 @@ class BulkUpdateRequest < ActiveRecord::Base
|
||||
validate :script_formatted_correctly
|
||||
validate :forum_topic_id_not_invalid
|
||||
validate :validate_script, :on => :create
|
||||
attr_accessible :user_id, :forum_topic_id, :script, :title, :reason, :skip_secondary_validations
|
||||
attr_accessible :user_id, :forum_topic_id, :forum_post_id, :script, :title, :reason, :skip_secondary_validations
|
||||
attr_accessible :status, :approver_id, :as => [:admin]
|
||||
before_validation :initialize_attributes, :on => :create
|
||||
before_validation :normalize_text
|
||||
@ -68,6 +68,7 @@ class BulkUpdateRequest < ActiveRecord::Base
|
||||
|
||||
def create_forum_topic
|
||||
if forum_topic_id
|
||||
forum_post = forum_topic.posts.create(body: reason_with_link)
|
||||
update_attributes(:forum_post_id => forum_post.id)
|
||||
else
|
||||
forum_topic = ForumTopic.create(:title => title, :category_id => 1, :original_post_attributes => {:body => reason_with_link})
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddTitleToBulkUpdateRequests < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :bulk_update_requests, :title, :text
|
||||
end
|
||||
end
|
@ -892,7 +892,8 @@ CREATE TABLE bulk_update_requests (
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
approver_id integer,
|
||||
forum_post_id integer
|
||||
forum_post_id integer,
|
||||
title text
|
||||
);
|
||||
|
||||
|
||||
@ -7220,6 +7221,13 @@ CREATE UNIQUE INDEX index_wiki_pages_on_title ON wiki_pages USING btree (title);
|
||||
CREATE INDEX index_wiki_pages_on_title_pattern ON wiki_pages USING btree (title text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_wiki_pages_on_updated_at; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_wiki_pages_on_updated_at ON wiki_pages USING btree (updated_at);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@ -7565,5 +7573,9 @@ INSERT INTO schema_migrations (version) VALUES ('20170316224630');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170319000519');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170329185605');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170330230231');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170413000209');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user