diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6a19f00d9..2a2eb0574 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -61,6 +61,12 @@ class UsersController < ApplicationController @user.update_cache render :nothing => true end + + def restore_uploaded_tags + @user = User.find(params[:id]) + importer = UploadedTagsImporter.new(@user) + importer.import! + end private def check_privilege(user) diff --git a/app/logical/uploaded_tags_importer.rb b/app/logical/uploaded_tags_importer.rb new file mode 100644 index 000000000..349d72db9 --- /dev/null +++ b/app/logical/uploaded_tags_importer.rb @@ -0,0 +1,20 @@ +class UploadedTagsImporter + attr_reader :user + + def initialize(user) + @user = user + end + + def import! + row = connection.exec("SELECT uploaded_tags FROM users WHERE id = #{user.id}").first + if row + user.update_attribute(:favorite_tags, row["uploaded_tags"]) + end + connection.close + rescue Exception + end + + def connection + @connection ||= PGconn.connect(:dbname => "danbooru", :host => "dbserver", :user => "albert") + end +end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 542c43342..0af874c8a 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -12,7 +12,13 @@ <%= f.input :default_image_size, :hint => "Large is #{Danbooru.config.large_image_width} pixels wide, and original is whatever the original image is", :collection => %w(large original), :include_blank => false %> <%= f.input :enable_post_navigation, :as => :select, :include_blank => false, :label => "Enable keyboard shortcuts" %> <%= f.input :new_post_navigation_layout, :as => :select, :label => "Pool links", :include_blank => false, :collection => [["Bottom", "true"], ["Top", "false"]], :hint => "When browsing pools, where do you want the navigation links to be placed?" %> - <%= f.input :favorite_tags, :hint => "A list of whitespace delimited tags that show up in your profile", :input_html => {:size => "40x5"} %> + +