diff --git a/app/models/community_user.rb b/app/models/community_user.rb index 1818fe2a11f484adc74356cc7080ade0cf335d0a..4917e529e2fe158332bfd487b9526c84f7967fc4 100644 --- a/app/models/community_user.rb +++ b/app/models/community_user.rb @@ -2,6 +2,8 @@ class CommunityUser < ApplicationRecord belongs_to :community belongs_to :user + has_many :mod_warnings, dependent: :destroy + validates :user_id, uniqueness: { scope: [:community_id] } scope :for_context, -> { where(community_id: RequestContext.community_id) } diff --git a/app/models/user.rb b/app/models/user.rb index 90e41012d22bfe0fb6ab9afef81df28958def14f..aef1dd3afa47d15a792a42696986a9b0ce52dc5a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,6 +19,8 @@ class User < ApplicationRecord has_many :suggested_edits, dependent: :destroy has_many :suggested_edits_decided, class_name: 'SuggestedEdit', foreign_key: 'decided_by_id', dependent: :nullify + has_many :mod_warning_author, class_name: 'ModWarning', foreign_key: 'author_id', dependent: :nullify + validates :username, presence: true, length: { minimum: 3, maximum: 50 } validates :login_token, uniqueness: { allow_nil: true, allow_blank: true } validate :no_links_in_username