From 812645403c01e3b5694a26a45f82634440c22069 Mon Sep 17 00:00:00 2001 From: Matt Levy Date: Sun, 28 Jul 2024 14:45:03 -0700 Subject: [PATCH] eald, cabins removal cleanup --- app/helpers/ticket_requests_helper.rb | 17 ----- app/mailers/ticket_request_mailer.rb | 22 +++---- app/models/event.rb | 9 --- .../payment_mailer/payment_received.html.haml | 14 ---- app/views/payments/show.html.haml | 15 ----- app/views/shared/_nav_event.html.haml | 38 ----------- .../request_approved.html.haml | 8 --- .../_table_ticket_requests.html.haml | 22 +++---- config/routes.rb | 20 ------ db/structure.sql | 65 +------------------ spec/models/event_spec.rb | 5 -- spec/models/ticket_request_spec.rb | 22 ------- 12 files changed, 23 insertions(+), 234 deletions(-) diff --git a/app/helpers/ticket_requests_helper.rb b/app/helpers/ticket_requests_helper.rb index 05caa977..1cf53ac5 100644 --- a/app/helpers/ticket_requests_helper.rb +++ b/app/helpers/ticket_requests_helper.rb @@ -40,23 +40,6 @@ def text_for_status(ticket_request) end end - def eald_requested?(ticket_request) - ticket_request.early_arrival_passes.positive? || - ticket_request.late_departure_passes.positive? - end - - # Not perfect, but looks up the email address associated with the request and - # checks if enough EA/LD passes have been purchased with that email address to - # meet or exceed the originally requested amount in the request. - def eald_paid?(ticket_request) - eald_payments = EaldPayment.where(event: ticket_request.event, - email: ticket_request.user.email).to_a - ea_passes = eald_payments.sum(&:early_arrival_passes) - ld_passes = eald_payments.sum(&:late_departure_passes) - ea_passes >= ticket_request.early_arrival_passes && - ld_passes >= ticket_request.late_departure_passes - end - def price_rules_to_json(event) event.price_rules.to_h do |price_rule| [price_rule.trigger_value, price_rule.price.to_i] diff --git a/app/mailers/ticket_request_mailer.rb b/app/mailers/ticket_request_mailer.rb index e7546724..193fd914 100644 --- a/app/mailers/ticket_request_mailer.rb +++ b/app/mailers/ticket_request_mailer.rb @@ -41,17 +41,17 @@ def request_approved(ticket_request) @payment_url = new_event_ticket_request_payment_url(@event, @ticket_request, @auth_token) - # XXX Clean me up and make Event Addons / Ticket Request - if @event.eald? - @extra_params = {}.tap do |params| - params[:early_arrival_passes] = @ticket_request.early_arrival_passes - params[:late_departure_passes] = @ticket_request.late_departure_passes - params[:email] = @ticket_request.user.email - params[:name] = @ticket_request.user.name - end - - @eald_url = new_event_eald_payment_path(@event, @extra_params) - end + # XXX Clean me up and make Event Addons / Ticket Request + # if @event.eald? + # @extra_params = {}.tap do |params| + # params[:early_arrival_passes] = @ticket_request.early_arrival_passes + # params[:late_departure_passes] = @ticket_request.late_departure_passes + # params[:email] = @ticket_request.user.email + # params[:name] = @ticket_request.user.name + # end + # + # @eald_url = new_event_eald_payment_path(@event, @extra_params) + # end # Return if the authentication token is blank return if @auth_token.blank? diff --git a/app/models/event.rb b/app/models/event.rb index 1f1deade..95ed079f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -8,14 +8,9 @@ # adult_ticket_price :decimal(8, 2) # allow_donations :boolean default(FALSE), not null # allow_financial_assistance :boolean default(FALSE), not null -# cabin_price :decimal(8, 2) -# early_arrival_price :decimal(8, 2) default(0.0) # end_time :datetime # kid_ticket_price :decimal(8, 2) -# late_departure_price :decimal(8, 2) default(0.0) # max_adult_tickets_per_request :integer -# max_cabin_requests :integer -# max_cabins_per_request :integer # max_kid_tickets_per_request :integer # name :string # photo :string @@ -180,10 +175,6 @@ def ticket_requests_open? false end - def eald? - early_arrival_price.positive? || late_departure_price.positive? - end - def to_param return nil unless persisted? diff --git a/app/views/payment_mailer/payment_received.html.haml b/app/views/payment_mailer/payment_received.html.haml index 3b7ddc10..c161aeb5 100644 --- a/app/views/payment_mailer/payment_received.html.haml +++ b/app/views/payment_mailer/payment_received.html.haml @@ -1,19 +1,5 @@ = render partial: "payments/payment", locals: { payment: @payment } -- if @event.eald? - %p - %b Planning to arrive early or leave late? - %br - :ruby - extra_params = {} - extra_params[:early_arrival_passes] = @ticket_request.early_arrival_passes - extra_params[:late_departure_passes] = @ticket_request.late_departure_passes - extra_params[:email] = @ticket_request.user.email - extra_params[:name] = @ticket_request.user.name - = link_to 'Early Arrival / Late Departure Passes', - new_event_eald_payment_url(@event, extra_params) - must be purchased separately! - %p Got ticket questions or think something is wrong with your order? We are still here for you, drop us a line at diff --git a/app/views/payments/show.html.haml b/app/views/payments/show.html.haml index a0d33af1..7c5e249d 100644 --- a/app/views/payments/show.html.haml +++ b/app/views/payments/show.html.haml @@ -1,20 +1,5 @@ = render partial: "payment", locals: { payment: @payment } -- if @event.eald? - %p - %b Planning to arrive early or leave late? - %br - :ruby - extra_params = {} - extra_params[:early_arrival_passes] = @ticket_request.early_arrival_passes - extra_params[:late_departure_passes] = @ticket_request.late_departure_passes - extra_params[:email] = @ticket_request.user.email - extra_params[:name] = @ticket_request.user.name - = link_to 'Early Arrival / Late Departure Passes', - new_event_eald_payment_path(@event, extra_params), - target: '_blank' - must be purchased separately! - %p You can = link_to 'review your ticket information', diff --git a/app/views/shared/_nav_event.html.haml b/app/views/shared/_nav_event.html.haml index 909483a9..c18097dc 100644 --- a/app/views/shared/_nav_event.html.haml +++ b/app/views/shared/_nav_event.html.haml @@ -1,39 +1 @@ --# - active_tab ||= {} --# --# -# TODO: when we allow uploading images for the events, we can show it. --# -# = image_tag image_path('logos/fnf-transparent.png'), class: 'float-end event-preview' --# .card.event-nav --# .card-header.bg-dark-subtle --# .card-img-top --# %h3.d-inline-block.align-baseline --# = event.name --# %h5.d-inline-block.px-xl-5.px-lg-3.p-md-0.p-sm-0.m-0 --# = event.starting --# --# .card-body.event-nav --# .btn-group --# - if current_user.site_admin? || current_user.manages_event?(event) --# = link_to event_path(event), class: "btn #{active_tab[:event_show]}" do --# - if active_tab[:event_show] != "active" --# %i.icon-arrow-left ← --# = event.name --# - else --# = event.name --# = link_to edit_event_path(event), class: "btn #{active_tab[:event_edit]}" do --# Edit Event --# %i.icon-edit --# --# --# = link_to event_ticket_requests_path(event), class: "btn #{active_tab[:ticket_requests]}" do --# Ticket Requests --# %i.icon-inbox --# = link_to event_eald_payments_path(event), class: "btn #{active_tab[:eald_passes]}" do --# EA/LD Passes --# %i.icon-inbox --# = link_to guest_list_event_path(event), class: "btn #{active_tab[:guest_list]}" do --# Guest List --# %i.icon-th-list --# --# .vertical-20 - = render partial: 'shared/nav_event_tabs', locals: { active_tab: active_tab, event: event } diff --git a/app/views/ticket_request_mailer/request_approved.html.haml b/app/views/ticket_request_mailer/request_approved.html.haml index d4882e4e..3f8c64bc 100644 --- a/app/views/ticket_request_mailer/request_approved.html.haml +++ b/app/views/ticket_request_mailer/request_approved.html.haml @@ -15,14 +15,6 @@ purchase your = 'ticket'.pluralize(@ticket_request.total_tickets) --# XXX will re-enable once EALD has been added back --# - if @event.eald? --# %p --# %b Planning to arrive early or leave late? --# %br --# = link_to 'Early Arrival / Late Departure Passes', @eald_url --# must be purchased separately! - %p Thanks, %br diff --git a/app/views/ticket_requests/_table_ticket_requests.html.haml b/app/views/ticket_requests/_table_ticket_requests.html.haml index 508c675c..09e75790 100644 --- a/app/views/ticket_requests/_table_ticket_requests.html.haml +++ b/app/views/ticket_requests/_table_ticket_requests.html.haml @@ -56,17 +56,17 @@ - if event.active_event_addons? %td.align-content-center.text-end.optional-medium= ticket_request.active_ticket_request_event_addons_count - - if event.eald? - %td.align-content-center.text-end.optional-medium - #{ticket_request.early_arrival_passes} / #{ticket_request.late_departure_passes} - -# %br - -# - if eald_requested?(ticket_request) - -# - if eald_paid?(ticket_request) - -# ✔︎ EALD Paid - -# - else - -# ✘ Not All EALD Bought - -# - else - -# ✘ Not Requested + -# - if event.eald? + -# %td.align-content-center.text-end.optional-medium + -# #{ticket_request.early_arrival_passes} / #{ticket_request.late_departure_passes} + -# -# %br + -# -# - if eald_requested?(ticket_request) + -# -# - if eald_paid?(ticket_request) + -# -# ✔︎ EALD Paid + -# -# - else + -# -# ✘ Not All EALD Bought + -# -# - else + -# -# ✘ Not Requested %td.align-content-center.text-end %span{ class: ('label label-info' if ticket_request.special_price) } = number_to_currency(ticket_request.price, precision: 0) diff --git a/config/routes.rb b/config/routes.rb index 25e91640..cbf1e0be 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,19 +14,6 @@ devise_for :users - # WTF was this for? --@kig - # - # event_id = 9 - # - # get('fnf-tickets', controller: :ticket_requests, action: :new, event_id:) - # get('fnf_tickets', controller: :ticket_requests, action: :new, event_id:) - # get('fnftickets', controller: :ticket_requests, action: :new, event_id:) - # get('fnf', controller: :ticket_requests, action: :new, event_id:) - # get('FNF', controller: :ticket_requests, action: :new, event_id:) - # get('FnF', controller: :ticket_requests, action: :new, event_id:) - # - # get('eald', controller: :eald_payments, action: :new, event_id:) - resources :emails, only: :index resources :events do @@ -73,13 +60,6 @@ end end end - - resources :eald_payments, only: %i[index new create] do - collection do - get :complete - get :download - end - end end resources :passwords, only: [] do diff --git a/db/structure.sql b/db/structure.sql index 0f3b2c15..3807025a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -58,43 +58,6 @@ CREATE TABLE public.ar_internal_metadata ( ); --- --- Name: eald_payments; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.eald_payments ( - id bigint NOT NULL, - event_id bigint, - stripe_charge_id character varying NOT NULL, - amount_charged_cents integer NOT NULL, - name character varying(255) NOT NULL, - email character varying(255) NOT NULL, - early_arrival_passes integer DEFAULT 0 NOT NULL, - late_departure_passes integer DEFAULT 0 NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: eald_payments_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.eald_payments_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: eald_payments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.eald_payments_id_seq OWNED BY public.eald_payments.id; - - -- -- Name: event_addons; Type: TABLE; Schema: public; Owner: - -- @@ -173,11 +136,8 @@ CREATE TABLE public.events ( updated_at timestamp(6) without time zone NOT NULL, adult_ticket_price numeric(8,2), kid_ticket_price numeric(8,2), - cabin_price numeric(8,2), max_adult_tickets_per_request integer, max_kid_tickets_per_request integer, - max_cabins_per_request integer, - max_cabin_requests integer, photo character varying, tickets_require_approval boolean DEFAULT true NOT NULL, require_mailing_address boolean DEFAULT false NOT NULL, @@ -186,8 +146,6 @@ CREATE TABLE public.events ( ticket_sales_start_time timestamp without time zone, ticket_sales_end_time timestamp without time zone, ticket_requests_end_time timestamp without time zone, - early_arrival_price numeric(8,2) DEFAULT 0.0, - late_departure_price numeric(8,2) DEFAULT 0.0, slug text, require_role boolean DEFAULT true NOT NULL ); @@ -570,13 +528,6 @@ ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; ALTER TABLE ONLY public.addons ALTER COLUMN id SET DEFAULT nextval('public.addons_id_seq'::regclass); --- --- Name: eald_payments id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.eald_payments ALTER COLUMN id SET DEFAULT nextval('public.eald_payments_id_seq'::regclass); - - -- -- Name: event_addons id; Type: DEFAULT; Schema: public; Owner: - -- @@ -677,14 +628,6 @@ ALTER TABLE ONLY public.ar_internal_metadata ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); --- --- Name: eald_payments eald_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.eald_payments - ADD CONSTRAINT eald_payments_pkey PRIMARY KEY (id); - - -- -- Name: event_addons event_addons_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -789,13 +732,6 @@ ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); --- --- Name: index_eald_payments_on_event_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_eald_payments_on_event_id ON public.eald_payments USING btree (event_id); - - -- -- Name: index_event_addons_on_addon_id; Type: INDEX; Schema: public; Owner: - -- @@ -954,6 +890,7 @@ ALTER TABLE ONLY public.ticket_request_event_addons SET search_path TO "$user", public; INSERT INTO "schema_migrations" (version) VALUES +('20240728211432'), ('20240718224717'), ('20240710231611'), ('20240523173316'), diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index c1601c05..440b1054 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -139,11 +139,6 @@ it { is_expected.not_to accept_values_for(:kid_ticket_price, -1) } end - describe '#cabin_price' do - it { is_expected.to accept_values_for(:cabin_price, nil, '', 0, 50) } - it { is_expected.not_to accept_values_for(:cabin_price, -1) } - end - describe '#max_adult_tickets_per_request' do it { is_expected.to accept_values_for(:max_adult_tickets_per_request, nil, '', 50) } it { is_expected.not_to accept_values_for(:max_adult_tickets_per_request, 0, -1) } diff --git a/spec/models/ticket_request_spec.rb b/spec/models/ticket_request_spec.rb index 227027d5..e7ca2cb4 100644 --- a/spec/models/ticket_request_spec.rb +++ b/spec/models/ticket_request_spec.rb @@ -136,28 +136,6 @@ end end - describe '#cabins' do - let(:ticket_request) { build(:ticket_request, cabins:) } - - context 'when not present' do - let(:cabins) { nil } - - it { is_expected.to be_valid } - end - - context 'when not a number' do - let(:cabins) { 'not a number' } - - it { is_expected.not_to be_valid } - end - - context 'when a number' do - let(:cabins) { 2 } - - it { is_expected.to be_valid } - end - end - describe '#notes' do let(:ticket_request) { build(:ticket_request, notes:) }