Change the way nuked users' posts are handled. Allow null in the user_id column of posts. Show these posts in the posts stream.

This commit is contained in:
Neil Lalonde
2013-09-03 17:19:29 -04:00
parent 1a6170a47c
commit 117fc8db58
16 changed files with 123 additions and 50 deletions

View File

@ -13,22 +13,22 @@ class User < ActiveRecord::Base
include Roleable
has_many :posts
has_many :notifications
has_many :topic_users
has_many :notifications, dependent: :destroy
has_many :topic_users, dependent: :destroy
has_many :topics
has_many :user_open_ids, dependent: :destroy
has_many :user_actions
has_many :post_actions
has_many :email_logs
has_many :user_actions, dependent: :destroy
has_many :post_actions, dependent: :destroy
has_many :email_logs, dependent: :destroy
has_many :post_timings
has_many :topic_allowed_users
has_many :topic_allowed_users, dependent: :destroy
has_many :topics_allowed, through: :topic_allowed_users, source: :topic
has_many :email_tokens
has_many :email_tokens, dependent: :destroy
has_many :views
has_many :user_visits
has_many :invites
has_many :topic_links
has_many :uploads
has_many :user_visits, dependent: :destroy
has_many :invites, dependent: :destroy
has_many :topic_links, dependent: :destroy
has_many :uploads, dependent: :destroy
has_one :facebook_user_info, dependent: :destroy
has_one :twitter_user_info, dependent: :destroy
@ -37,11 +37,11 @@ class User < ActiveRecord::Base
has_one :oauth2_user_info, dependent: :destroy
belongs_to :approved_by, class_name: 'User'
has_many :group_users
has_many :group_users, dependent: :destroy
has_many :groups, through: :group_users
has_many :secure_categories, through: :groups, source: :categories
has_one :user_search_data
has_one :user_search_data, dependent: :destroy
belongs_to :uploaded_avatar, class_name: 'Upload', dependent: :destroy
@ -61,6 +61,12 @@ class User < ActiveRecord::Base
after_create :create_email_token
before_destroy do
# These tables don't have primary keys, so destroying them with activerecord is tricky:
PostTiming.delete_all(user_id: self.id)
View.delete_all(user_id: self.id)
end
# Whether we need to be sending a system message after creation
attr_accessor :send_welcome_message