Store website content as HTML
Some checks failed
Run unit tests / rubocop (pull_request) Failing after 2m38s
Run unit tests / check-licenses (pull_request) Successful in 3m1s
Run unit tests / copyright_notice (pull_request) Successful in 1m55s
Run unit tests / unit_tests (pull_request) Successful in 5m25s
Run unit tests / build-static-assets (pull_request) Has been skipped
Some checks failed
Run unit tests / rubocop (pull_request) Failing after 2m38s
Run unit tests / check-licenses (pull_request) Successful in 3m1s
Run unit tests / copyright_notice (pull_request) Successful in 1m55s
Run unit tests / unit_tests (pull_request) Successful in 5m25s
Run unit tests / build-static-assets (pull_request) Has been skipped
This commit is contained in:
parent
9461fa5255
commit
cc10fbfb83
19
app/controllers/websites_controller.rb
Normal file
19
app/controllers/websites_controller.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
class WebsitesController < ApplicationController
|
||||||
|
def show
|
||||||
|
render json: current_tenant.website.as_json(only: %i[content]) || {}, status: :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
website = current_tenant.website || current_tenant.create_website
|
||||||
|
website.update!(website_params)
|
||||||
|
render json: website.as_json(only: %i[content]), status: :ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def website_params
|
||||||
|
params.require(:website).permit(:content)
|
||||||
|
end
|
||||||
|
end
|
21
app/models/website.rb
Normal file
21
app/models/website.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: websites
|
||||||
|
#
|
||||||
|
# id :bigint not null, primary key
|
||||||
|
# content :text
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# wedding_id :uuid not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_websites_on_wedding_id (wedding_id)
|
||||||
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# fk_rails_... (wedding_id => weddings.id)
|
||||||
|
#
|
||||||
|
class Website < ApplicationRecord
|
||||||
|
belongs_to :wedding
|
||||||
|
end
|
@ -23,4 +23,5 @@ class Wedding < ApplicationRecord
|
|||||||
has_many :guests, dependent: :delete_all
|
has_many :guests, dependent: :delete_all
|
||||||
has_many :groups, dependent: :delete_all
|
has_many :groups, dependent: :delete_all
|
||||||
has_many :invitations, dependent: :delete_all
|
has_many :invitations, dependent: :delete_all
|
||||||
|
has_one :website, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
@ -37,6 +37,9 @@ Rails.application.routes.draw do
|
|||||||
resources :expenses, only: %i[index create update destroy] do
|
resources :expenses, only: %i[index create update destroy] do
|
||||||
get :summary, on: :collection
|
get :summary, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resource :website, only: [:show, :update]
|
||||||
|
|
||||||
resources :tables_arrangements, only: %i[index show create]
|
resources :tables_arrangements, only: %i[index show create]
|
||||||
resources :summary, only: :index
|
resources :summary, only: :index
|
||||||
resources :invitations, only: %i[index create update destroy]
|
resources :invitations, only: %i[index create update destroy]
|
||||||
|
10
db/migrate/20250608181054_create_websites.rb
Normal file
10
db/migrate/20250608181054_create_websites.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
class CreateWebsites < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
create_table :websites do |t|
|
||||||
|
t.text :content
|
||||||
|
t.references :wedding, null: false, foreign_key: true, type: :uuid
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
11
db/schema.rb
generated
11
db/schema.rb
generated
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_01_27_190131) do
|
ActiveRecord::Schema[8.0].define(version: 2025_06_08_181054) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_catalog.plpgsql"
|
enable_extension "pg_catalog.plpgsql"
|
||||||
|
|
||||||
@ -241,6 +241,14 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_27_190131) do
|
|||||||
t.index ["wedding_id"], name: "index_users_on_wedding_id"
|
t.index ["wedding_id"], name: "index_users_on_wedding_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "websites", force: :cascade do |t|
|
||||||
|
t.text "content"
|
||||||
|
t.uuid "wedding_id", null: false
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["wedding_id"], name: "index_websites_on_wedding_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "weddings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "weddings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
t.string "slug", null: false
|
t.string "slug", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@ -268,4 +276,5 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_27_190131) do
|
|||||||
add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||||
add_foreign_key "tables_arrangements", "weddings", on_delete: :cascade
|
add_foreign_key "tables_arrangements", "weddings", on_delete: :cascade
|
||||||
add_foreign_key "users", "weddings", on_delete: :cascade
|
add_foreign_key "users", "weddings", on_delete: :cascade
|
||||||
|
add_foreign_key "websites", "weddings"
|
||||||
end
|
end
|
||||||
|
6
spec/factories/websites.rb
Normal file
6
spec/factories/websites.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FactoryBot.define do
|
||||||
|
factory :website do
|
||||||
|
content { "MyText" }
|
||||||
|
wedding { nil }
|
||||||
|
end
|
||||||
|
end
|
5
spec/models/website_spec.rb
Normal file
5
spec/models/website_spec.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Website, type: :model do
|
||||||
|
it { should belong_to(:wedding) }
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user