add support for searching for dup-related flags
This commit is contained in:
@@ -17,7 +17,8 @@ form.simple_form {
|
||||
}
|
||||
|
||||
span.hint {
|
||||
margin-left: 1em;
|
||||
display: block;
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
textarea {
|
||||
|
||||
@@ -144,6 +144,7 @@ module ApplicationHelper
|
||||
options[:value] ||= instance_variable_get("@#{object}").try(name)
|
||||
options[:preview_id] ||= "dtext-preview"
|
||||
options[:classes] ||= ""
|
||||
options[:type] ||= "text"
|
||||
|
||||
render "dtext/form", options
|
||||
end
|
||||
|
||||
@@ -33,6 +33,14 @@ class PostFlag < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def duplicate
|
||||
where("to_tsvector('english', post_flags.reason) @@ to_tsquery('dup | duplicate | sample | smaller')")
|
||||
end
|
||||
|
||||
def not_duplicate
|
||||
where("to_tsvector('english', post_flags.reason) @@ to_tsquery('!dup & !duplicate & !sample & !smaller')")
|
||||
end
|
||||
|
||||
def post_tags_match(query)
|
||||
PostQueryBuilder.new(query).build(self.joins(:post))
|
||||
end
|
||||
@@ -98,6 +106,8 @@ class PostFlag < ActiveRecord::Base
|
||||
q = q.where("reason LIKE ?", Reasons::REJECTED)
|
||||
when "deleted"
|
||||
q = q.where("reason = ? OR reason LIKE ?", Reasons::UNAPPROVED, Reasons::REJECTED)
|
||||
when "duplicate"
|
||||
q = q.duplicate
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -4,12 +4,17 @@
|
||||
- input_name
|
||||
- preview_id
|
||||
- value
|
||||
- type
|
||||
-->
|
||||
<div class="input text optional <%= classes %>">
|
||||
<label class="text optional" for="<%= input_id %>"><%= name %></label>
|
||||
|
||||
<div class="dtext-previewable">
|
||||
<textarea id="<%= input_id %>" class="text optional" rows="20" name="<%= input_name %>" cols="30"><%= value %></textarea>
|
||||
<% if type == "text" %>
|
||||
<textarea id="<%= input_id %>" class="text optional" rows="20" name="<%= input_name %>" cols="30"><%= value %></textarea>
|
||||
<% else %>
|
||||
<input type="text" id="<%= input_id %>" class="text optional" name="<%= input_name %>" value="<%= value %>">
|
||||
<% end %>
|
||||
<div id="<%= preview_id %>" class="dtext-preview prose"></div>
|
||||
</div>
|
||||
<span class="hint">All text is formatted using <%= link_to "DText", wiki_pages_path(:title => "help:dtext"), :target => "_blank" %></span>
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
<% @post_flag = post_flag %>
|
||||
<%= simple_form_for(@post_flag, format: :js, remote: true) do |f| %>
|
||||
<%= f.hidden_field :post_id %>
|
||||
<%= dtext_field "post_flag", "reason", preview_id: "dtext-preview-for-post-flag" %>
|
||||
<%= dtext_field "post_flag", "reason", preview_id: "dtext-preview-for-post-flag", type: "string" %>
|
||||
<%= dtext_preview_button "post_flag", "reason", preview_id: "dtext-preview-for-post-flag" %>
|
||||
<% end %>
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||
<% end %>
|
||||
<%= f.input :is_resolved, label: "Resolved?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_resolved] %>
|
||||
<%= f.input :category, label: "Category", collection: ["normal", "unapproved", "rejected", "deleted", "banned"], include_blank: true, selected: params[:search][:category] %>
|
||||
<%= f.input :category, label: "Category", collection: ["normal", "unapproved", "rejected", "deleted", "banned", "duplicate"], include_blank: true, selected: params[:search][:category] %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user