This commit is contained in:
albert
2013-04-09 18:05:23 -04:00
parent 0c16403c29
commit 56f1e19f67
5 changed files with 1 additions and 29 deletions

View File

@@ -66,12 +66,6 @@ class UsersController < ApplicationController
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)
raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?)

View File

@@ -1,20 +0,0 @@
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

View File

@@ -29,7 +29,7 @@
<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"><%= raw @user.favorite_tags %></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>
<span class="hint">A list of whitespace delimited tags that show up in your profile.</span>
</div>
</fieldset>

View File

@@ -1 +0,0 @@
$("#user_favorite_tags").val(<%= raw @user.favorite_tags.to_json %>);

View File

@@ -192,7 +192,6 @@ Danbooru::Application.routes.draw do
member do
delete :cache
post :upgrade
post :restore_uploaded_tags
end
end
resources :user_feedbacks