fixes #1085
This commit is contained in:
@@ -281,17 +281,19 @@
|
|||||||
$("#edit").hide();
|
$("#edit").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Post.notice_update = function(x) {
|
Danbooru.Post.notice_update = function(x, hide_msg) {
|
||||||
if (x === "inc") {
|
if (x === "inc") {
|
||||||
Danbooru.Post.pending_update_count += 1;
|
Danbooru.Post.pending_update_count += 1;
|
||||||
Danbooru.notice("Updating posts (" + Danbooru.Post.pending_update_count + " pending)...");
|
Danbooru.notice("Updating posts (" + Danbooru.Post.pending_update_count + " pending)...");
|
||||||
} else {
|
} else {
|
||||||
Danbooru.Post.pending_update_count -= 1;
|
Danbooru.Post.pending_update_count -= 1;
|
||||||
|
|
||||||
if (Danbooru.Post.pending_update_count < 1) {
|
if (!!hide_msg) {
|
||||||
Danbooru.notice("Posts updated");
|
if (Danbooru.Post.pending_update_count < 1) {
|
||||||
} else {
|
Danbooru.notice("Posts updated");
|
||||||
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...");
|
} else {
|
||||||
|
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,23 +306,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Post.vote = function(score, id) {
|
Danbooru.Post.vote = function(score, id) {
|
||||||
Danbooru.Post.notice_update("inc");
|
Danbooru.notice("Voting...");
|
||||||
|
|
||||||
$.ajax({
|
$.post("/posts/" + id + "/votes.js", {
|
||||||
type: "POST",
|
score: score
|
||||||
url: "/posts/" + id + "/votes",
|
|
||||||
data: {
|
|
||||||
score: score
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
Danbooru.Post.notice_update("dec");
|
|
||||||
},
|
|
||||||
success: function(data, status, xhr) {
|
|
||||||
$("post-score-" + data.post_id).html(data.score);
|
|
||||||
},
|
|
||||||
error: function(data, status, xhr) {
|
|
||||||
Danbooru.notice("Error: " + data.reason);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
} else {
|
} else {
|
||||||
top = element.offset().top - 10;
|
top = element.offset().top - 10;
|
||||||
}
|
}
|
||||||
$('html, body').animate({scrollTop: top}, 200, "linear", function() {Danbooru.scrolling = false;});
|
$('html, body').animate({scrollTop: top}, 300, "linear", function() {Danbooru.scrolling = false;});
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.notice = function(msg) {
|
Danbooru.notice = function(msg) {
|
||||||
|
|||||||
@@ -527,8 +527,8 @@ class Post < ActiveRecord::Base
|
|||||||
def add_favorite!(user)
|
def add_favorite!(user)
|
||||||
return if favorited_by?(user.id)
|
return if favorited_by?(user.id)
|
||||||
append_user_to_fav_string(user.id)
|
append_user_to_fav_string(user.id)
|
||||||
increment!(:fav_count)
|
Post.connection.execute_sql("update posts set fav_count = fav_count + 1 where id = #{id}")
|
||||||
increment!(:score) if CurrentUser.is_privileged?
|
Post.connection.execute_sql("update posts set score = score + 1 where id = #{id}") if CurrentUser.is_privileged?
|
||||||
user.add_favorite!(self)
|
user.add_favorite!(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -538,8 +538,8 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
def remove_favorite!(user)
|
def remove_favorite!(user)
|
||||||
return unless favorited_by?(user.id)
|
return unless favorited_by?(user.id)
|
||||||
decrement!(:fav_count)
|
Post.connection.execute_sql("update posts set fav_count = fav_count - 1 where id = #{id}")
|
||||||
decrement!(:score) if CurrentUser.is_privileged?
|
Post.connection.execute_sql("update posts set score = score - 1 where id = #{id}") if CurrentUser.is_privileged?
|
||||||
delete_user_from_fav_string(user.id)
|
delete_user_from_fav_string(user.id)
|
||||||
user.remove_favorite!(self)
|
user.remove_favorite!(self)
|
||||||
end
|
end
|
||||||
@@ -597,7 +597,7 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
module VoteMethods
|
module VoteMethods
|
||||||
def can_be_voted_by?(user)
|
def can_be_voted_by?(user)
|
||||||
!votes.exists?(["user_id = ?", user.id])
|
!PostVote.exists?(:user_id => user.id, :post_id => id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def vote!(score)
|
def vote!(score)
|
||||||
@@ -612,6 +612,7 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
votes.create(:score => score)
|
votes.create(:score => score)
|
||||||
else
|
else
|
||||||
|
puts "raising"
|
||||||
raise PostVote::Error.new("You have already voted for this post")
|
raise PostVote::Error.new("You have already voted for this post")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<% if @error %>
|
<% if @error %>
|
||||||
Danbooru.error("<%= j @error.to_s %>");
|
Danbooru.notice("<%= j @error.to_s %>");
|
||||||
<% else %>
|
<% else %>
|
||||||
|
Danbooru.notice("Vote saved");
|
||||||
$("#score-for-post-<%= @post.id %>").html(<%= @post.score %>);
|
$("#score-for-post-<%= @post.id %>").html(<%= @post.score %>);
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2691,7 +2691,8 @@ CREATE TABLE users (
|
|||||||
enable_privacy_mode boolean DEFAULT false NOT NULL,
|
enable_privacy_mode boolean DEFAULT false NOT NULL,
|
||||||
enable_sequential_post_navigation boolean DEFAULT true NOT NULL,
|
enable_sequential_post_navigation boolean DEFAULT true NOT NULL,
|
||||||
per_page integer DEFAULT 20 NOT NULL,
|
per_page integer DEFAULT 20 NOT NULL,
|
||||||
hide_deleted_posts boolean DEFAULT false NOT NULL
|
hide_deleted_posts boolean DEFAULT false NOT NULL,
|
||||||
|
style_usernames boolean DEFAULT false NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -6407,3 +6408,5 @@ INSERT INTO schema_migrations (version) VALUES ('20130331182719');
|
|||||||
INSERT INTO schema_migrations (version) VALUES ('20130401013601');
|
INSERT INTO schema_migrations (version) VALUES ('20130401013601');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20130409191950');
|
INSERT INTO schema_migrations (version) VALUES ('20130409191950');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20130417221643');
|
||||||
Reference in New Issue
Block a user