models: remove creator_id from artists, notes, and pools.

Remove the creator_id field from artists, notes, and pools. The
creator_id wasn't otherwise used and was inconsistent with the
artist/note/pool history in some cases, especially for old artists.
This commit is contained in:
evazion
2020-02-16 23:02:23 -06:00
parent 207861fd40
commit 2dab9aa075
16 changed files with 23 additions and 46 deletions

View File

@@ -11,7 +11,6 @@ class Artist < ApplicationRecord
after_save :clear_url_string_changed
validate :validate_tag_category
validates :name, tag_name: true, uniqueness: true
belongs_to :creator, class_name: "User"
has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name"
has_many :urls, :dependent => :destroy, :class_name => "ArtistUrl", :autosave => true
has_many :versions, -> {order("artist_versions.id ASC")}, :class_name => "ArtistVersion"
@@ -386,7 +385,7 @@ class Artist < ApplicationRecord
def search(params)
q = super
q = q.search_attributes(params, :is_active, :is_banned, :creator, :name, :group_name, :other_names)
q = q.search_attributes(params, :is_active, :is_banned, :name, :group_name, :other_names)
if params[:any_other_name_like]
q = q.any_other_name_like(params[:any_other_name_like])
@@ -446,6 +445,6 @@ class Artist < ApplicationRecord
end
def self.available_includes
[:creator, :members, :urls, :wiki_page, :tag_alias, :tag]
[:members, :urls, :wiki_page, :tag_alias, :tag]
end
end

View File

@@ -3,7 +3,6 @@ class Note < ApplicationRecord
attr_accessor :html_id
belongs_to :post
belongs_to :creator, class_name: "User"
has_many :versions, -> {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy
validates_presence_of :x, :y, :width, :height, :body
validate :note_within_image
@@ -19,7 +18,7 @@ class Note < ApplicationRecord
def search(params)
q = super
q = q.search_attributes(params, :creator, :post, :is_active, :x, :y, :width, :height, :body, :version)
q = q.search_attributes(params, :post, :is_active, :x, :y, :width, :height, :body, :version)
q = q.text_attribute_matches(:body, params[:body_matches], index_column: :body_index)
q.apply_default_order(params)
@@ -123,9 +122,8 @@ class Note < ApplicationRecord
save!
end
def copy_to(new_post, creator: CurrentUser.user)
def copy_to(new_post)
new_note = dup
new_note.creator = creator
new_note.post_id = new_post.id
new_note.version = 0
@@ -154,6 +152,6 @@ class Note < ApplicationRecord
end
def self.available_includes
[:creator, :post]
[:post]
end
end

View File

@@ -3,7 +3,6 @@ class Pool < ApplicationRecord
POOL_ORDER_LIMIT = 1000
array_attribute :post_ids, parse: /\d+/, cast: :to_i
belongs_to :creator, class_name: "User"
validates_uniqueness_of :name, case_sensitive: false, if: :name_changed?
validate :validate_name, if: :name_changed?
@@ -53,7 +52,7 @@ class Pool < ApplicationRecord
def search(params)
q = super
q = q.search_attributes(params, :creator, :is_deleted, :name, :description, :post_ids)
q = q.search_attributes(params, :is_deleted, :name, :description, :post_ids)
q = q.text_attribute_matches(:description, params[:description_matches])
if params[:post_tags_match]
@@ -300,8 +299,4 @@ class Pool < ApplicationRecord
errors[:base] << "You cannot removes posts from pools within the first week of sign up"
end
end
def self.available_includes
[:creator]
end
end