Skip to content

Commit

Permalink
Cleanup event scheudle dates/times presentations
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed Jul 31, 2024
1 parent 57c1da5 commit 5755135
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
3 changes: 2 additions & 1 deletion app/controllers/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def create
notice: 'Thanks! Your ticket is booked successfully.'
end
else
@total_amount_to_pay = convert_currency(@conference, Ticket.total_price(@conference, current_user, paid: false), from_currency, selected_currency)
# TODO-SNAPCON: This case is not tested at all
@total_amount_to_pay = CurrencyConversion.convert_currency(@conference, Ticket.total_price(@conference, current_user, paid: false), from_currency, selected_currency)
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
flash.now[:error] = @payment.errors.full_messages.to_sentence + ' Please try again with correct credentials.'
render :new
Expand Down
1 change: 0 additions & 1 deletion app/models/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# id :bigint not null, primary key
# amount :integer
# authorization_code :string
# currency :string
# last4 :string
# status :integer default("unpaid"), not null
# created_at :datetime not null
Expand Down
2 changes: 2 additions & 0 deletions app/views/schedules/_date_event_types.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
The conference timezone is #{timezone_mapping(conference.timezone)}.
- if current_user
Visit your #{link_to('user profile page', edit_user_path(current_user.id))} to set your timezone.
- else
(#{link_to('Log in', new_user_session_path)} to view the schedule in your preferred timezone.)
- if current_user
%p.text-center
Click the star next to each event to add or remove it from
Expand Down
2 changes: 1 addition & 1 deletion app/views/schedules/_event.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

%h3.event-panel-title
= link_to conference_program_proposal_path(@conference.short_title, event.id),
style: color_style do
style: "#{color_style}; line-height: 1.7" do
= event.title
- if event.subtitle.present?
%br
Expand Down
47 changes: 21 additions & 26 deletions app/views/schedules/events.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,33 @@
.row
/ scheduled events
:ruby
date = nil
time = nil
tz_object = current_user&.timezone ? current_user : @conference
prev_date, prev_time = nil
display_tz = current_user&.timezone.presence || @conference.timezone

/ TODO-SNAPCON: Explore caching this.
- @events_schedules.each do |event_schedule|
- next if event_schedule.event.parent_event.present?
- new_start_time = convert_timezone(event_schedule.start_time, @conference.timezone, tz_object.timezone)
- start_ymd = new_start_time.strftime('%Y-%m-%d')
- unless start_ymd.eql?(date)
.col-xs-12.col-md-12
.date-content
%span.date-title
= inyourtz(event_schedule.start_time, @conference.timezone) do
= date = start_ymd
%a.pull-right{ title: "Go up", href: "#program" }
%i.fa-solid.fa-angles-up.fa-lg{ 'aria-hidden': true }
.col-xs-12.col-md-1
- if !event_schedule.start_time.strftime('%H:%M').eql?(time) || !start_ymd.eql?(date)
- time = new_start_time.strftime('%H:%M')
= inyourtz(event_schedule.start_time, @conference.timezone) do
= time + ' ' + timezone_text(tz_object)
.col-xs-12.col-md-11
- cache [@program, event_schedule, event_schedule.event, current_user, event_schedule.happening_now?, '#scheduled#full#panel'] do
.event-item{ data: { time: event_schedule.start_time.iso8601 }, class: "event-#{event_schedule.event.id}" }
= render 'event', event: event_schedule.event, event_schedule: event_schedule
- @events_schedules.select { |es| es.event.parent_event.nil? }.each do |event_schedule|
- event = event_schedule.event
- start_time = convert_timezone(event_schedule.start_time, @conference.timezone, display_tz)

- unless start_time.to_date.eql?(prev_date)
.date-content
%h2.date-title{ style: "margin: 0;" }
= prev_date = start_time.to_date
%a.pull-right{ title: "Go up", href: "#program" }
%i.fa-solid.fa-angles-up.fa-lg{ 'aria-hidden': true }
- if !start_time.eql?(prev_time)
- prev_time = start_time
%h3= start_time.strftime('%H:%M %p %Z')
.col-12
- cache [@program, event_schedule, event, current_user, event_schedule.happening_now?, '#scheduled#full#panel'] do
.event-item{ data: { time: event_schedule.start_time.iso8601 }, id: dom_id(event) }
= render 'event', event: event, event_schedule: event_schedule

/ confirmed events that are not scheduled
- if @unscheduled_events.any?
.col-xs-12.col-md-12
.col-12
.date-content
%span.date-title#unscheduled
%h2.date-title#unscheduled{ style: "margin: 0;" }
Unscheduled events
%a.pull-right{ title: "Go up", href: "#program" }
%i.fa-solid.fa-angles-up.fa-lg{ 'aria-hidden': true }
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion spec/models/payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# id :bigint not null, primary key
# amount :integer
# authorization_code :string
# currency :string
# last4 :string
# status :integer default("unpaid"), not null
# created_at :datetime not null
Expand Down

0 comments on commit 5755135

Please sign in to comment.