Implement forum topic voting and tag change pruning (#3580)
This commit is contained in:
@@ -8,6 +8,6 @@
|
|||||||
//= require jquery.qtip.js
|
//= require jquery.qtip.js
|
||||||
//= require ugoira_player.js
|
//= require ugoira_player.js
|
||||||
//= require stupidtable.js
|
//= require stupidtable.js
|
||||||
//= require rails.js
|
//= require rails-ujs
|
||||||
//= require common.js
|
//= require common.js
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
|||||||
2
app/assets/javascripts/forum_post_votes_controller.js
Normal file
2
app/assets/javascripts/forum_post_votes_controller.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
||||||
3
app/assets/stylesheets/forum_post_votes_controller.scss
Normal file
3
app/assets/stylesheets/forum_post_votes_controller.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the ForumPostVotesController controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
@@ -5,10 +5,30 @@ div.list-of-forum-posts {
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
box-shadow: 1px 1px 2px #AAA;
|
box-shadow: 1px 1px 2px #AAA;
|
||||||
|
|
||||||
|
a.voted {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.desc {
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
|
|
||||||
&:target {
|
&:target {
|
||||||
background-color: #FFC;
|
background-color: #FFC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vote-score-up {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vote-score-meh {
|
||||||
|
color: goldenrod;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vote-score-down {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
div.author {
|
div.author {
|
||||||
padding: 1em 1em 0 1em;
|
padding: 1em 1em 0 1em;
|
||||||
width: 12em;
|
width: 12em;
|
||||||
@@ -26,6 +46,10 @@ div.list-of-forum-posts {
|
|||||||
menu {
|
menu {
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
|
|
||||||
|
ul.votes {
|
||||||
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class ApplicationController < ActionController::Base
|
|||||||
fmt.xml { render template: "static/error", status: 501 }
|
fmt.xml { render template: "static/error", status: 501 }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :template => "static/error", :status => 500
|
render :template => "static/error", :status => 500, :layout => "blank"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
32
app/controllers/forum_post_votes_controller.rb
Normal file
32
app/controllers/forum_post_votes_controller.rb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
class ForumPostVotesController < ApplicationController
|
||||||
|
respond_to :js
|
||||||
|
before_action :load_forum_post
|
||||||
|
before_action :load_vote, only: [:destroy]
|
||||||
|
before_action :member_only
|
||||||
|
|
||||||
|
def create
|
||||||
|
@forum_post_vote = @forum_post.votes.create(forum_post_vote_params)
|
||||||
|
respond_with(@forum_post_vote)
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@forum_post_vote.destroy
|
||||||
|
respond_with(@forum_post_vote)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def load_vote
|
||||||
|
@forum_post_vote = @forum_post.votes.where(creator_id: CurrentUser.id).first
|
||||||
|
raise ActiveRecord::RecordNotFound.new if @forum_post_vote.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_forum_post
|
||||||
|
@forum_post = ForumPost.find(params[:forum_post_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def forum_post_vote_params
|
||||||
|
params.fetch(:forum_post_vote, {}).permit(:score)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -46,6 +46,7 @@ class ForumTopicsController < ApplicationController
|
|||||||
@forum_topic.mark_as_read!(CurrentUser.user)
|
@forum_topic.mark_as_read!(CurrentUser.user)
|
||||||
end
|
end
|
||||||
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page])
|
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page])
|
||||||
|
@original_forum_post_id = @forum_topic.original_post.id
|
||||||
respond_with(@forum_topic) do |format|
|
respond_with(@forum_topic) do |format|
|
||||||
format.atom do
|
format.atom do
|
||||||
@forum_posts = @forum_posts.reverse_order.includes(:creator).load
|
@forum_posts = @forum_posts.reverse_order.includes(:creator).load
|
||||||
|
|||||||
2
app/helpers/forum_post_votes_controller_helper.rb
Normal file
2
app/helpers/forum_post_votes_controller_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module ForumPostVotesControllerHelper
|
||||||
|
end
|
||||||
@@ -5,6 +5,7 @@ class DailyMaintenance
|
|||||||
TagPruner.new.prune!
|
TagPruner.new.prune!
|
||||||
Upload.where('created_at < ?', 1.day.ago).delete_all
|
Upload.where('created_at < ?', 1.day.ago).delete_all
|
||||||
Delayed::Job.where('created_at < ?', 45.days.ago).delete_all
|
Delayed::Job.where('created_at < ?', 45.days.ago).delete_all
|
||||||
|
#ForumPostVote.where("created_at < ?", 90.days.ago).delete_all
|
||||||
PostVote.prune!
|
PostVote.prune!
|
||||||
CommentVote.prune!
|
CommentVote.prune!
|
||||||
ApiCacheGenerator.new.generate_tag_cache
|
ApiCacheGenerator.new.generate_tag_cache
|
||||||
@@ -15,5 +16,7 @@ class DailyMaintenance
|
|||||||
Tag.clean_up_negative_post_counts!
|
Tag.clean_up_negative_post_counts!
|
||||||
SuperVoter.init!
|
SuperVoter.init!
|
||||||
TokenBucket.prune!
|
TokenBucket.prune!
|
||||||
|
TagChangeRequestPruner.warn_all
|
||||||
|
TagChangeRequestPruner.reject_all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_session_user
|
def load_session_user
|
||||||
CurrentUser.user = User.find_by_id(session[:user_id])
|
user = User.find_by_id(session[:user_id])
|
||||||
|
CurrentUser.user = user if user
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_cookie_user
|
def load_cookie_user
|
||||||
|
|||||||
43
app/logical/tag_change_request_pruner.rb
Normal file
43
app/logical/tag_change_request_pruner.rb
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Service to prune old unapproved tag change requests
|
||||||
|
# (including tag aliases, tag implications, and bulk
|
||||||
|
# update requests).
|
||||||
|
|
||||||
|
class TagChangeRequestPruner
|
||||||
|
def self.warn_all
|
||||||
|
[TagAlias, TagImplication, BulkUpdateRequest].each do |model|
|
||||||
|
new.warn_old(model)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.reject_all
|
||||||
|
[TagAlias, TagImplication, BulkUpdateRequest].each do |model|
|
||||||
|
new.reject_expired(model)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def warn_old(model)
|
||||||
|
model.old.pending.find_each do |tag_change|
|
||||||
|
if tag_change.forum_topic
|
||||||
|
name = model.model_name.human.downcase
|
||||||
|
body = "This #{name} is pending automatic rejection in 5 days."
|
||||||
|
unless tag_change.forum_topic.posts.where(creator_id: User.system.id, body: body).exists?
|
||||||
|
tag_change.forum_updater.update(body)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def reject_expired(model)
|
||||||
|
model.expired.pending.find_each do |tag_change|
|
||||||
|
if tag_change.forum_topic
|
||||||
|
name = model.model_name.human.downcase
|
||||||
|
body = "This #{name} has been rejected because it was not approved within 60 days."
|
||||||
|
tag_change.forum_updater.update(body)
|
||||||
|
end
|
||||||
|
|
||||||
|
CurrentUser.as_system do
|
||||||
|
tag_change.reject!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -18,6 +18,9 @@ class BulkUpdateRequest < ApplicationRecord
|
|||||||
after_create :create_forum_topic
|
after_create :create_forum_topic
|
||||||
|
|
||||||
scope :pending_first, lambda { order("(case status when 'pending' then 0 when 'approved' then 1 else 2 end)") }
|
scope :pending_first, lambda { order("(case status when 'pending' then 0 when 'approved' then 1 else 2 end)") }
|
||||||
|
scope :pending, ->{where(status: "pending")}
|
||||||
|
scope :expired, ->{where("created_at < ?", TagRelationship::EXPIRY.days.ago)}
|
||||||
|
scope :old, ->{where("created_at between ? and ?", TagRelationship::EXPIRY.days.ago, TagRelationship::EXPIRY_WARNING.days.ago)}
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def default_order
|
def default_order
|
||||||
@@ -121,7 +124,7 @@ class BulkUpdateRequest < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def reject!(rejector)
|
def reject!(rejector = User.system)
|
||||||
transaction do
|
transaction do
|
||||||
update(status: "rejected")
|
update(status: "rejected")
|
||||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been rejected by @#{rejector.name}.", "REJECTED")
|
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been rejected by @#{rejector.name}.", "REJECTED")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class ForumPost < ApplicationRecord
|
|||||||
belongs_to_creator
|
belongs_to_creator
|
||||||
belongs_to_updater
|
belongs_to_updater
|
||||||
belongs_to :topic, :class_name => "ForumTopic"
|
belongs_to :topic, :class_name => "ForumTopic"
|
||||||
|
has_many :votes, class_name: "ForumPostVote"
|
||||||
before_validation :initialize_is_deleted, :on => :create
|
before_validation :initialize_is_deleted, :on => :create
|
||||||
after_create :update_topic_updated_at_on_create
|
after_create :update_topic_updated_at_on_create
|
||||||
after_update :update_topic_updated_at_on_update_for_original_posts
|
after_update :update_topic_updated_at_on_update_for_original_posts
|
||||||
@@ -128,6 +129,10 @@ class ForumPost < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def voted?(user, score)
|
||||||
|
votes.where(creator_id: user.id, score: score).exists?
|
||||||
|
end
|
||||||
|
|
||||||
def validate_topic_is_unlocked
|
def validate_topic_is_unlocked
|
||||||
return if CurrentUser.is_moderator?
|
return if CurrentUser.is_moderator?
|
||||||
return if topic.nil?
|
return if topic.nil?
|
||||||
@@ -228,8 +233,12 @@ class ForumPost < ApplicationRecord
|
|||||||
((ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count) / Danbooru.config.posts_per_page.to_f).ceil
|
((ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count) / Danbooru.config.posts_per_page.to_f).ceil
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_original_post?
|
def is_original_post?(original_post_id = nil)
|
||||||
ForumPost.exists?(["id = ? and id = (select _.id from forum_posts _ where _.topic_id = ? order by _.id asc limit 1)", id, topic_id])
|
if original_post_id
|
||||||
|
return id == original_post_id
|
||||||
|
else
|
||||||
|
ForumPost.exists?(["id = ? and id = (select _.id from forum_posts _ where _.topic_id = ? order by _.id asc limit 1)", id, topic_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_topic_if_original_post
|
def delete_topic_if_original_post
|
||||||
|
|||||||
44
app/models/forum_post_vote.rb
Normal file
44
app/models/forum_post_vote.rb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
class ForumPostVote < ApplicationRecord
|
||||||
|
belongs_to_creator
|
||||||
|
belongs_to :forum_post
|
||||||
|
validates :creator_id, uniqueness: {scope: :forum_post_id}
|
||||||
|
validates :score, inclusion: {in: [-1, 0, 1]}
|
||||||
|
scope :up, -> {where(score: 1)}
|
||||||
|
scope :down, -> {where(score: -1)}
|
||||||
|
scope :by, ->(user_id) {where(creator_id: user_id)}
|
||||||
|
scope :excluding, ->(user_id) {where("creator_id <> ?", user_id)}
|
||||||
|
|
||||||
|
def up?
|
||||||
|
score == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def down?
|
||||||
|
score == -1
|
||||||
|
end
|
||||||
|
|
||||||
|
def meh?
|
||||||
|
score == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def fa_class
|
||||||
|
if score == 1
|
||||||
|
return "fa-thumbs-up"
|
||||||
|
elsif score == -1
|
||||||
|
return "fa-thumbs-down"
|
||||||
|
else
|
||||||
|
return "fa-meh"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def vote_type
|
||||||
|
if score == 1
|
||||||
|
return "up"
|
||||||
|
elsif score == -1
|
||||||
|
return "down"
|
||||||
|
elsif score == 0
|
||||||
|
return "meh"
|
||||||
|
else
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,6 +10,9 @@ class TagImplication < TagRelationship
|
|||||||
validate :consequent_is_not_aliased
|
validate :consequent_is_not_aliased
|
||||||
validate :antecedent_and_consequent_are_different
|
validate :antecedent_and_consequent_are_different
|
||||||
validate :wiki_pages_present, :on => :create
|
validate :wiki_pages_present, :on => :create
|
||||||
|
scope :expired, ->{where("created_at < ?", 2.months.ago)}
|
||||||
|
scope :old, ->{where("created_at between ? and ?", 2.months.ago, 1.month.ago)}
|
||||||
|
scope :pending, ->{where(status: "pending")}
|
||||||
|
|
||||||
module DescendantMethods
|
module DescendantMethods
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
class TagRelationship < ApplicationRecord
|
class TagRelationship < ApplicationRecord
|
||||||
self.abstract_class = true
|
self.abstract_class = true
|
||||||
|
|
||||||
|
EXPIRY = 60
|
||||||
|
EXPIRY_WARNING = 55
|
||||||
|
|
||||||
attr_accessor :skip_secondary_validations
|
attr_accessor :skip_secondary_validations
|
||||||
|
|
||||||
belongs_to_creator
|
belongs_to_creator
|
||||||
@@ -10,6 +13,10 @@ class TagRelationship < ApplicationRecord
|
|||||||
has_one :antecedent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "antecedent_name"
|
has_one :antecedent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "antecedent_name"
|
||||||
has_one :consequent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "consequent_name"
|
has_one :consequent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "consequent_name"
|
||||||
|
|
||||||
|
scope :expired, ->{where("created_at < ?", EXPIRY.days.ago)}
|
||||||
|
scope :old, ->{where("created_at >= ? and created_at < ?", EXPIRY.days.ago, EXPIRY_WARNING.days.ago)}
|
||||||
|
scope :pending, ->{where(status: "pending")}
|
||||||
|
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
before_validation :normalize_names
|
before_validation :normalize_names
|
||||||
validates_format_of :status, :with => /\A(active|deleted|pending|processing|queued|error: .*)\Z/
|
validates_format_of :status, :with => /\A(active|deleted|pending|processing|queued|error: .*)\Z/
|
||||||
|
|||||||
11
app/views/forum_post_votes/_add_vote.html.erb
Normal file
11
app/views/forum_post_votes/_add_vote.html.erb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<%-
|
||||||
|
# forum_post
|
||||||
|
%>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<%= link_to content_tag(:i, nil, class: "far fa-thumbs-up"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=1"}, title: "Vote up" %>
|
||||||
|
|
||||||
|
<%= link_to content_tag(:i, nil, class: "far fa-meh"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=0"}, title: "Vote meh" %>
|
||||||
|
|
||||||
|
<%= link_to content_tag(:i, nil, class: "far fa-thumbs-down"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=-1"}, title: "Vote down" %>
|
||||||
|
</li>
|
||||||
16
app/views/forum_post_votes/_list.html.erb
Normal file
16
app/views/forum_post_votes/_list.html.erb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<%-
|
||||||
|
# votes
|
||||||
|
# forum_post
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% votes.by(CurrentUser.user.id).each do |vote| %>
|
||||||
|
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% votes.excluding(CurrentUser.user.id).each do |vote| %>
|
||||||
|
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if !votes.by(CurrentUser.user.id).exists? %>
|
||||||
|
<%= render "forum_post_votes/add_vote", vote: votes.by(CurrentUser.user.id).first, forum_post: forum_post %>
|
||||||
|
<% end %>
|
||||||
14
app/views/forum_post_votes/_vote.html.erb
Normal file
14
app/views/forum_post_votes/_vote.html.erb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<%-
|
||||||
|
# vote
|
||||||
|
# forum_post
|
||||||
|
%>
|
||||||
|
|
||||||
|
<li class="vote-score-<%= vote.vote_type %>">
|
||||||
|
<% if vote.creator_id == CurrentUser.id %>
|
||||||
|
<%= link_to content_tag(:i, nil, class: "far #{vote.fa_class}"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :delete %>
|
||||||
|
<%= link_to_user vote.creator %>
|
||||||
|
<% else %>
|
||||||
|
<%= content_tag(:i, nil, class: "far #{vote.fa_class}") %>
|
||||||
|
<%= link_to_user vote.creator %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
7
app/views/forum_post_votes/create.js.erb
Normal file
7
app/views/forum_post_votes/create.js.erb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<% if @forum_post_vote.invalid? %>
|
||||||
|
Danbooru.error(<%= raw @forum_post_vote.errors.full_messages.join("; ").to_json %>);
|
||||||
|
<% else %>
|
||||||
|
Danbooru.notice("Voted");
|
||||||
|
var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>;
|
||||||
|
$("#forum-post-votes-for-<%= @forum_post.id %>").html(code);
|
||||||
|
<% end %>
|
||||||
3
app/views/forum_post_votes/destroy.js.erb
Normal file
3
app/views/forum_post_votes/destroy.js.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Danbooru.notice("Unvoted");
|
||||||
|
var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>;
|
||||||
|
$("#forum-post-votes-for-<%= @forum_post.id %>").html(code);
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
<%- # original_forum_post_id: used to accelerate #is_original_post? calls %>
|
||||||
|
|
||||||
<% if forum_post.visible?(CurrentUser.user) %>
|
<% if forum_post.visible?(CurrentUser.user) %>
|
||||||
<article class="forum-post" id="forum_post_<%= forum_post.id %>" data-forum-post-id="<%= forum_post.id %>" data-creator="<%= forum_post.creator.name %>">
|
<article class="forum-post" id="forum_post_<%= forum_post.id %>" data-forum-post-id="<%= forum_post.id %>" data-creator="<%= forum_post.creator.name %>">
|
||||||
<div class="author">
|
<div class="author">
|
||||||
@@ -23,7 +25,7 @@
|
|||||||
<% if CurrentUser.is_member? && @forum_topic %>
|
<% if CurrentUser.is_member? && @forum_topic %>
|
||||||
<li><%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %></li>
|
<li><%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if CurrentUser.is_moderator? && !forum_post.is_original_post? %>
|
<% if CurrentUser.is_moderator? && !forum_post.is_original_post?(original_forum_post_id) %>
|
||||||
<% if forum_post.is_deleted %>
|
<% if forum_post.is_deleted %>
|
||||||
<li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
|
<li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -31,7 +33,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if forum_post.editable_by?(CurrentUser.user) %>
|
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||||
<% if forum_post.is_original_post? %>
|
<% if forum_post.is_original_post?(original_forum_post_id) %>
|
||||||
<li><%= link_to "Edit", edit_forum_topic_path(forum_post.topic), :id => "edit_forum_topic_link_#{forum_post.topic.id}", :class => "edit_forum_topic_link" %></li>
|
<li><%= link_to "Edit", edit_forum_topic_path(forum_post.topic), :id => "edit_forum_topic_link_#{forum_post.topic.id}", :class => "edit_forum_topic_link" %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id), :id => "edit_forum_post_link_#{forum_post.id}", :class => "edit_forum_post_link" %></li>
|
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id), :id => "edit_forum_post_link_#{forum_post.id}", :class => "edit_forum_post_link" %></li>
|
||||||
@@ -42,9 +44,14 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
|
<li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if forum_post.is_original_post?(original_forum_post_id) %>
|
||||||
|
<ul class="votes" id="forum-post-votes-for-<%= forum_post.id %>">
|
||||||
|
<%= render "forum_post_votes/list", votes: forum_post.votes, forum_post: forum_post %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
<% if forum_post.editable_by?(CurrentUser.user) %>
|
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||||
<% if forum_post.is_original_post? %>
|
<% if forum_post.is_original_post?(original_forum_post_id) %>
|
||||||
<%= render "forum_topics/form", :forum_topic => forum_post.topic %>
|
<%= render "forum_topics/form", :forum_topic => forum_post.topic %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render "forum_posts/partials/edit/form", :forum_post => forum_post %>
|
<%= render "forum_posts/partials/edit/form", :forum_post => forum_post %>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
<%- # forum_post %>
|
||||||
|
<%- # original_forum_post_id %>
|
||||||
|
|
||||||
<div class="list-of-forum-posts">
|
<div class="list-of-forum-posts">
|
||||||
<% forum_posts.each do |forum_post| %>
|
<% forum_posts.each do |forum_post| %>
|
||||||
<%= render "forum_posts/forum_post", :forum_post => forum_post %>
|
<%= render "forum_posts/forum_post", :forum_post => forum_post, :original_forum_post_id => original_forum_post_id %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div id="c-forum-posts">
|
<div id="c-forum-posts">
|
||||||
<div id="a-show" class="single-forum-post list-of-forum-posts">
|
<div id="a-show" class="single-forum-post list-of-forum-posts">
|
||||||
<h1>Topic: <%= @forum_post.topic.title %></h1>
|
<h1>Topic: <%= @forum_post.topic.title %></h1>
|
||||||
<%= render "forum_post", :forum_post => @forum_post %>
|
<%= render "forum_post", :forum_post => @forum_post, :original_forum_post_id => @forum_post.topic.original_post.id %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "forum_posts/listing", :forum_posts => @forum_posts %>
|
<%= render "forum_posts/listing", :forum_posts => @forum_posts, :original_forum_post_id => @forum_topic.original_post.id %>
|
||||||
|
|
||||||
<% if CurrentUser.is_member? %>
|
<% if CurrentUser.is_member? %>
|
||||||
<% if CurrentUser.is_moderator? || !@forum_topic.is_locked? %>
|
<% if CurrentUser.is_moderator? || !@forum_topic.is_locked? %>
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
<%= csrf_meta_tag %>
|
<%= csrf_meta_tag %>
|
||||||
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
|
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
|
||||||
<%= stylesheet_link_tag "application", :media => "screen" %>
|
<%= stylesheet_link_tag "application", :media => "screen" %>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||||
<%= javascript_include_tag "application" %>
|
<%= javascript_include_tag "application" %>
|
||||||
<%= Danbooru.config.custom_html_header_content %>
|
<%= Danbooru.config.custom_html_header_content %>
|
||||||
<meta name="enable-auto-complete" content="<%= CurrentUser.user.enable_auto_complete %>">
|
|
||||||
<%= yield :html_header %>
|
<%= yield :html_header %>
|
||||||
</head>
|
</head>
|
||||||
<body lang="en">
|
<body lang="en">
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
"url" : "<%= root_url %>"
|
"url" : "<%= root_url %>"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<script defer src="https://use.fontawesome.com/releases/v5.0.10/js/all.js" integrity="sha384-slN8GvtUJGnv6ca26v8EzVaR9DC58QEwsIk9q1QXdCU8Yu8ck/tL/5szYlBbqmS+" crossorigin="anonymous"></script>
|
||||||
</head>
|
</head>
|
||||||
<body lang="en" <%= body_attributes(CurrentUser.user) %>>
|
<body lang="en" <%= body_attributes(CurrentUser.user) %>>
|
||||||
<header id="top">
|
<header id="top">
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Specify a serializer for the signed and encrypted cookie jars.
|
||||||
|
# Valid options are :json, :marshal, and :hybrid.
|
||||||
Rails.application.config.action_dispatch.cookies_serializer = :json
|
Rails.application.config.action_dispatch.cookies_serializer = :json
|
||||||
|
|||||||
16
config/initializers/cors.rb
Normal file
16
config/initializers/cors.rb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Avoid CORS issues when API is called from the frontend app.
|
||||||
|
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
|
||||||
|
|
||||||
|
# Read more: https://github.com/cyu/rack-cors
|
||||||
|
|
||||||
|
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
||||||
|
# allow do
|
||||||
|
# origins 'example.com'
|
||||||
|
#
|
||||||
|
# resource '*',
|
||||||
|
# headers: :any,
|
||||||
|
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
|
||||||
|
# end
|
||||||
|
# end
|
||||||
@@ -5,6 +5,8 @@ en:
|
|||||||
hello: "Hello world"
|
hello: "Hello world"
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
|
forum_post_vote:
|
||||||
|
creator_id: "Your vote"
|
||||||
post:
|
post:
|
||||||
approver: "You"
|
approver: "You"
|
||||||
approver_id: "You"
|
approver_id: "You"
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ Rails.application.routes.draw do
|
|||||||
resource :order, :only => [:edit], :controller => "favorite_group_orders"
|
resource :order, :only => [:edit], :controller => "favorite_group_orders"
|
||||||
end
|
end
|
||||||
resources :forum_posts do
|
resources :forum_posts do
|
||||||
|
resource :votes, controller: "forum_post_votes"
|
||||||
member do
|
member do
|
||||||
post :undelete
|
post :undelete
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateUsers < ActiveRecord::Migration
|
class CreateUsers < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :users do |t|
|
create_table :users do |t|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePosts < ActiveRecord::Migration
|
class CreatePosts < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :posts do |t|
|
create_table :posts do |t|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateTags < ActiveRecord::Migration
|
class CreateTags < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :tags do |t|
|
create_table :tags do |t|
|
||||||
t.column :name, :string, :null => false
|
t.column :name, :string, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePostVersions < ActiveRecord::Migration
|
class CreatePostVersions < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :post_versions do |t|
|
create_table :post_versions do |t|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateUploads < ActiveRecord::Migration
|
class CreateUploads < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :uploads do |t|
|
create_table :uploads do |t|
|
||||||
t.column :source, :string
|
t.column :source, :string
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePools < ActiveRecord::Migration
|
class CreatePools < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :pools do |t|
|
create_table :pools do |t|
|
||||||
t.column :name, :string
|
t.column :name, :string
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateFavorites < ActiveRecord::Migration
|
class CreateFavorites < ActiveRecord::Migration[4.2]
|
||||||
TABLE_COUNT = 100
|
TABLE_COUNT = 100
|
||||||
|
|
||||||
def self.up
|
def self.up
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateTagAliases < ActiveRecord::Migration
|
class CreateTagAliases < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :tag_aliases do |t|
|
create_table :tag_aliases do |t|
|
||||||
t.column :antecedent_name, :string, :null => false
|
t.column :antecedent_name, :string, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateTagImplications < ActiveRecord::Migration
|
class CreateTagImplications < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :tag_implications do |t|
|
create_table :tag_implications do |t|
|
||||||
t.column :antecedent_name, :string, :null => false
|
t.column :antecedent_name, :string, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateComments < ActiveRecord::Migration
|
class CreateComments < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :comments do |t|
|
create_table :comments do |t|
|
||||||
t.column :post_id, :integer, :null => false
|
t.column :post_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateCommentVotes < ActiveRecord::Migration
|
class CreateCommentVotes < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :comment_votes do |t|
|
create_table :comment_votes do |t|
|
||||||
t.column :comment_id, :integer, :null => false
|
t.column :comment_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateArtists < ActiveRecord::Migration
|
class CreateArtists < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :artists do |t|
|
create_table :artists do |t|
|
||||||
t.column :name, :string, :null => false
|
t.column :name, :string, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateArtistVersions < ActiveRecord::Migration
|
class CreateArtistVersions < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :artist_versions do |t|
|
create_table :artist_versions do |t|
|
||||||
t.column :artist_id, :integer, :null => false
|
t.column :artist_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateArtistUrls < ActiveRecord::Migration
|
class CreateArtistUrls < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :artist_urls do |t|
|
create_table :artist_urls do |t|
|
||||||
t.column :artist_id, :integer, :null => false
|
t.column :artist_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateWikiPages < ActiveRecord::Migration
|
class CreateWikiPages < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :wiki_pages do |t|
|
create_table :wiki_pages do |t|
|
||||||
t.column :creator_id, :integer, :null => false
|
t.column :creator_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateWikiPageVersions < ActiveRecord::Migration
|
class CreateWikiPageVersions < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :wiki_page_versions do |t|
|
create_table :wiki_page_versions do |t|
|
||||||
t.column :wiki_page_id, :integer, :null => false
|
t.column :wiki_page_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePostVotes < ActiveRecord::Migration
|
class CreatePostVotes < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :post_votes do |t|
|
create_table :post_votes do |t|
|
||||||
t.column :post_id, :integer, :null => false
|
t.column :post_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateAdvertisements < ActiveRecord::Migration
|
class CreateAdvertisements < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :advertisements do |t|
|
create_table :advertisements do |t|
|
||||||
t.column :referral_url, :text, :null => false
|
t.column :referral_url, :text, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateAdvertisementHits < ActiveRecord::Migration
|
class CreateAdvertisementHits < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :advertisement_hits do |t|
|
create_table :advertisement_hits do |t|
|
||||||
t.column :advertisement_id, :integer, :null => false
|
t.column :advertisement_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateBans < ActiveRecord::Migration
|
class CreateBans < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :bans do |t|
|
create_table :bans do |t|
|
||||||
t.column :user_id, :integer
|
t.column :user_id, :integer
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateUserFeedback < ActiveRecord::Migration
|
class CreateUserFeedback < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :user_feedback do |t|
|
create_table :user_feedback do |t|
|
||||||
t.column :user_id, :integer, :null => false
|
t.column :user_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateDmails < ActiveRecord::Migration
|
class CreateDmails < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :dmails do |t|
|
create_table :dmails do |t|
|
||||||
t.column :owner_id, :integer, :null => false
|
t.column :owner_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateForumTopics < ActiveRecord::Migration
|
class CreateForumTopics < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :forum_topics do |t|
|
create_table :forum_topics do |t|
|
||||||
t.column :creator_id, :integer, :null => false
|
t.column :creator_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateForumPosts < ActiveRecord::Migration
|
class CreateForumPosts < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :forum_posts do |t|
|
create_table :forum_posts do |t|
|
||||||
t.column :topic_id, :integer, :null => false
|
t.column :topic_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePostDisapprovals < ActiveRecord::Migration
|
class CreatePostDisapprovals < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :post_disapprovals do |t|
|
create_table :post_disapprovals do |t|
|
||||||
t.column :user_id, :integer, :null => false
|
t.column :user_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateNotes < ActiveRecord::Migration
|
class CreateNotes < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :notes do |t|
|
create_table :notes do |t|
|
||||||
t.column :creator_id, :integer, :null => false
|
t.column :creator_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateNoteVersions < ActiveRecord::Migration
|
class CreateNoteVersions < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :note_versions do |t|
|
create_table :note_versions do |t|
|
||||||
t.column :note_id, :integer, :null => false
|
t.column :note_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateTagSubscriptions < ActiveRecord::Migration
|
class CreateTagSubscriptions < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :tag_subscriptions do |t|
|
create_table :tag_subscriptions do |t|
|
||||||
t.column :creator_id, :integer, :null => false
|
t.column :creator_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateJanitorTrials < ActiveRecord::Migration
|
class CreateJanitorTrials < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :janitor_trials do |t|
|
create_table :janitor_trials do |t|
|
||||||
t.column :creator_id, :integer, :null => false
|
t.column :creator_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateIpBans < ActiveRecord::Migration
|
class CreateIpBans < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :ip_bans do |t|
|
create_table :ip_bans do |t|
|
||||||
t.column :creator_id, :integer, :null => false
|
t.column :creator_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateDelayedJobs < ActiveRecord::Migration
|
class CreateDelayedJobs < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :delayed_jobs, :force => true do |table|
|
create_table :delayed_jobs, :force => true do |table|
|
||||||
table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
|
table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePostFlags < ActiveRecord::Migration
|
class CreatePostFlags < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :post_flags do |t|
|
create_table :post_flags do |t|
|
||||||
t.column :post_id, :integer, :null => false
|
t.column :post_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePostAppeals < ActiveRecord::Migration
|
class CreatePostAppeals < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
create_table :post_appeals do |t|
|
create_table :post_appeals do |t|
|
||||||
t.column :post_id, :integer, :null => false
|
t.column :post_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreatePoolVersions < ActiveRecord::Migration
|
class CreatePoolVersions < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
create_table :pool_versions do |t|
|
create_table :pool_versions do |t|
|
||||||
t.column :pool_id, :integer
|
t.column :pool_id, :integer
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateUserPasswordResetNonces < ActiveRecord::Migration
|
class CreateUserPasswordResetNonces < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
create_table :user_password_reset_nonces do |t|
|
create_table :user_password_reset_nonces do |t|
|
||||||
t.column :key, :string, :null => false
|
t.column :key, :string, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateModActions < ActiveRecord::Migration
|
class CreateModActions < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
create_table :mod_actions do |t|
|
create_table :mod_actions do |t|
|
||||||
t.column :creator_id, :integer, :null => false
|
t.column :creator_id, :integer, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateAmazonBackups < ActiveRecord::Migration
|
class CreateAmazonBackups < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
create_table :amazon_backups do |t|
|
create_table :amazon_backups do |t|
|
||||||
t.integer :last_id
|
t.integer :last_id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateNewsUpdates < ActiveRecord::Migration
|
class CreateNewsUpdates < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
create_table :news_updates do |t|
|
create_table :news_updates do |t|
|
||||||
t.column :message, :text, :null => false
|
t.column :message, :text, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddServerToUploads < ActiveRecord::Migration
|
class AddServerToUploads < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
add_column :uploads, :server, :text
|
add_column :uploads, :server, :text
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddQueueToDelayedJobs < ActiveRecord::Migration
|
class AddQueueToDelayedJobs < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
add_column :delayed_jobs, :queue, :string
|
add_column :delayed_jobs, :queue, :string
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class ChangeUploadsSourceToText < ActiveRecord::Migration
|
class ChangeUploadsSourceToText < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "alter table uploads alter column source type text"
|
execute "alter table uploads alter column source type text"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddParentIdToUploads < ActiveRecord::Migration
|
class AddParentIdToUploads < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
add_column :uploads, :parent_id, :integer
|
add_column :uploads, :parent_id, :integer
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddIndexUpdatedAtOnPostVersions < ActiveRecord::Migration
|
class AddIndexUpdatedAtOnPostVersions < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_index :post_versions, :updated_at
|
add_index :post_versions, :updated_at
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddIndexCreatedAtOnUserFeedback < ActiveRecord::Migration
|
class AddIndexCreatedAtOnUserFeedback < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_index :user_feedback, :created_at
|
add_index :user_feedback, :created_at
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddIndexUpdatedAtOnPoolVersions < ActiveRecord::Migration
|
class AddIndexUpdatedAtOnPoolVersions < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_index :pool_versions, :updated_at
|
add_index :pool_versions, :updated_at
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddIndexPixivOnPosts < ActiveRecord::Migration
|
class AddIndexPixivOnPosts < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
execute "CREATE INDEX index_posts_on_pixiv_suffix ON posts USING btree
|
execute "CREATE INDEX index_posts_on_pixiv_suffix ON posts USING btree
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddBcryptFieldsToUsers < ActiveRecord::Migration
|
class AddBcryptFieldsToUsers < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddSettingsToUsers < ActiveRecord::Migration
|
class AddSettingsToUsers < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
add_column :users, :enable_post_navigation, :boolean, :null => false, :default => true
|
add_column :users, :enable_post_navigation, :boolean, :null => false, :default => true
|
||||||
add_column :users, :new_post_navigation_layout, :boolean, :null => false, :default => true
|
add_column :users, :new_post_navigation_layout, :boolean, :null => false, :default => true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddLowerNameIndexToPools < ActiveRecord::Migration
|
class AddLowerNameIndexToPools < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def self.up
|
||||||
execute "create index index_pools_on_lower_name on pools (lower(name))"
|
execute "create index index_pools_on_lower_name on pools (lower(name))"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddUpdaterInfoToComments < ActiveRecord::Migration
|
class AddUpdaterInfoToComments < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
add_column :comments, :updater_id, :integer
|
add_column :comments, :updater_id, :integer
|
||||||
add_column :comments, :updater_ip_addr, "inet"
|
add_column :comments, :updater_ip_addr, "inet"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddUpdatedAtIndexToWikiPages < ActiveRecord::Migration
|
class AddUpdatedAtIndexToWikiPages < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
# add_index :wiki_pages, :updated_at
|
# add_index :wiki_pages, :updated_at
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddEnablePostSeqNavigationToUsers < ActiveRecord::Migration
|
class AddEnablePostSeqNavigationToUsers < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_column :users, :enable_sequential_post_navigation, :boolean, :null => false, :default => true
|
add_column :users, :enable_sequential_post_navigation, :boolean, :null => false, :default => true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class ChangeTagSubscriptionTagQueryType < ActiveRecord::Migration
|
class ChangeTagSubscriptionTagQueryType < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "alter table tag_subscriptions alter column tag_query type text"
|
execute "alter table tag_subscriptions alter column tag_query type text"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddUpdaterIdToWikiPages < ActiveRecord::Migration
|
class AddUpdaterIdToWikiPages < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
add_column :wiki_pages, :updater_id, :integer
|
add_column :wiki_pages, :updater_id, :integer
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddIsBannedToPosts < ActiveRecord::Migration
|
class AddIsBannedToPosts < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute("set statement_timeout = 0")
|
execute("set statement_timeout = 0")
|
||||||
add_column :posts, :is_banned, :boolean, :null => false, :default => false
|
add_column :posts, :is_banned, :boolean, :null => false, :default => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddPerPageToUsers < ActiveRecord::Migration
|
class AddPerPageToUsers < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute("set statement_timeout = 0")
|
execute("set statement_timeout = 0")
|
||||||
add_column :users, :per_page, :integer, :null => false, :default => 20
|
add_column :users, :per_page, :integer, :null => false, :default => 20
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddVersionToNotes < ActiveRecord::Migration
|
class AddVersionToNotes < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute("set statement_timeout = 0")
|
execute("set statement_timeout = 0")
|
||||||
add_column :notes, :version, :integer, :null => false, :default => 0
|
add_column :notes, :version, :integer, :null => false, :default => 0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddHideDeletedPostsToUsers < ActiveRecord::Migration
|
class AddHideDeletedPostsToUsers < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_column :users, :hide_deleted_posts, :boolean, :null => false, :default => false
|
add_column :users, :hide_deleted_posts, :boolean, :null => false, :default => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateUserNameChangeRequests < ActiveRecord::Migration
|
class CreateUserNameChangeRequests < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
create_table :user_name_change_requests do |t|
|
create_table :user_name_change_requests do |t|
|
||||||
t.string :status, :null => false, :default => "pending"
|
t.string :status, :null => false, :default => "pending"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class ChangeSourcePatternIndexOnPosts < ActiveRecord::Migration
|
class ChangeSourcePatternIndexOnPosts < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
execute "DROP INDEX index_posts_on_pixiv_suffix"
|
execute "DROP INDEX index_posts_on_pixiv_suffix"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class CreateKeyValues < ActiveRecord::Migration
|
class CreateKeyValues < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
create_table :key_values do |t|
|
create_table :key_values do |t|
|
||||||
t.string :key, :null => false
|
t.string :key, :null => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddPixivIdToPosts < ActiveRecord::Migration
|
class AddPixivIdToPosts < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_column :posts, :pixiv_id, :integer
|
add_column :posts, :pixiv_id, :integer
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class DropIndexPostsOnCreatedAtDate < ActiveRecord::Migration
|
class DropIndexPostsOnCreatedAtDate < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
execute "drop index index_posts_on_created_at_date"
|
execute "drop index index_posts_on_created_at_date"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddCreatorIdIndexToComments < ActiveRecord::Migration
|
class AddCreatorIdIndexToComments < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_index :comments, :creator_id
|
add_index :comments, :creator_id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddStyleUsernamesToUsers < ActiveRecord::Migration
|
class AddStyleUsernamesToUsers < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute "set statement_timeout = 0"
|
execute "set statement_timeout = 0"
|
||||||
add_column :users, :style_usernames, :boolean, :null => false, :default => false
|
add_column :users, :style_usernames, :boolean, :null => false, :default => false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddNameToPoolVersions < ActiveRecord::Migration
|
class AddNameToPoolVersions < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute("set statement_timeout = 0")
|
execute("set statement_timeout = 0")
|
||||||
add_column :pool_versions, :name, :string
|
add_column :pool_versions, :name, :string
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddCategoryToPools < ActiveRecord::Migration
|
class AddCategoryToPools < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute("set statement_timeout = 0")
|
execute("set statement_timeout = 0")
|
||||||
add_column :pools, :category, :string, :null => false, :default => "series"
|
add_column :pools, :category, :string, :null => false, :default => "series"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddCategoryToForumTopics < ActiveRecord::Migration
|
class AddCategoryToForumTopics < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
add_column :forum_topics, :category_id, :integer, :default => 0, :null => false
|
add_column :forum_topics, :category_id, :integer, :default => 0, :null => false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class AddEnableAutoCompleteToUsers < ActiveRecord::Migration
|
class AddEnableAutoCompleteToUsers < ActiveRecord::Migration[4.2]
|
||||||
def change
|
def change
|
||||||
execute("set statement_timeout = 0")
|
execute("set statement_timeout = 0")
|
||||||
add_column :users, :enable_auto_complete, :boolean, :null => false, :default => :true
|
add_column :users, :enable_auto_complete, :boolean, :null => false, :default => :true
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user