diff --git a/app/assets/javascripts/osem-schedule.js b/app/assets/javascripts/osem-schedule.js index 5e4822bf9..b38ae2cc8 100644 --- a/app/assets/javascripts/osem-schedule.js +++ b/app/assets/javascripts/osem-schedule.js @@ -82,30 +82,27 @@ $(document).ready( function() { $('#current-event-btn').on('click', function() { var now = new Date(); - var closestEventId = null; + var closestEvent = null; var smallestDiff = Infinity; - var i = 0; $('.event-item').each(function() { + let $event = $(this), eventTimeStr = $event.data('time'); - var eventTimeStr = $(this).data('time'); + if (!eventTimeStr) { return; } - if (eventTimeStr) { - var eventTime = new Date(eventTimeStr); - var diff = Math.abs(eventTime - now); - - if (diff < smallestDiff) { - smallestDiff = diff; - closestEventId = $(this).attr('class').split(' ')[1]; - } - } + var eventTime = new Date(eventTimeStr); + var diff = Math.abs(eventTime - now); + if (diff < smallestDiff) { + smallestDiff = diff; + closestEvent = $event; + } }); - if (closestEventId) { - //Instead of relying on hash it's probably better to scroll using javascript - //Since the users and click button->scroll->click again, which won't re-scroll + if (closestEvent) { + // Instead of relying on hash it's probably better to scroll using javascript + // Since the users and click button->scroll->click again, which won't re-scroll $('.highlighted').removeClass('highlighted'); - $('.' + closestEventId).addClass('highlighted').get(0).scrollIntoView({ behavior: 'smooth', block: 'start' }); + $(closestEvent).addClass('highlighted').get(0).scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index ca0217bca..17a4b94b2 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -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 diff --git a/app/views/schedules/_date_event_types.haml b/app/views/schedules/_date_event_types.haml index 2ba3cd4d2..c129e782e 100644 --- a/app/views/schedules/_date_event_types.haml +++ b/app/views/schedules/_date_event_types.haml @@ -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 diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index 122d3e1e1..e3438bde0 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -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 diff --git a/app/views/schedules/_event_mini.html.haml b/app/views/schedules/_event_mini.html.haml index b0e29509c..27acb4a77 100644 --- a/app/views/schedules/_event_mini.html.haml +++ b/app/views/schedules/_event_mini.html.haml @@ -25,8 +25,8 @@ %span= " at #{new_start_time.strftime('%l:%M %P')}" = join_event_link(event, event_schedule, current_user, small: true) %p - = truncate(markdown(event.abstract), length: 250, escape: false) - - if event.subevents.present? + = markdown(truncate(event.abstract, length: 256)) + - if event.program_subevents.present? %ul - event.program_subevents.each do |subevent| %li= link_to(subevent.title, conference_program_proposal_path(@conference.short_title, subevent.id)) diff --git a/app/views/schedules/events.html.haml b/app/views/schedules/events.html.haml index 14a1669ca..a8079c9f2 100644 --- a/app/views/schedules/events.html.haml +++ b/app/views/schedules/events.html.haml @@ -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 } diff --git a/db/migrate/20230418211420_create_currency_conversions.rb b/db/migrate/20230418211420_create_currency_conversions.rb index 9c5100085..3403e779c 100644 --- a/db/migrate/20230418211420_create_currency_conversions.rb +++ b/db/migrate/20230418211420_create_currency_conversions.rb @@ -1,6 +1,6 @@ class CreateCurrencyConversions < ActiveRecord::Migration[7.0] def change - create_table :currency_conversions do |t| + create_table :currency_conversions, if_not_exists: true do |t| t.decimal :rate t.string :from_currency t.string :to_currency diff --git a/db/schema.rb b/db/schema.rb index d40bd6b55..8b20ff52d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_07_22_183008) do +ActiveRecord::Schema[7.0].define(version: 2024_04_22_200831) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -545,8 +545,8 @@ t.integer "payment_id" t.integer "week" t.float "amount_paid", default: 0.0 - t.integer "amount_paid_cents", default: 0 t.string "currency" + t.integer "amount_paid_cents", default: 0 end create_table "ticket_scannings", force: :cascade do |t| diff --git a/features/conferences/all_events.feature b/features/conferences/all_events.feature index 4df1fe39b..409c91da1 100644 --- a/features/conferences/all_events.feature +++ b/features/conferences/all_events.feature @@ -9,7 +9,7 @@ Scenario: Display events using the conference's timezone And I should see "All events are currently displayed in PDT (UTC -7)." And I should see the following data: 8:00 am - 8:30 am PDT, 8:30 am - 9:00 am PDT And I should see the following data in order: Dates, 2014-05-03, 2014-05-04, 2014-05-05, 2014-05-06, 2014-05-07, Unscheduled - And I should see the following data in order: 2014-05-03, 08:00 PDT, first_scheduled_event, 8:00 am, first_scheduled_subevent, 08:30 PDT, multiple_speaker_event + And I should see the following data in order: 2014-05-03, 08:00 AM PDT, first_scheduled_event, 8:00 am, first_scheduled_subevent, 08:30 AM PDT, multiple_speaker_event Scenario: Display events using the user's timezone Given I sign in with username "admin" and password "password123" @@ -18,4 +18,4 @@ Scenario: Display events using the user's timezone And I should see "All events are currently displayed in AEST (UTC 10)." And I should see the following data: 1:00 am - 1:30 am AEST, 1:30 am - 2:00 am AEST And I should see the following data in order: Dates, 2014-05-04, 2014-05-05, 2014-05-06, 2014-05-07, 2014-05-08, Unscheduled - And I should see the following data in order: 2014-05-04, 01:00 AEST, first_scheduled_event, 1:00 am, first_scheduled_subevent, 01:30 AEST, multiple_speaker_event + And I should see the following data in order: 2014-05-04, 01:00 AM AEST, first_scheduled_event, 1:00 am, first_scheduled_subevent, 01:30 AM AEST, multiple_speaker_event diff --git a/package-lock.json b/package-lock.json index fedc26385..e5e7a779a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "snapcon2", + "name": "snapcon", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/spec/factories/payments.rb b/spec/factories/payments.rb index caea70729..a3df512e9 100644 --- a/spec/factories/payments.rb +++ b/spec/factories/payments.rb @@ -7,6 +7,7 @@ # 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 diff --git a/spec/features/event_schedules_spec.rb b/spec/features/event_schedules_spec.rb index cc01677a5..bbb3eaf20 100644 --- a/spec/features/event_schedules_spec.rb +++ b/spec/features/event_schedules_spec.rb @@ -41,6 +41,6 @@ it 'jumps to the closest event' do find('#current-event-btn').click highlighted_element = page.find('.highlighted', visible: true, wait: 1) - expect(highlighted_element[:class]).to include("event-#{scheduled_event_mid.id}") + expect(highlighted_element[:id]).to include("event_#{scheduled_event_mid.id}") end end