Merge branch 'main' into bustikiller-patch-2
Some checks failed
Run unit tests / rubocop (pull_request) Successful in 1m14s
Run unit tests / check-licenses (pull_request) Failing after 1m42s
Run unit tests / copyright_notice (pull_request) Successful in 2m57s
Run unit tests / unit_tests (pull_request) Successful in 6m24s
Run unit tests / build-static-assets (pull_request) Has been skipped
Some checks failed
Run unit tests / rubocop (pull_request) Successful in 1m14s
Run unit tests / check-licenses (pull_request) Failing after 1m42s
Run unit tests / copyright_notice (pull_request) Successful in 2m57s
Run unit tests / unit_tests (pull_request) Successful in 6m24s
Run unit tests / build-static-assets (pull_request) Has been skipped
This commit is contained in:
commit
8e866d8a35
1
.gitignore
vendored
1
.gitignore
vendored
@ -36,3 +36,4 @@
|
||||
|
||||
# Ignore swagger generated documentation
|
||||
swagger/v1/swagger.yaml
|
||||
wedding-planner.code-workspace
|
||||
|
46
Gemfile.lock
46
Gemfile.lock
@ -76,7 +76,7 @@ GEM
|
||||
rails (>= 6.0)
|
||||
addressable (2.8.7)
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
annotaterb (4.14.0)
|
||||
annotaterb (4.15.0)
|
||||
ast (2.4.3)
|
||||
babel-source (5.8.35)
|
||||
babel-transpiler (0.7.0)
|
||||
@ -87,7 +87,7 @@ GEM
|
||||
benchmark (0.4.0)
|
||||
bigdecimal (3.1.9)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.18.4)
|
||||
bootsnap (1.18.6)
|
||||
msgpack (~> 1.2)
|
||||
builder (3.3.0)
|
||||
childprocess (5.1.0)
|
||||
@ -95,9 +95,9 @@ GEM
|
||||
chroma (0.2.0)
|
||||
coderay (1.1.3)
|
||||
concurrent-ruby (1.3.5)
|
||||
connection_pool (2.5.1)
|
||||
connection_pool (2.5.3)
|
||||
crass (1.0.6)
|
||||
csv (3.3.4)
|
||||
csv (3.3.5)
|
||||
date (3.4.1)
|
||||
debug (1.10.0)
|
||||
irb (~> 1.10)
|
||||
@ -143,7 +143,7 @@ GEM
|
||||
jbuilder (2.13.0)
|
||||
actionview (>= 5.0.0)
|
||||
activesupport (>= 5.0.0)
|
||||
json (2.10.2)
|
||||
json (2.12.2)
|
||||
json-schema (5.0.1)
|
||||
addressable (~> 2.8)
|
||||
jsonapi-deserializable (0.2.0)
|
||||
@ -157,7 +157,7 @@ GEM
|
||||
jsonapi-renderer (0.2.2)
|
||||
jsonapi-serializable (0.3.1)
|
||||
jsonapi-renderer (~> 0.2.0)
|
||||
language_server-protocol (3.17.0.4)
|
||||
language_server-protocol (3.17.0.5)
|
||||
launchy (3.0.1)
|
||||
addressable (~> 2.8)
|
||||
childprocess (~> 5.0)
|
||||
@ -193,7 +193,7 @@ GEM
|
||||
minitest (5.25.5)
|
||||
money (6.19.0)
|
||||
i18n (>= 0.6.4, <= 2)
|
||||
msgpack (1.7.2)
|
||||
msgpack (1.7.5)
|
||||
multi_xml (0.7.1)
|
||||
bigdecimal (~> 3.1)
|
||||
net-imap (0.5.6)
|
||||
@ -240,7 +240,7 @@ GEM
|
||||
nio4r (~> 2.0)
|
||||
raabro (1.4.0)
|
||||
racc (1.8.1)
|
||||
rack (3.1.13)
|
||||
rack (3.1.14)
|
||||
rack-cors (2.0.2)
|
||||
rack (>= 2.0.0)
|
||||
rack-session (2.0.0)
|
||||
@ -331,7 +331,7 @@ GEM
|
||||
rswag-ui (2.16.0)
|
||||
actionpack (>= 5.2, < 8.1)
|
||||
railties (>= 5.2, < 8.1)
|
||||
rubocop (1.75.3)
|
||||
rubocop (1.75.8)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (~> 3.17.0.2)
|
||||
lint_roller (~> 1.1.0)
|
||||
@ -348,12 +348,12 @@ GEM
|
||||
rubocop-factory_bot (2.27.1)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rails (2.31.0)
|
||||
rubocop-rails (2.32.0)
|
||||
activesupport (>= 4.2.0)
|
||||
lint_roller (~> 1.1)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.75.0, < 2.0)
|
||||
rubocop-ast (>= 1.38.0, < 2.0)
|
||||
rubocop-ast (>= 1.44.0, < 2.0)
|
||||
rubocop-rspec (3.6.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
@ -366,7 +366,7 @@ GEM
|
||||
json (~> 2.0, > 2.9)
|
||||
rubyzip (2.3.2)
|
||||
securerandom (0.4.1)
|
||||
shoulda-matchers (6.4.0)
|
||||
shoulda-matchers (6.5.0)
|
||||
activesupport (>= 5.2.0)
|
||||
solid_queue (1.1.5)
|
||||
activejob (>= 7.1)
|
||||
@ -476,7 +476,7 @@ CHECKSUMS
|
||||
activesupport (8.0.2) sha256=8565cddba31b900cdc17682fd66ecd020441e3eef320a9930285394e8c07a45e
|
||||
acts_as_tenant (1.0.1) sha256=6944e4d64533337938a8817a6b4ff9b11189c9dcc0b1333bb89f3821a4c14c53
|
||||
addressable (2.8.7) sha256=462986537cf3735ab5f3c0f557f14155d778f4b43ea4f485a9deb9c8f7c58232
|
||||
annotaterb (4.14.0) sha256=466cf28443416a19754c807cb2acb9370c75a6a2bc3b92d3c4bbc02a38d00975
|
||||
annotaterb (4.15.0) sha256=fb871b5a3f96d1a3195ab0f0f51adb9105ab00492f10e97dd6f35d321e3410b0
|
||||
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
||||
babel-source (5.8.35) sha256=79ef222a9dcb867ac2efa3b0da35b4bcb15a4bfa67b6b2dcbf1e9a29104498d9
|
||||
babel-transpiler (0.7.0) sha256=4c06f4ad9e8e1cabe94f99e11df2f140bb72aca9ba067dbb49dc14d9b98d1570
|
||||
@ -485,15 +485,15 @@ CHECKSUMS
|
||||
benchmark (0.4.0) sha256=0f12f8c495545e3710c3e4f0480f63f06b4c842cc94cec7f33a956f5180e874a
|
||||
bigdecimal (3.1.9) sha256=2ffc742031521ad69c2dfc815a98e426a230a3d22aeac1995826a75dabfad8cc
|
||||
bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e
|
||||
bootsnap (1.18.4) sha256=ac4c42af397f7ee15521820198daeff545e4c360d2772c601fbdc2c07d92af55
|
||||
bootsnap (1.18.6) sha256=0ae2393c1e911e38be0f24e9173e7be570c3650128251bf06240046f84a07d00
|
||||
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
|
||||
childprocess (5.1.0) sha256=9a8d484be2fd4096a0e90a0cd3e449a05bc3aa33f8ac9e4d6dcef6ac1455b6ec
|
||||
chroma (0.2.0) sha256=64bdcd36a4765fbcd45adc64960cc153101300b4918f90ffdd89f4e2eb954b54
|
||||
coderay (1.1.3) sha256=dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b
|
||||
concurrent-ruby (1.3.5) sha256=813b3e37aca6df2a21a3b9f1d497f8cbab24a2b94cab325bffe65ee0f6cbebc6
|
||||
connection_pool (2.5.1) sha256=ae802a90a4b5a081101b39d618e69921a9a50bea9ac3420a5b8c71f1befa3e9c
|
||||
connection_pool (2.5.3) sha256=cfd74a82b9b094d1ce30c4f1a346da23ee19dc8a062a16a85f58eab1ced4305b
|
||||
crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d
|
||||
csv (3.3.4) sha256=e96ecd5a8c3494aa5b596282249daba5c6033203c199248e6146e36d2a78d8cd
|
||||
csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
|
||||
date (3.4.1) sha256=bf268e14ef7158009bfeaec40b5fa3c7271906e88b196d958a89d4b408abe64f
|
||||
debug (1.10.0) sha256=11e28ca74875979e612444104f3972bd5ffb9e79179907d7ad46dba44bd2e7a4
|
||||
devise (4.9.4) sha256=920042fe5e704c548aa4eb65ebdd65980b83ffae67feb32c697206bfd975a7f8
|
||||
@ -513,7 +513,7 @@ CHECKSUMS
|
||||
io-console (0.8.0) sha256=cd6a9facbc69871d69b2cb8b926fc6ea7ef06f06e505e81a64f14a470fddefa2
|
||||
irb (1.14.3) sha256=c457f1f2f1438ae9ce5c5be3981ae2138dec7fb894c7d73777eeeb0a6c0d0752
|
||||
jbuilder (2.13.0) sha256=7200a38a1c0081aa81b7a9757e7a299db75bc58cf1fd45ca7919a91627d227d6
|
||||
json (2.10.2) sha256=34e0eada93022b2a0a3345bb0b5efddb6e9ff5be7c48e409cfb54ff8a36a8b06
|
||||
json (2.12.2) sha256=ba94a48ad265605c8fa9a50a5892f3ba6a02661aa010f638211f3cb36f44abf4
|
||||
json-schema (5.0.1) sha256=bef71a82c600a42594911553522e143f7634affc198ed507ef3ded2f920a74a9
|
||||
jsonapi-deserializable (0.2.0) sha256=5f0ca2d3f8404cce1584a314e8a3753be32a56054c942adfe997b87e92bce147
|
||||
jsonapi-parser (0.1.1) sha256=9ee0dc031e88fc7548d56fab66f9716d1e1c06f972b529b8c4617bc42a097020
|
||||
@ -521,7 +521,7 @@ CHECKSUMS
|
||||
jsonapi-rb (0.5.0) sha256=7922a164278f506c43d56277f6bd0800a0b603cc985f7f63fe7241b2628bd105
|
||||
jsonapi-renderer (0.2.2) sha256=b5c44b033d61b4abdb6500fa4ab84807ca0b36ea0e59e47a2c3ca7095a6e447b
|
||||
jsonapi-serializable (0.3.1) sha256=221e657677659d798e268a33ec97a83ec5ea0e4233f931358db84e88056552e9
|
||||
language_server-protocol (3.17.0.4) sha256=c484626478664fd13482d8180947c50a8590484b1258b99b7aedb3b69df89669
|
||||
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
||||
launchy (3.0.1) sha256=b7fa60bda0197cf57614e271a250a8ca1f6a34ab889a3c73f67ec5d57c8a7f2c
|
||||
letter_opener (1.10.0) sha256=2ff33f2e3b5c3c26d1959be54b395c086ca6d44826e8bf41a14ff96fdf1bdbb2
|
||||
letter_opener_web (3.0.0) sha256=3f391efe0e8b9b24becfab5537dfb17a5cf5eb532038f947daab58cb4b749860
|
||||
@ -536,7 +536,7 @@ CHECKSUMS
|
||||
mini_portile2 (2.8.8) sha256=8e47136cdac04ce81750bb6c09733b37895bf06962554e4b4056d78168d70a75
|
||||
minitest (5.25.5) sha256=391b6c6cb43a4802bfb7c93af1ebe2ac66a210293f4a3fb7db36f2fc7dc2c756
|
||||
money (6.19.0) sha256=ec936fa1e42f2783719241ed9fd52725d0efa628f928feea1eb5c37d5de7daf3
|
||||
msgpack (1.7.2) sha256=59ab62fd8a4d0dfbde45009f87eb6f158ab2628a7c48886b0256f175166baaa8
|
||||
msgpack (1.7.5) sha256=ffb04979f51e6406823c03abe50e1da2c825c55a37dee138518cdd09d9d3aea8
|
||||
multi_xml (0.7.1) sha256=4fce100c68af588ff91b8ba90a0bb3f0466f06c909f21a32f4962059140ba61b
|
||||
net-imap (0.5.6) sha256=1ede8048ee688a14206060bf37a716d18cb6ea00855f6c9b15daee97ee51fbe5
|
||||
net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3
|
||||
@ -561,7 +561,7 @@ CHECKSUMS
|
||||
puma (6.6.0) sha256=f25c06873eb3d5de5f0a4ebc783acc81a4ccfe580c760cfe323497798018ad87
|
||||
raabro (1.4.0) sha256=d4fa9ff5172391edb92b242eed8be802d1934b1464061ae5e70d80962c5da882
|
||||
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
||||
rack (3.1.13) sha256=170c79db621882884d9a28d9cd5bd228c663fddcd367c4dea22c9a1808645792
|
||||
rack (3.1.14) sha256=84613c2a8df193bb6711d9c14ecc6d5a65a7cb4312379a65e793562608944b44
|
||||
rack-cors (2.0.2) sha256=415d4e1599891760c5dc9ef0349c7fecdf94f7c6a03e75b2e7c2b54b82adda1b
|
||||
rack-session (2.0.0) sha256=db04b2063e180369192a9046b4559af311990af38c6a93d4c600cee4eb6d4e81
|
||||
rack-test (2.1.0) sha256=0c61fc61904049d691922ea4bb99e28004ed3f43aa5cfd495024cc345f125dfb
|
||||
@ -589,17 +589,17 @@ CHECKSUMS
|
||||
rswag-api (2.16.0) sha256=b653f7bd92e98be18b01ab4525d88950d7b0960e293a99f856b9efcee3ae6074
|
||||
rswag-specs (2.16.0) sha256=8ba26085c408b0bd2ed21dc8015c80f417c7d34c63720ab7133c2549b5bd2a91
|
||||
rswag-ui (2.16.0) sha256=a1f49e927dceda92e6e6e7c1000f1e217ee66c565f69e28131dc98b33cd3a04f
|
||||
rubocop (1.75.3) sha256=1860a1b571fe4a15dff79d6683642ebf3ea4b3f7ae7903743ab0885b4686a1d5
|
||||
rubocop (1.75.8) sha256=c80ab4286c5dcfc49d7ad1787cdba5569b63b58c96ee7afde4ec47a9c8a85be9
|
||||
rubocop-ast (1.44.1) sha256=e3cc04203b2ef04f6d6cf5f85fe6d643f442b18cc3b23e3ada0ce5b6521b8e92
|
||||
rubocop-factory_bot (2.27.1) sha256=9d744b5916778c1848e5fe6777cc69855bd96548853554ec239ba9961b8573fe
|
||||
rubocop-rails (2.31.0) sha256=79476e1075299c3e60fc50549c7c32614f9ebaae719b899ed75785c6786c52bd
|
||||
rubocop-rails (2.32.0) sha256=9fcc623c8722fe71e835e99c4a18b740b5b0d3fb69915d7f0777f00794b30490
|
||||
rubocop-rspec (3.6.0) sha256=c0e4205871776727e54dee9cc91af5fd74578001551ba40e1fe1a1ab4b404479
|
||||
rubocop-rspec_rails (2.31.0) sha256=775375e18a26a1184a812ef3054b79d218e85601b9ae897f38f8be24dddf1f45
|
||||
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
||||
rubytree (2.1.1) sha256=4925016356a81730e982f1f8c3b5f8da461f18906c77d238bad4c4ba896abd41
|
||||
rubyzip (2.3.2) sha256=3f57e3935dc2255c414484fbf8d673b4909d8a6a57007ed754dde39342d2373f
|
||||
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
||||
shoulda-matchers (6.4.0) sha256=9055bb7f4bb342125fb860809798855c630e05ef5e75837b3168b8e6ee1608b0
|
||||
shoulda-matchers (6.5.0) sha256=ef6b572b2bed1ac4aba6ab2c5ff345a24b6d055a93a3d1c3bfc86d9d499e3f44
|
||||
solid_queue (1.1.5) sha256=bae0c9d76310f4953ebc57466f2e8c78703a0fbf4b89d25756c23c88f9b6df9b
|
||||
sprockets (4.2.1) sha256=951b13dd2f2fcae840a7184722689a803e0ff9d2702d902bd844b196da773f97
|
||||
sprockets-rails (3.5.2) sha256=a9e88e6ce9f8c912d349aa5401509165ec42326baf9e942a85de4b76dbc4119e
|
||||
|
48
app/controllers/invitations_controller.rb
Normal file
48
app/controllers/invitations_controller.rb
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
||||
|
||||
class InvitationsController < ApplicationController
|
||||
def index
|
||||
render json: Invitation.includes(:guests).as_json(
|
||||
only: :id,
|
||||
include: {
|
||||
guests: {
|
||||
only: %i[id name]
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def create
|
||||
invitation = Invitation.create
|
||||
|
||||
if invitation.persisted?
|
||||
render json: invitation, only: :id, status: :created
|
||||
else
|
||||
render json: { errors: invitation.errors.full_messages }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
invitation = Invitation.find(params[:id])
|
||||
|
||||
if invitation.update(guest_ids: params[:invitation][:guest_ids])
|
||||
render json: invitation, only: :id, include: { guests: { only: %i[id name] } }, status: :ok
|
||||
else
|
||||
render json: { errors: invitation.errors.full_messages }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
invitation = Invitation.find(params[:id])
|
||||
|
||||
if invitation.destroy
|
||||
head :no_content
|
||||
else
|
||||
render json: { errors: invitation.errors.full_messages }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
end
|
@ -20,7 +20,7 @@
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (wedding_id => weddings.id)
|
||||
# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade
|
||||
#
|
||||
class Expense < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
|
@ -25,7 +25,7 @@
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (parent_id => groups.id)
|
||||
# fk_rails_... (wedding_id => weddings.id)
|
||||
# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade
|
||||
#
|
||||
class Group < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
|
@ -6,28 +6,32 @@
|
||||
#
|
||||
# Table name: guests
|
||||
#
|
||||
# id :uuid not null, primary key
|
||||
# name :string
|
||||
# phone :string
|
||||
# status :integer default("considered")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# group_id :uuid
|
||||
# wedding_id :uuid not null
|
||||
# id :uuid not null, primary key
|
||||
# name :string
|
||||
# phone :string
|
||||
# status :integer default("considered")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# group_id :uuid
|
||||
# invitation_id :uuid
|
||||
# wedding_id :uuid not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_guests_on_group_id (group_id)
|
||||
# index_guests_on_wedding_id (wedding_id)
|
||||
# index_guests_on_group_id (group_id)
|
||||
# index_guests_on_invitation_id (invitation_id)
|
||||
# index_guests_on_wedding_id (wedding_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (group_id => groups.id)
|
||||
# fk_rails_... (wedding_id => weddings.id)
|
||||
# fk_rails_... (invitation_id => invitations.id)
|
||||
# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade
|
||||
#
|
||||
class Guest < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
belongs_to :group, optional: true
|
||||
belongs_to :invitation, optional: true
|
||||
|
||||
enum :status, {
|
||||
considered: 0,
|
||||
|
25
app/models/invitation.rb
Normal file
25
app/models/invitation.rb
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: invitations
|
||||
#
|
||||
# id :uuid not null, primary key
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# wedding_id :uuid not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_invitations_on_wedding_id (wedding_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade
|
||||
#
|
||||
class Invitation < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
has_many :guests, dependent: :nullify
|
||||
end
|
@ -24,7 +24,7 @@
|
||||
#
|
||||
# fk_rails_... (guest_id => guests.id)
|
||||
# fk_rails_... (tables_arrangement_id => tables_arrangements.id) ON DELETE => cascade
|
||||
# fk_rails_... (wedding_id => weddings.id)
|
||||
# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade
|
||||
#
|
||||
class Seat < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
|
@ -20,7 +20,7 @@
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (wedding_id => weddings.id)
|
||||
# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade
|
||||
#
|
||||
class TablesArrangement < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
|
@ -32,7 +32,7 @@
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (wedding_id => weddings.id)
|
||||
# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade
|
||||
#
|
||||
class User < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
|
@ -21,4 +21,6 @@ class Wedding < ApplicationRecord
|
||||
validates :slug, presence: true, uniqueness: true, format: { with: /\A#{SLUG_REGEX}\z/ }
|
||||
|
||||
has_many :guests, dependent: :delete_all
|
||||
has_many :groups, dependent: :delete_all
|
||||
has_many :invitations, dependent: :delete_all
|
||||
end
|
||||
|
@ -2,4 +2,8 @@
|
||||
|
||||
ActsAsTenant.configure do |config|
|
||||
config.require_tenant = !Rails.env.test?
|
||||
end
|
||||
end
|
||||
|
||||
Rails.application.console do
|
||||
ActsAsTenant.current_tenant = Wedding.first
|
||||
end
|
||||
|
@ -39,6 +39,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
resources :tables_arrangements, only: %i[index show create]
|
||||
resources :summary, only: :index
|
||||
resources :invitations, only: %i[index create update destroy]
|
||||
|
||||
root to: redirect("/%{slug}")
|
||||
end
|
||||
|
10
db/migrate/20250127183547_create_invitations.rb
Normal file
10
db/migrate/20250127183547_create_invitations.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class CreateInvitations < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :invitations, id: :uuid do |t|
|
||||
t.references :wedding, null: false, foreign_key: { on_delete: :cascade }, type: :uuid
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_reference :guests, :invitation, foreign_key: true, type: :uuid
|
||||
end
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
class FixCascadingWeddingDeletion < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
[:expenses, :groups, :guests, :seats, :tables_arrangements, :users].each do |table|
|
||||
remove_foreign_key table, :weddings, column: :wedding_id
|
||||
add_foreign_key table, :weddings, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
end
|
25
db/schema.rb
generated
25
db/schema.rb
generated
@ -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_26_091823) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_01_27_190131) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
@ -63,10 +63,19 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_26_091823) do
|
||||
t.integer "status", default: 0
|
||||
t.string "name"
|
||||
t.uuid "wedding_id", null: false
|
||||
t.uuid "invitation_id"
|
||||
t.index ["group_id"], name: "index_guests_on_group_id"
|
||||
t.index ["invitation_id"], name: "index_guests_on_invitation_id"
|
||||
t.index ["wedding_id"], name: "index_guests_on_wedding_id"
|
||||
end
|
||||
|
||||
create_table "invitations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "wedding_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["wedding_id"], name: "index_invitations_on_wedding_id"
|
||||
end
|
||||
|
||||
create_table "seats", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "guest_id", null: false
|
||||
t.uuid "tables_arrangement_id", null: false
|
||||
@ -239,22 +248,24 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_26_091823) do
|
||||
t.index ["slug"], name: "index_weddings_on_slug", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "expenses", "weddings"
|
||||
add_foreign_key "expenses", "weddings", on_delete: :cascade
|
||||
add_foreign_key "group_affinities", "groups", column: "group_a_id"
|
||||
add_foreign_key "group_affinities", "groups", column: "group_b_id"
|
||||
add_foreign_key "groups", "groups", column: "parent_id"
|
||||
add_foreign_key "groups", "weddings"
|
||||
add_foreign_key "groups", "weddings", on_delete: :cascade
|
||||
add_foreign_key "guests", "groups"
|
||||
add_foreign_key "guests", "weddings"
|
||||
add_foreign_key "guests", "invitations"
|
||||
add_foreign_key "guests", "weddings", on_delete: :cascade
|
||||
add_foreign_key "invitations", "weddings", on_delete: :cascade
|
||||
add_foreign_key "seats", "guests"
|
||||
add_foreign_key "seats", "tables_arrangements", on_delete: :cascade
|
||||
add_foreign_key "seats", "weddings"
|
||||
add_foreign_key "seats", "weddings", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_recurring_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"
|
||||
add_foreign_key "users", "weddings"
|
||||
add_foreign_key "tables_arrangements", "weddings", on_delete: :cascade
|
||||
add_foreign_key "users", "weddings", on_delete: :cascade
|
||||
end
|
||||
|
70
db/seeds.rb
70
db/seeds.rb
@ -1,33 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
||||
|
||||
NUMBER_OF_GUESTS = 50
|
||||
NUMBER_OF_GUESTS = 200
|
||||
|
||||
ActsAsTenant.without_tenant do
|
||||
TablesArrangement.delete_all
|
||||
Expense.delete_all
|
||||
Guest.delete_all
|
||||
Group.delete_all
|
||||
|
||||
GroupAffinity.delete_all
|
||||
Wedding.delete_all
|
||||
end
|
||||
|
||||
wedding = Wedding.create!(slug: :default)
|
||||
|
||||
ActsAsTenant.with_tenant(wedding) do
|
||||
Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Country house', amount: 6000, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Catering', amount: 200, pricing_type: 'per_person')
|
||||
Expense.create!(name: 'Flowers', amount: 500, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Band', amount: 1000, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Wedding planner', amount: 2000, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Dress', amount: 1000, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Suit', amount: 500, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Rings', amount: 1000, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Makeup', amount: 200, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Hair', amount: 200, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Transportation', amount: 3000, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed')
|
||||
Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed')
|
||||
[
|
||||
{ name: 'Photographer', amount: 3000, pricing_type: 'fixed' },
|
||||
{ name: 'Country house', amount: 6000, pricing_type: 'fixed' },
|
||||
{ name: 'Catering', amount: 200, pricing_type: 'per_person' },
|
||||
{ name: 'Flowers', amount: 500, pricing_type: 'fixed' },
|
||||
{ name: 'Band', amount: 1000, pricing_type: 'fixed' },
|
||||
{ name: 'Wedding planner', amount: 2000, pricing_type: 'fixed' },
|
||||
{ name: 'Dress', amount: 1000, pricing_type: 'fixed' },
|
||||
{ name: 'Suit', amount: 500, pricing_type: 'fixed' },
|
||||
{ name: 'Rings', amount: 1000, pricing_type: 'fixed' },
|
||||
{ name: 'Makeup', amount: 200, pricing_type: 'fixed' },
|
||||
{ name: 'Hair', amount: 200, pricing_type: 'fixed' },
|
||||
{ name: 'Transportation', amount: 3000, pricing_type: 'fixed' },
|
||||
{ name: 'Invitations', amount: 200, pricing_type: 'fixed' },
|
||||
{ name: 'Cake', amount: 500, pricing_type: 'fixed' }
|
||||
].then { Expense.insert_all!(it) }
|
||||
|
||||
Group.create!(name: "Jim's guests", icon: 'pi pi-heart').tap do |parent|
|
||||
parent.children.create!(name: "Jim's family", icon: 'pi pi-users').tap do |family|
|
||||
@ -61,18 +61,34 @@ ActsAsTenant.with_tenant(wedding) do
|
||||
|
||||
groups = Group.all
|
||||
|
||||
NUMBER_OF_GUESTS.times do
|
||||
Guest.create!(
|
||||
NUMBER_OF_GUESTS.times.map do |i|
|
||||
{
|
||||
name: Faker::Name.name,
|
||||
phone: Faker::PhoneNumber.cell_phone,
|
||||
group: groups.sample,
|
||||
status: Guest.statuses.keys.sample
|
||||
)
|
||||
group_id: groups.sample.id,
|
||||
status: Guest.statuses.keys.sample,
|
||||
}
|
||||
end.then { Guest.insert_all!(it) }
|
||||
|
||||
Group.includes(:guests).each do |group|
|
||||
guests = group.guests.potential.to_a
|
||||
|
||||
while guests.any?
|
||||
invitation = Invitation.create!
|
||||
|
||||
guests.shift(rand(1..3)).each do |guest|
|
||||
guest.update!(invitation:)
|
||||
end
|
||||
guests.shift(1) if rand < 0.3 # Leave a percentage of guests without an invitation
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Clean up invitations with no guests
|
||||
|
||||
ActiveJob.perform_all_later(3.times.map { TableSimulatorJob.new(wedding.id) })
|
||||
|
||||
'red'.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) }
|
||||
"red".dup.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) }
|
||||
|
||||
Group.roots.each(&:colorize_children)
|
||||
|
||||
@ -80,6 +96,6 @@ ActsAsTenant.with_tenant(wedding) do
|
||||
email: 'development@example.com',
|
||||
confirmed_at: Time.zone.now,
|
||||
password: 'supersecretpassword',
|
||||
password_confirmation: 'supersecretpassword',
|
||||
password_confirmation: 'supersecretpassword'
|
||||
)
|
||||
end
|
||||
|
9
spec/factories/invitations.rb
Normal file
9
spec/factories/invitations.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :invitation do
|
||||
wedding
|
||||
end
|
||||
end
|
9
spec/models/invitation_spec.rb
Normal file
9
spec/models/invitation_spec.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Invitation do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user