Include confirmation status #39

Merged
bustikiller merged 1 commits from feature/confirmation-status into main 2024-08-11 17:27:14 +00:00
5 changed files with 22 additions and 3 deletions
Showing only changes of commit cb42b86136 - Show all commits

View File

@ -1,6 +1,14 @@
class Guest < ApplicationRecord class Guest < ApplicationRecord
acts_as_taggable_on :affinity_groups, :unbreakable_bonds acts_as_taggable_on :affinity_groups, :unbreakable_bonds
belongs_to :group belongs_to :group
enum status: {
considered: 0,
invited: 10,
confirmed: 20,
declined: 30
}
def full_name def full_name
"#{first_name} #{last_name}" "#{first_name} #{last_name}"
end end

View File

@ -1,7 +1,7 @@
class SerializableGuest < JSONAPI::Serializable::Resource class SerializableGuest < JSONAPI::Serializable::Resource
type 'guest' type 'guest'
attributes :id, :email, :group_id attributes :id, :email, :group_id, :status
attribute :name do attribute :name do
"#{@object.first_name} #{@object.last_name}" "#{@object.first_name} #{@object.last_name}"
@ -10,4 +10,8 @@ class SerializableGuest < JSONAPI::Serializable::Resource
attribute :group_name do attribute :group_name do
@object.group.name @object.group.name
end end
attribute :status do
@object.status.capitalize
end
end end

View File

@ -0,0 +1,5 @@
class AddStatusToGuest < ActiveRecord::Migration[7.1]
def change
add_column :guests, :status, :integer, default: 0
end
end

3
db/schema.rb generated
View File

@ -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[7.1].define(version: 2024_08_11_154115) do ActiveRecord::Schema[7.1].define(version: 2024_08_11_170021) 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 "plpgsql" enable_extension "plpgsql"
@ -45,6 +45,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_11_154115) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.uuid "group_id", null: false t.uuid "group_id", null: false
t.integer "status", default: 0
t.index ["group_id"], name: "index_guests_on_group_id" t.index ["group_id"], name: "index_guests_on_group_id"
end end

View File

@ -60,6 +60,7 @@ NUMBER_OF_GUESTS.times do
last_name: Faker::Name.last_name, last_name: Faker::Name.last_name,
email: Faker::Internet.email, email: Faker::Internet.email,
phone: Faker::PhoneNumber.cell_phone, phone: Faker::PhoneNumber.cell_phone,
group: groups.sample group: groups.sample,
status: Guest.statuses.keys.sample
) )
end end