diff --git a/app/assets/stylesheets/specific/users.css.scss b/app/assets/stylesheets/specific/users.css.scss index b6d2e1dfb..d7cca1839 100644 --- a/app/assets/stylesheets/specific/users.css.scss +++ b/app/assets/stylesheets/specific/users.css.scss @@ -59,7 +59,7 @@ div#c-users { } div#a-new { - max-width: 40em; + max-width: 60em; p { font-size: 1.2em; diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb index 1e9329984..3bde039cd 100644 --- a/app/controllers/tag_aliases_controller.rb +++ b/app/controllers/tag_aliases_controller.rb @@ -28,6 +28,8 @@ class TagAliasesController < ApplicationController def destroy @tag_alias = TagAlias.find(params[:id]) + @tag_alias.update_column(:status, "deleted") + @tag_alias.clear_all_cache @tag_alias.destroy respond_with(@tag_alias, :location => tag_aliases_path) end @@ -38,10 +40,4 @@ class TagAliasesController < ApplicationController @tag_alias.delay(:queue => "default").process! respond_with(@tag_alias, :location => tag_alias_path(@tag_alias)) end - - def cache - @tag_alias = TagAlias.find(params[:id]) - @tag_alias.clear_cache - render :nothing => true - end end diff --git a/app/logical/tag_alias_correction.rb b/app/logical/tag_alias_correction.rb index 094067f8f..f33b6b403 100644 --- a/app/logical/tag_alias_correction.rb +++ b/app/logical/tag_alias_correction.rb @@ -51,7 +51,6 @@ class TagAliasCorrection def fix! clear_cache - tag_alias.update_cache tag_alias.delay(:queue => "default").update_posts end end diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index 09cdccbdc..edd99cb42 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -1,6 +1,5 @@ class TagAlias < ActiveRecord::Base after_save :clear_all_cache - after_save :update_cache after_save :ensure_category_consistency after_destroy :clear_all_cache before_validation :initialize_creator, :on => :create @@ -35,7 +34,25 @@ class TagAlias < ActiveRecord::Base end end + module CacheMethods + extend ActiveSupport::Concern + + module ClassMethods + def clear_cache_for(name) + Cache.delete("ta:#{Cache.sanitize(name)}") + end + end + + def clear_all_cache + Danbooru.config.all_server_hosts.each do |host| + TagAlias.delay(:queue => host).clear_cache_for(antecedent_name) + TagAlias.delay(:queue => host).clear_cache_for(consequent_name) + end + end + end + extend SearchMethods + include CacheMethods def self.to_aliased(names) alias_hash = Cache.get_multi(names.flatten, "ta") do |name| @@ -96,22 +113,6 @@ class TagAlias < ActiveRecord::Base true end - def clear_all_cache - Danbooru.config.all_server_hosts.each do |host| - delay(:queue => host).clear_cache - end - end - - def clear_cache - Cache.delete("ta:#{Cache.sanitize(antecedent_name)}") - Cache.delete("ta:#{Cache.sanitize(consequent_name)}") - end - - def update_cache - Cache.put("ta:#{Cache.sanitize(antecedent_name)}", consequent_name) - Cache.delete("ta:#{Cache.sanitize(consequent_name)}") - end - def update_posts Post.raw_tag_match(antecedent_name).find_each do |post| escaped_antecedent_name = Regexp.escape(antecedent_name) diff --git a/app/views/static/name_change.html.erb b/app/views/static/name_change.html.erb new file mode 100644 index 000000000..f09c5aea8 --- /dev/null +++ b/app/views/static/name_change.html.erb @@ -0,0 +1,9 @@ +
+

Name Change

+ +

I want to change my name. Why can't I?

+ +

Moderators rely on user names to track identities. For example, if Bob has a history of leaving nasty comments, the mods will know that Bob has a bad reputation. But if Bob decides to change his name to Carl, and Carl starts leaving nasty comments again, the mods won't realize that Bob and Carl are the same person. They might be lenient with Carl instead of banning him.

+ +

For this reason user name changes are not supported.

+
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 24104efbf..894ca8174 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -4,6 +4,10 @@ <%= simple_form_for @user do |f| %>
+
+ +

Name changes are not supported. <%= link_to "Read why", name_change_path %>.

