|
|
|
@@ -4,7 +4,6 @@ class User < ApplicationRecord |
|
|
|
validates :name, length: { maximum: 255 } |
|
|
|
validates :inheritance_code, presence: true, length: { maximum: 64 } |
|
|
|
validates :role, presence: true, inclusion: { in: roles.keys } |
|
|
|
validates :banned, inclusion: { in: [true, false] } |
|
|
|
|
|
|
|
has_many :created_posts, |
|
|
|
class_name: 'Post', foreign_key: :uploaded_user_id, dependent: :nullify |
|
|
|
@@ -19,5 +18,9 @@ class User < ApplicationRecord |
|
|
|
class_name: 'WikiPage', foreign_key: :updated_user_id, dependent: :nullify |
|
|
|
|
|
|
|
def viewed?(post) = user_post_views.exists?(post_id: post.id) |
|
|
|
|
|
|
|
def gte_member? = member? || admin? |
|
|
|
|
|
|
|
def banned? = banned_at.present? |
|
|
|
def ban! = update!(banned_at: Time.current) |
|
|
|
end |