Compare commits

...

7 Commits

Author SHA1 Message Date
d1791e12c7 Merge pull request 'Do not require authentication to access the public website content' (#274) from public-access-website into main
Some checks failed
Run unit tests / rubocop (push) Failing after 30s
Run unit tests / check-licenses (push) Successful in 32s
Run unit tests / copyright_notice (push) Successful in 45s
Run unit tests / unit_tests (push) Successful in 1m27s
Run unit tests / build-static-assets (push) Has been skipped
Reviewed-on: #274
2025-06-09 06:35:59 +00:00
3832f1d840 Do not require authentication to access the public website content
All checks were successful
Run unit tests / check-licenses (pull_request) Successful in 40s
Run unit tests / rubocop (pull_request) Successful in 42s
Run unit tests / copyright_notice (pull_request) Successful in 53s
Run unit tests / unit_tests (pull_request) Successful in 1m23s
Run unit tests / build-static-assets (pull_request) Successful in 8m0s
2025-06-09 08:26:26 +02:00
4e2d046b18 Merge pull request 'Store website content as HTML' (#273) from store-website into main
All checks were successful
Run unit tests / rubocop (push) Successful in 45s
Run unit tests / check-licenses (push) Successful in 47s
Run unit tests / copyright_notice (push) Successful in 1m14s
Run unit tests / unit_tests (push) Successful in 3m45s
Run unit tests / build-static-assets (push) Successful in 15m46s
Reviewed-on: #273
2025-06-08 21:35:43 +00:00
c0ba659f29 Merge pull request 'Return guest that has just been created' (#272) from api/return-guest into main
Some checks failed
Run unit tests / rubocop (push) Successful in 41s
Run unit tests / check-licenses (push) Successful in 53s
Run unit tests / copyright_notice (push) Successful in 1m8s
Run unit tests / unit_tests (push) Successful in 3m2s
Run unit tests / build-static-assets (push) Has been cancelled
Reviewed-on: #272
2025-06-08 21:31:40 +00:00
fc9911abf4 Fix rubocop ofenses
All checks were successful
Run unit tests / rubocop (pull_request) Successful in 1m38s
Run unit tests / check-licenses (pull_request) Successful in 1m59s
Run unit tests / copyright_notice (pull_request) Successful in 2m32s
Run unit tests / unit_tests (pull_request) Successful in 4m10s
Run unit tests / build-static-assets (pull_request) Successful in 17m41s
2025-06-08 23:13:44 +02:00
3e363ac7dd Add copyright notice
Some checks failed
Run unit tests / check-licenses (pull_request) Successful in 59s
Run unit tests / rubocop (pull_request) Failing after 1m5s
Run unit tests / copyright_notice (pull_request) Successful in 2m46s
Run unit tests / unit_tests (pull_request) Successful in 5m9s
Run unit tests / build-static-assets (pull_request) Has been skipped
2025-06-08 19:03:39 +00:00
cc10fbfb83 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
2025-06-08 20:59:09 +02:00
8 changed files with 93 additions and 1 deletions

View File

@ -0,0 +1,25 @@
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
# frozen_string_literal: true
class WebsitesController < ApplicationController
skip_before_action :authenticate_user!, only: :show
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.expect(website: [:content])
end
end

25
app/models/website.rb Normal file
View File

@ -0,0 +1,25 @@
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
# frozen_string_literal: true
# == 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

View File

@ -23,4 +23,5 @@ class Wedding < ApplicationRecord
has_many :guests, dependent: :delete_all
has_many :groups, dependent: :delete_all
has_many :invitations, dependent: :delete_all
has_one :website, dependent: :destroy
end

View File

@ -37,6 +37,9 @@ Rails.application.routes.draw do
resources :expenses, only: %i[index create update destroy] do
get :summary, on: :collection
end
resource :website, only: [:show, :update]
resources :tables_arrangements, only: %i[index show create]
resources :summary, only: :index
resources :invitations, only: %i[index create update destroy]

View 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
View File

@ -10,7 +10,7 @@
#
# 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
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"
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|
t.string "slug", 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 "tables_arrangements", "weddings", on_delete: :cascade
add_foreign_key "users", "weddings", on_delete: :cascade
add_foreign_key "websites", "weddings"
end

View File

@ -0,0 +1,10 @@
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
# frozen_string_literal: true
FactoryBot.define do
factory :website do
content { 'MyText' }
wedding { nil }
end
end

View File

@ -0,0 +1,9 @@
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Website do
it { is_expected.to belong_to(:wedding) }
end