+
<%= f.input :email, :required => Danbooru.config.enable_email_verification?, :hint => "Used for messages and for password resets", :as => :email %> <%= f.input :time_zone, :include_blank => false %> <%= f.input :receive_email_notifications, :as => :select, :include_blank => false %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 8bb5317e5..1d0dcbd8b 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -3,6 +3,10 @@

Sign Up

A basic account is free and lets you keep favorites, upload artwork, and write comments. If you want <%= link_to "more features", wiki_pages_path(:title => "help:accounts") %> you can upgrade your account later.

+ +

This site is open to web crawlers so whatever name you choose will be public!

+ +

This includes favorites, uploads, and comments. Almost everything is public. So don't choose a name you don't want to be associated with.

<%= simple_form_for(@user) do |f| %> diff --git a/app/views/users/upgrade_information.html.erb b/app/views/users/upgrade_information.html.erb index c1af72f59..eddbefb58 100644 --- a/app/views/users/upgrade_information.html.erb +++ b/app/views/users/upgrade_information.html.erb @@ -50,7 +50,7 @@ Yes - See Deleted Posts + See Banned Posts No Yes Yes @@ -64,7 +64,7 @@
-

Just provide your email address and details for upgrading your account will be sent to you. If you have any further questions or concerns, feel free to contact me at <%= mail_to Danbooru.config.contact_email, nil, :encode => :javascript %>.

+

Just provide your email address and details for upgrading your account will be sent to you. Upgrading from Gold to Platinum will only cost $20. If you have any further questions or concerns, feel free to contact me at <%= mail_to Danbooru.config.contact_email, nil, :encode => :javascript %>.

<%= form_tag(upgrade_user_path(CurrentUser.user)) do %> <%= email_field_tag :email, CurrentUser.email %> diff --git a/config/routes.rb b/config/routes.rb index 5e272826a..dd0ddf02d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -159,7 +159,6 @@ Danbooru::Application.routes.draw do resources :tag_aliases do resource :correction, :only => [:new, :create, :show], :controller => "TagAliasCorrections" member do - delete :cache post :approve end collection do @@ -304,6 +303,7 @@ Danbooru::Application.routes.draw do match "/static/mrtg" => "static#mrtg", :as => "mrtg" match "/static/contact" => "static#contact", :as => "contact" match "/static/benchmark" => "static#benchmark" + match "/static/name_change" => "static#name_change", :as => "name_change" root :to => "posts#index" end diff --git a/test/unit/alias_and_implication_importer_test.rb b/test/unit/alias_and_implication_importer_test.rb index 776283c9d..ceff062bf 100644 --- a/test/unit/alias_and_implication_importer_test.rb +++ b/test/unit/alias_and_implication_importer_test.rb @@ -20,7 +20,7 @@ class AliasAndImplicationImporterTest < ActiveSupport::TestCase end should "process it" do - assert_difference("Delayed::Job.count", 3) do + assert_difference("Delayed::Job.count", 4) do @importer.process! end end diff --git a/test/unit/tag_alias_correction_test.rb b/test/unit/tag_alias_correction_test.rb index c78a9db3b..d2dbc206d 100644 --- a/test/unit/tag_alias_correction_test.rb +++ b/test/unit/tag_alias_correction_test.rb @@ -45,6 +45,7 @@ class TagAliasCorrectionTest < ActiveSupport::TestCase context "that is fixed" do setup do @correction.fix! + TagAlias.to_aliased(["aaa"]) end should "now have the correct cache" do diff --git a/test/unit/tag_alias_test.rb b/test/unit/tag_alias_test.rb index d58ba8506..e4479d940 100644 --- a/test/unit/tag_alias_test.rb +++ b/test/unit/tag_alias_test.rb @@ -32,11 +32,11 @@ class TagAliasTest < ActiveSupport::TestCase tag1 = FactoryGirl.create(:tag, :name => "aaa") tag2 = FactoryGirl.create(:tag, :name => "bbb") ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") - assert_nil(MEMCACHE.get("ta:aaa")) - ta.update_cache - assert_equal("bbb", MEMCACHE.get("ta:aaa")) + assert_nil(Cache.get("ta:aaa")) + TagAlias.to_aliased(["aaa"]) + assert_equal("bbb", Cache.get("ta:aaa")) ta.destroy - assert_nil(MEMCACHE.get("ta:aaa")) + assert_nil(Cache.get("ta:aaa")) end should "update any affected posts when saved" do