-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Extend embeddable hosts with Individual tags and author assi…
…gnments (#26868) * FEATURE: Extend embeddable hosts with tags and author assignments
- Loading branch information
1 parent
0e9451e
commit 63b7a36
Showing
19 changed files
with
423 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class EmbeddableHostTag < ActiveRecord::Base | ||
belongs_to :embeddable_host | ||
belongs_to :tag | ||
|
||
validates :embeddable_host_id, presence: true | ||
validates :tag_id, presence: true | ||
validates :embeddable_host_id, uniqueness: { scope: :tag_id } | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: embeddable_host_tags | ||
# | ||
# id :bigint not null, primary key | ||
# embeddable_host_id :integer not null | ||
# tag_id :integer not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_embeddable_host_tags_on_embeddable_host_id (embeddable_host_id) | ||
# index_embeddable_host_tags_on_embeddable_host_id_and_tag_id (embeddable_host_id,tag_id) UNIQUE | ||
# index_embeddable_host_tags_on_tag_id (tag_id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class EmbeddableHostSerializer < ApplicationSerializer | ||
TO_SERIALIZE = %i[id host allowed_paths class_name category_id] | ||
TO_SERIALIZE = %i[id host allowed_paths class_name category_id tags user] | ||
|
||
attributes *TO_SERIALIZE | ||
|
||
TO_SERIALIZE.each { |attr| define_method(attr) { object.public_send(attr) } } | ||
|
||
def user | ||
object.user&.username | ||
end | ||
|
||
def tags | ||
object.tags.map(&:name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
class AddUserIdToEmbeddableHosts < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :embeddable_hosts, :user_id, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
class CreateEmbeddableHostTags < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :embeddable_host_tags do |t| | ||
t.integer :embeddable_host_id, null: false | ||
t.integer :tag_id, null: false | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :embeddable_host_tags, :embeddable_host_id | ||
add_index :embeddable_host_tags, :tag_id | ||
add_index :embeddable_host_tags, %i[embeddable_host_id tag_id], unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#frozen_string_literal: true | ||
|
||
Fabricator(:embeddable_host_tag) do | ||
embeddable_host | ||
tag | ||
end |
Oops, something went wrong.