fixes #1209
This commit is contained in:
@@ -66,12 +66,6 @@ class UsersController < ApplicationController
|
|||||||
render :nothing => true
|
render :nothing => true
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore_uploaded_tags
|
|
||||||
@user = User.find(params[:id])
|
|
||||||
importer = UploadedTagsImporter.new(@user)
|
|
||||||
importer.import!
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_privilege(user)
|
def check_privilege(user)
|
||||||
raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?)
|
raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?)
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<div class="input text optional field_with_hint">
|
<div class="input text optional field_with_hint">
|
||||||
<label class="text optional" for="user_favorite_tags">Favorite tags</label>
|
<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>
|
<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>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
$("#user_favorite_tags").val(<%= raw @user.favorite_tags.to_json %>);
|
|
||||||
@@ -192,7 +192,6 @@ Danbooru::Application.routes.draw do
|
|||||||
member do
|
member do
|
||||||
delete :cache
|
delete :cache
|
||||||
post :upgrade
|
post :upgrade
|
||||||
post :restore_uploaded_tags
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :user_feedbacks
|
resources :user_feedbacks
|
||||||
|
|||||||
Reference in New Issue
Block a user