This commit is contained in:
Toks
2015-05-13 18:25:01 -04:00
parent 90a1694f62
commit 8c63bf5b72
5 changed files with 55 additions and 0 deletions

View File

@@ -565,6 +565,7 @@ Danbooru.Note = {
$("#image").unbind("click", Danbooru.Note.Box.toggle_all);
$("#image").bind("mousedown", Danbooru.Note.TranslationMode.Drag.start);
$(window).bind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
$("#mark-as-translated-section").show();
Danbooru.notice('Translation mode is on. Drag on the image to create notes. <a href="#">Turn translation mode off</a> (shortcut is <span class="key">n</span>).');
$("#notice a:contains(Turn translation mode off)").click(function(e) {
@@ -581,6 +582,7 @@ Danbooru.Note = {
$(window).unbind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
$(document.body).removeClass("mode-translation");
$("#close-notice-link").click();
$("#mark-as-translated-section").hide();
},
create_note: function(e, x, y, w, h) {

View File

@@ -122,6 +122,12 @@ class PostsController < ApplicationController
redirect_to post_path(@post, :tags => params[:tags])
end
def mark_as_translated
@post = Post.find(params[:id])
@post.mark_as_translated(params[:post])
respond_with(@post)
end
private
def tag_query
params[:tags] || (params[:post] && params[:post][:tags])

View File

@@ -1566,6 +1566,32 @@ class Post < ActiveRecord::Base
def strip_source
self.source = source.try(:strip)
end
def mark_as_translated(params)
tags = self.tag_array.dup
if params["check_translation"] == "1"
tags << "check_translation"
elsif params["check_translation"] == "0"
tags -= ["check_translation"]
end
if params["partially_translated"] == "1"
tags << "partially_translated"
elsif params["partially_translated"] == "0"
tags -= ["partially_translated"]
end
if params["check_translation"] == "1" || params["partially_translated"] == "1"
tags << "translation_request"
tags -= ["translated"]
else
tags << "translated"
tags -= ["translation_request"]
end
self.tag_string = tags.join(" ")
save
end
end
Post.connection.extend(PostgresExtensions)

View File

@@ -47,6 +47,26 @@
<%= @post.presenter.image_html(self) %>
</section>
<section id="mark-as-translated-section" style="display: none;">
<%= form_tag(mark_as_translated_post_path(@post), :class => "simple_form", :method => :put) do |f| %>
<fieldset>
<label for="post_check_translation">
<%= check_box "post", "check_translation", :checked => @post.has_tag?("check_translation") %>
Check translation
</label>
<label for="post_partially_translated">
<%= check_box "post", "partially_translated", :checked => @post.has_tag?("partially_translated") %>
Partially translated
</label>
</fieldset>
<div class="input">
<%= submit_tag "Mark as translated" %>
</div>
<% end %>
</section>
<% if @post.artist_commentary && @post.artist_commentary.any_field_present? %>
<div id="artist-commentary">
<%= render "artist_commentaries/show", :artist_commentary => @post.artist_commentary %>

View File

@@ -180,6 +180,7 @@ Rails.application.routes.draw do
put :copy_notes
get :show_seq
put :unvote
put :mark_as_translated
end
end
resources :post_appeals