fixes #774
This commit is contained in:
@@ -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)
|
||||
|
||||
20
app/logical/uploaded_tags_importer.rb
Normal file
20
app/logical/uploaded_tags_importer.rb
Normal file
@@ -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
|
||||
@@ -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"} %>
|
||||
|
||||
<div class="input text optional field_with_hint">
|
||||
<label class="text optional" for="user_favorite_tags">Favorite tags</label>
|
||||
<textarea id="user_favorite_tags" class="text optional" rows="5" name="user[favorite_tags]" cols="40">1 2 3 </textarea>
|
||||
<span class="hint">A list of whitespace delimited tags that show up in your profile. <%= link_to "Restore from old database", restore_uploaded_tags_user_path(@user), :method => :post, :remote => true %></span>
|
||||
</div>
|
||||
|
||||
<%= f.input :blacklisted_tags, :hint => "A list of newline delimited tags that you never want to see", :input_html => {:size => "40x5"} %>
|
||||
</fieldset>
|
||||
|
||||
|
||||
1
app/views/users/restore_uploaded_tags.js.erb
Normal file
1
app/views/users/restore_uploaded_tags.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#favorite_tags").val(<%= raw @user.favorite_tags.to_json %>);
|
||||
@@ -187,6 +187,7 @@ Danbooru::Application.routes.draw do
|
||||
member do
|
||||
delete :cache
|
||||
post :upgrade
|
||||
post :restore_uploaded_tags
|
||||
end
|
||||
end
|
||||
resources :user_feedbacks
|
||||
|
||||
Reference in New Issue
Block a user