forked from e621ng/e621ng
Remove user inviter system
This commit is contained in:
parent
ce38222a00
commit
bb9e30dc74
@ -34,8 +34,6 @@ class UserPromotion
|
||||
user.no_flagging = options[:no_flagging]
|
||||
end
|
||||
|
||||
user.inviter_id = promoter.id
|
||||
|
||||
create_user_feedback unless options[:is_upgbrade]
|
||||
create_dmail unless options[:skip_dmail]
|
||||
create_mod_actions
|
||||
|
@ -115,7 +115,6 @@ class User < ApplicationRecord
|
||||
has_many :user_name_change_requests, -> {visible.order("user_name_change_requests.created_at desc")}
|
||||
has_many :post_sets, -> {order(name: :asc)}, foreign_key: :creator_id
|
||||
has_many :favorites, ->(rec) {where("user_id = ?", rec.id).order("id desc")}
|
||||
belongs_to :inviter, class_name: "User", optional: true
|
||||
belongs_to :avatar, class_name: 'Post', optional: true
|
||||
accepts_nested_attributes_for :dmail_filter
|
||||
|
||||
@ -596,7 +595,7 @@ class User < ApplicationRecord
|
||||
|
||||
def method_attributes
|
||||
list = super + [
|
||||
:id, :created_at, :name, :inviter_id, :level, :base_upload_limit,
|
||||
:id, :created_at, :name, :level, :base_upload_limit,
|
||||
:post_upload_count, :post_update_count, :note_update_count,
|
||||
:is_banned, :can_approve_posts, :can_upload_free,
|
||||
:level_string,
|
||||
@ -749,7 +748,6 @@ class User < ApplicationRecord
|
||||
|
||||
q = q.search_text_attribute(:name, params)
|
||||
q = q.attribute_matches(:level, params[:level])
|
||||
q = q.attribute_matches(:inviter_id, params[:inviter_id])
|
||||
# TODO: Doesn't support relation filtering using this method.
|
||||
# q = q.attribute_matches(:post_upload_count, params[:post_upload_count])
|
||||
# q = q.attribute_matches(:post_update_count, params[:post_update_count])
|
||||
@ -760,10 +758,6 @@ class User < ApplicationRecord
|
||||
q = q.where_ilike(:name, normalize_name(params[:name_matches]))
|
||||
end
|
||||
|
||||
if params[:inviter].present?
|
||||
q = q.where(inviter_id: search(params[:inviter]))
|
||||
end
|
||||
|
||||
if params[:min_level].present?
|
||||
q = q.where("level >= ?", params[:min_level].to_i)
|
||||
end
|
||||
|
@ -18,12 +18,6 @@
|
||||
<tr>
|
||||
<th>Join Date</th>
|
||||
<td><%= presenter.join_date %></td>
|
||||
<th>Inviter</th>
|
||||
<% if user.inviter %>
|
||||
<td><%= link_to_user user.inviter %> <%= link_to "»", users_path(search: {inviter: {name: user.inviter.name}}) %></td>
|
||||
<% else %>
|
||||
<td>None</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
@ -34,9 +34,6 @@
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to_user user %>
|
||||
<% if user.inviter %>
|
||||
← <%= link_to_user user.inviter %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= link_to user.posts.count, posts_path(:tags => "user:#{user.name}") %></td>
|
||||
<td><%= user.posts.deleted.count %></td>
|
||||
|
@ -2,9 +2,6 @@
|
||||
<div id="a-search">
|
||||
<%= simple_form_for(:search, url: users_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :name_matches, label: "Name", hint: "Use * for wildcard", input_html: { value: params[:search][:name_matches], data: { autocomplete: "user" } } %>
|
||||
<%= f.simple_fields_for :inviter do |sub| %>
|
||||
<%= sub.input :name_matches, label: "Inviter Name", hint: "Use * for wildcard", input_html: { value: params.dig(:search, :inviter, :name_matches), data: { autocomplete: "user" } } %>
|
||||
<% end %>
|
||||
|
||||
<%= f.input :level, collection: User.level_hash.to_a, include_blank: true, selected: params[:search][:level] %>
|
||||
<%= f.input :min_level, collection: User.level_hash.to_a, include_blank: true, selected: params[:search][:min_level] %>
|
||||
|
5
db/migrate/20190916204908_remove_inviter_id.rb
Normal file
5
db/migrate/20190916204908_remove_inviter_id.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class RemoveInviterId < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
remove_column :users, :inviter_id
|
||||
end
|
||||
end
|
@ -5,6 +5,7 @@ SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
@ -2652,7 +2653,6 @@ CREATE TABLE public.users (
|
||||
password_hash character varying NOT NULL,
|
||||
email character varying,
|
||||
email_verification_key character varying,
|
||||
inviter_id integer,
|
||||
level integer DEFAULT 0 NOT NULL,
|
||||
base_upload_limit integer DEFAULT 10 NOT NULL,
|
||||
last_logged_in_at timestamp without time zone,
|
||||
@ -5257,6 +5257,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20190827223818'),
|
||||
('20190827233008'),
|
||||
('20190829044313'),
|
||||
('20190905111159');
|
||||
('20190905111159'),
|
||||
('20190916204908');
|
||||
|
||||
|
||||
|
@ -22,7 +22,6 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_redirected_to(edit_admin_user_path(@user))
|
||||
@user.reload
|
||||
assert_equal(30, @user.level)
|
||||
assert_equal(@mod.id, @user.inviter_id)
|
||||
end
|
||||
|
||||
context "promoted to an admin" do
|
||||
|
@ -28,7 +28,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
should "list all users (with blank search parameters)" do
|
||||
get users_path, params: { search: { inviter: { name_matches: "" }, level: "", name: "test" } }
|
||||
get users_path, params: { search: { level: "", name: "test" } }
|
||||
assert_redirected_to users_path(search: { name: "test" })
|
||||
end
|
||||
end
|
||||
@ -79,7 +79,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
Danbooru.config.stubs(:enable_recaptcha?).returns(false)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get new_user_path
|
||||
assert_response :success
|
||||
@ -95,7 +95,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
context "with sockpuppet validation enabled" do
|
||||
setup do
|
||||
Danbooru.config.unstub(:enable_sock_puppet_validation?)
|
||||
Danbooru.config.unstub(:enable_sock_puppet_validation?)
|
||||
@user.update(last_ip_addr: "127.0.0.1")
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user