fixes #1085
This commit is contained in:
@@ -281,17 +281,19 @@
|
||||
$("#edit").hide();
|
||||
}
|
||||
|
||||
Danbooru.Post.notice_update = function(x) {
|
||||
Danbooru.Post.notice_update = function(x, hide_msg) {
|
||||
if (x === "inc") {
|
||||
Danbooru.Post.pending_update_count += 1;
|
||||
Danbooru.notice("Updating posts (" + Danbooru.Post.pending_update_count + " pending)...");
|
||||
} else {
|
||||
Danbooru.Post.pending_update_count -= 1;
|
||||
|
||||
if (Danbooru.Post.pending_update_count < 1) {
|
||||
Danbooru.notice("Posts updated");
|
||||
} else {
|
||||
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...");
|
||||
if (!!hide_msg) {
|
||||
if (Danbooru.Post.pending_update_count < 1) {
|
||||
Danbooru.notice("Posts updated");
|
||||
} else {
|
||||
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,23 +306,10 @@
|
||||
}
|
||||
|
||||
Danbooru.Post.vote = function(score, id) {
|
||||
Danbooru.Post.notice_update("inc");
|
||||
Danbooru.notice("Voting...");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
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);
|
||||
}
|
||||
$.post("/posts/" + id + "/votes.js", {
|
||||
score: score
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
} else {
|
||||
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) {
|
||||
|
||||
@@ -527,8 +527,8 @@ class Post < ActiveRecord::Base
|
||||
def add_favorite!(user)
|
||||
return if favorited_by?(user.id)
|
||||
append_user_to_fav_string(user.id)
|
||||
increment!(:fav_count)
|
||||
increment!(:score) if CurrentUser.is_privileged?
|
||||
Post.connection.execute_sql("update posts set fav_count = fav_count + 1 where id = #{id}")
|
||||
Post.connection.execute_sql("update posts set score = score + 1 where id = #{id}") if CurrentUser.is_privileged?
|
||||
user.add_favorite!(self)
|
||||
end
|
||||
|
||||
@@ -538,8 +538,8 @@ class Post < ActiveRecord::Base
|
||||
|
||||
def remove_favorite!(user)
|
||||
return unless favorited_by?(user.id)
|
||||
decrement!(:fav_count)
|
||||
decrement!(:score) if CurrentUser.is_privileged?
|
||||
Post.connection.execute_sql("update posts set fav_count = fav_count - 1 where id = #{id}")
|
||||
Post.connection.execute_sql("update posts set score = score - 1 where id = #{id}") if CurrentUser.is_privileged?
|
||||
delete_user_from_fav_string(user.id)
|
||||
user.remove_favorite!(self)
|
||||
end
|
||||
@@ -597,7 +597,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
module VoteMethods
|
||||
def can_be_voted_by?(user)
|
||||
!votes.exists?(["user_id = ?", user.id])
|
||||
!PostVote.exists?(:user_id => user.id, :post_id => id)
|
||||
end
|
||||
|
||||
def vote!(score)
|
||||
@@ -612,6 +612,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
votes.create(:score => score)
|
||||
else
|
||||
puts "raising"
|
||||
raise PostVote::Error.new("You have already voted for this post")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<% if @error %>
|
||||
Danbooru.error("<%= j @error.to_s %>");
|
||||
Danbooru.notice("<%= j @error.to_s %>");
|
||||
<% else %>
|
||||
Danbooru.notice("Vote saved");
|
||||
$("#score-for-post-<%= @post.id %>").html(<%= @post.score %>);
|
||||
<% end %>
|
||||
|
||||
@@ -2691,7 +2691,8 @@ CREATE TABLE users (
|
||||
enable_privacy_mode boolean DEFAULT false NOT NULL,
|
||||
enable_sequential_post_navigation boolean DEFAULT true 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
|
||||
);
|
||||
|
||||
|
||||
@@ -6406,4 +6407,6 @@ INSERT INTO schema_migrations (version) VALUES ('20130331182719');
|
||||
|
||||
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