add some js to allow moderators to enter reason when deleting stories
This commit is contained in:
parent
10abf0bd7b
commit
f130dd7ab0
|
@ -153,6 +153,40 @@ var _Lobsters = Class.extend({
|
|||
$("#inside").load("/stories/preview", $(form).serializeArray());
|
||||
},
|
||||
|
||||
moderateStory: function(link) {
|
||||
var reason = prompt("Moderation reason:");
|
||||
if (reason == null || reason == "")
|
||||
return false;
|
||||
|
||||
var link = $(link);
|
||||
|
||||
/* $.rails.handleMethod() */
|
||||
var href = $.rails.href(link),
|
||||
method = link.data('method'),
|
||||
target = link.attr('target'),
|
||||
csrf_token = $("meta[name=csrf-token]").attr("content"),
|
||||
csrf_param = $("meta[name=csrf-param]").attr("content"),
|
||||
form = $("<form method=\"post\" action=\"" + href + "\"></form>"),
|
||||
metadata_input = "<input name=\"_method\" value=\"" + method +
|
||||
"\" type=\"hidden\" />";
|
||||
|
||||
if (csrf_param !== undefined && csrf_token !== undefined)
|
||||
metadata_input += "<input name=\"" + csrf_param + "\" value=\"" +
|
||||
csrf_token + "\" type=\"hidden\" />";
|
||||
|
||||
if (target)
|
||||
form.attr("target", target);
|
||||
|
||||
var r = $("<input type=\"hidden\" name=\"reason\" />");
|
||||
r.val(reason);
|
||||
form.append(r);
|
||||
|
||||
form.hide().append(metadata_input).appendTo('body');
|
||||
form.submit();
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
fetchURLTitle: function(button, url_field, title_field) {
|
||||
if (url_field.val() == "")
|
||||
return;
|
||||
|
@ -205,6 +239,10 @@ $(document).ready(function() {
|
|||
return false;
|
||||
});
|
||||
|
||||
$("li.story a.mod_story_link").click(function() {
|
||||
return Lobsters.moderateStory(this);
|
||||
}),
|
||||
|
||||
$("a.comment_replier").live("click", function() {
|
||||
if (!Lobsters.curUser) {
|
||||
Lobsters.bounceToLogin();
|
||||
|
|
|
@ -47,6 +47,11 @@ class StoriesController < ApplicationController
|
|||
|
||||
@story.is_expired = true
|
||||
@story.editor_user_id = @user.id
|
||||
|
||||
if params[:reason].present? && @story.user_id != @user.id
|
||||
@story.moderation_reason = params[:reason]
|
||||
end
|
||||
|
||||
@story.save(:validate => false)
|
||||
|
||||
redirect_to @story.comments_url
|
||||
|
|
|
@ -58,9 +58,15 @@ class="story <%= story.vote == 1 ? "upvoted" : (story.vote == -1 ?
|
|||
:confirm => "Are you sure you want to undelete this story?" } %>
|
||||
<% elsif !story.is_gone? %>
|
||||
|
|
||||
<%= link_to "delete", story_url(story.short_id),
|
||||
:method => :delete, :data => {
|
||||
:confirm => "Are you sure you want to delete this story?" } %>
|
||||
<% if story.user_id != @user.try(:id) &&
|
||||
@user.try(:is_moderator?) %>
|
||||
<%= link_to "delete", story_url(story.short_id),
|
||||
:method => :delete, :class => "mod_story_link" %>
|
||||
<% else %>
|
||||
<%= link_to "delete", story_url(story.short_id),
|
||||
:method => :delete, :data => {
|
||||
:confirm => "Are you sure you want to delete this story?" } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if !story.is_gone? %>
|
||||
|
|
Loading…
Reference in a new issue