diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 79daff0f5..de4346039 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -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. Turn translation mode off (shortcut is n).'); $("#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) { diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index ef4a8ccfd..79d29553e 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -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]) diff --git a/app/models/post.rb b/app/models/post.rb index 3432fbe79..855f40550 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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) diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index c86d31cf6..267dff155 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -47,6 +47,26 @@ <%= @post.presenter.image_html(self) %> + + <% if @post.artist_commentary && @post.artist_commentary.any_field_present? %>