diff --git a/app/models/communication/extranet/post.rb b/app/models/communication/extranet/post.rb new file mode 100644 index 0000000000000000000000000000000000000000..35e3fb3958c39a6a2f89634ecfaa812ce3fc5bfe --- /dev/null +++ b/app/models/communication/extranet/post.rb @@ -0,0 +1,41 @@ +# == Schema Information +# +# Table name: communication_extranet_posts +# +# id :uuid not null, primary key +# featured_image_alt :string +# featured_image_credit :text +# published :boolean default(FALSE) +# published_at :datetime +# slug :string +# summary :text +# title :string +# created_at :datetime not null +# updated_at :datetime not null +# author_id :uuid indexed +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_extranet_posts_on_author_id (author_id) +# index_communication_extranet_posts_on_extranet_id (extranet_id) +# index_communication_extranet_posts_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_0232de42a1 (university_id => universities.id) +# fk_rails_4341823eab (extranet_id => communication_extranets.id) +# fk_rails_86cc935add (author_id => university_people.id) +# +class Communication::Extranet::Post < ApplicationRecord + include Sanitizable + include WithUniversity + include WithFeaturedImage + include WithBlocks + include WithPermalink + include WithSlug + + belongs_to :author, class_name: 'University::Person' + belongs_to :extranet, class_name: 'Communication::Extranet' +end diff --git a/db/migrate/20230307145748_create_communication_extranet_posts.rb b/db/migrate/20230307145748_create_communication_extranet_posts.rb new file mode 100644 index 0000000000000000000000000000000000000000..c9724dfdb8658239b2ebb398873c183007dc743f --- /dev/null +++ b/db/migrate/20230307145748_create_communication_extranet_posts.rb @@ -0,0 +1,18 @@ +class CreateCommunicationExtranetPosts < ActiveRecord::Migration[7.0] + def change + create_table :communication_extranet_posts, id: :uuid do |t| + t.string :title + t.boolean :published, default: false + t.datetime :published_at + t.references :author, foreign_key: {to_table: :university_people}, type: :uuid + t.references :extranet, null: false, foreign_key: {to_table: :communication_extranets}, type: :uuid + t.references :university, null: false, foreign_key: true, type: :uuid + t.string :featured_image_alt + t.text :featured_image_credit + t.string :slug + t.text :summary + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 0f5083066b2e4fb79d71c2596116099a7b48781b..3fbf22adfbfa782184974342422b24cd86280793 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_06_153945) do +ActiveRecord::Schema[7.0].define(version: 2023_03_07_145748) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -105,6 +105,24 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_06_153945) do t.index ["university_id"], name: "index_communication_extranet_connections_on_university_id" end + create_table "communication_extranet_posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "title" + t.boolean "published", default: false + t.datetime "published_at" + t.uuid "author_id" + t.uuid "extranet_id", null: false + t.uuid "university_id", null: false + t.string "featured_image_alt" + t.text "featured_image_credit" + t.string "slug" + t.text "summary" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["author_id"], name: "index_communication_extranet_posts_on_author_id" + t.index ["extranet_id"], name: "index_communication_extranet_posts_on_extranet_id" + t.index ["university_id"], name: "index_communication_extranet_posts_on_university_id" + end + create_table "communication_extranets", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.uuid "university_id", null: false @@ -966,6 +984,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_06_153945) do add_foreign_key "communication_blocks", "universities" add_foreign_key "communication_extranet_connections", "communication_extranets", column: "extranet_id" add_foreign_key "communication_extranet_connections", "universities" + add_foreign_key "communication_extranet_posts", "communication_extranets", column: "extranet_id" + add_foreign_key "communication_extranet_posts", "universities" + add_foreign_key "communication_extranet_posts", "university_people", column: "author_id" add_foreign_key "communication_extranets", "universities" add_foreign_key "communication_website_categories", "communication_website_categories", column: "original_id" add_foreign_key "communication_website_categories", "communication_website_categories", column: "parent_id" diff --git a/test/fixtures/communication/extranet/posts.yml b/test/fixtures/communication/extranet/posts.yml new file mode 100644 index 0000000000000000000000000000000000000000..fe704e31e7cd9e6ec60c71dae44f20251dd889a9 --- /dev/null +++ b/test/fixtures/communication/extranet/posts.yml @@ -0,0 +1,58 @@ +# == Schema Information +# +# Table name: communication_extranet_posts +# +# id :uuid not null, primary key +# featured_image_alt :string +# featured_image_credit :text +# published :boolean default(FALSE) +# published_at :datetime +# slug :string +# summary :text +# title :string +# created_at :datetime not null +# updated_at :datetime not null +# author_id :uuid indexed +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_extranet_posts_on_author_id (author_id) +# index_communication_extranet_posts_on_extranet_id (extranet_id) +# index_communication_extranet_posts_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_0232de42a1 (university_id => universities.id) +# fk_rails_4341823eab (extranet_id => communication_extranets.id) +# fk_rails_86cc935add (author_id => university_people.id) +# + +one: + title: MyString + published: false + published_at: 2023-03-07 15:57:51 + author: one + extranet: one + university: one + featured_image_alt: MyString + featured_image_credit: MyText + slug: MyString + summary: MyText + language: one + original: one + +two: + title: MyString + published: false + published_at: 2023-03-07 15:57:51 + author: two + extranet: two + university: two + featured_image_alt: MyString + featured_image_credit: MyText + slug: MyString + summary: MyText + language: two + original: two diff --git a/test/models/communication/extranet/post_test.rb b/test/models/communication/extranet/post_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..7ebb9729226d256d7dcfc1963f0d30598bea7724 --- /dev/null +++ b/test/models/communication/extranet/post_test.rb @@ -0,0 +1,37 @@ +# == Schema Information +# +# Table name: communication_extranet_posts +# +# id :uuid not null, primary key +# featured_image_alt :string +# featured_image_credit :text +# published :boolean default(FALSE) +# published_at :datetime +# slug :string +# summary :text +# title :string +# created_at :datetime not null +# updated_at :datetime not null +# author_id :uuid indexed +# extranet_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_extranet_posts_on_author_id (author_id) +# index_communication_extranet_posts_on_extranet_id (extranet_id) +# index_communication_extranet_posts_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_0232de42a1 (university_id => universities.id) +# fk_rails_4341823eab (extranet_id => communication_extranets.id) +# fk_rails_86cc935add (author_id => university_people.id) +# +require "test_helper" + +class Communication::Extranet::PostTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end