diff --git a/Gemfile.lock b/Gemfile.lock index 03887e0ef..0550a4a21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,47 +11,47 @@ GEM remote: https://rubygems.org/ specs: Ascii85 (1.1.0) - actioncable (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) + actioncable (7.0.8.4) + actionpack (= 7.0.8.4) + activesupport (= 7.0.8.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionmailbox (7.0.8.4) + actionpack (= 7.0.8.4) + activejob (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.1) - actionpack (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionmailer (7.0.8.4) + actionpack (= 7.0.8.4) + actionview (= 7.0.8.4) + activejob (= 7.0.8.4) + activesupport (= 7.0.8.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8.1) - actionview (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionpack (7.0.8.4) + actionview (= 7.0.8.4) + activesupport (= 7.0.8.4) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.1) - actionpack (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + actiontext (7.0.8.4) + actionpack (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.1) - activesupport (= 7.0.8.1) + actionview (7.0.8.4) + activesupport (= 7.0.8.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -61,22 +61,22 @@ GEM activemodel (>= 4.1, < 7.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (7.0.8.1) - activesupport (= 7.0.8.1) + activejob (7.0.8.4) + activesupport (= 7.0.8.4) globalid (>= 0.3.6) - activemodel (7.0.8.1) - activesupport (= 7.0.8.1) - activerecord (7.0.8.1) - activemodel (= 7.0.8.1) - activesupport (= 7.0.8.1) - activestorage (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activesupport (= 7.0.8.1) + activemodel (7.0.8.4) + activesupport (= 7.0.8.4) + activerecord (7.0.8.4) + activemodel (= 7.0.8.4) + activesupport (= 7.0.8.4) + activestorage (7.0.8.4) + actionpack (= 7.0.8.4) + activejob (= 7.0.8.4) + activerecord (= 7.0.8.4) + activesupport (= 7.0.8.4) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8.1) + activesupport (7.0.8.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -112,7 +112,7 @@ GEM bootstrap-switch-rails (3.3.3) bootstrap3-datetimepicker-rails (4.17.47) momentjs-rails (>= 2.8.1) - builder (3.2.4) + builder (3.3.0) bullet (7.0.2) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) @@ -158,7 +158,7 @@ GEM rest-client (>= 2.0.0) cocoon (1.2.15) colorize (0.8.1) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) countable-rails (0.0.1) railties (>= 3.1) crack (0.4.5) @@ -235,7 +235,7 @@ GEM dotenv-rails (2.8.1) dotenv (= 2.8.1) railties (>= 3.2) - erubi (1.12.0) + erubi (1.13.0) execjs (2.8.1) factory_bot (6.2.1) activesupport (>= 5.0.0) @@ -290,7 +290,7 @@ GEM httparty (0.21.0) mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) i18n_data (0.17.1) simple_po_parser (~> 1.1) @@ -350,7 +350,7 @@ GEM rake mini_magick (4.12.0) mini_mime (1.1.5) - minitest (5.22.3) + minitest (5.24.1) momentjs-rails (2.29.4.1) railties (>= 3.1) monetize (1.12.0) @@ -378,11 +378,11 @@ GEM next_rails (1.2.4) colorize (>= 0.8.1) nio4r (2.7.0) - nokogiri (1.16.5-arm64-darwin) + nokogiri (1.16.6-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) + nokogiri (1.16.6-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -466,7 +466,7 @@ GEM public_suffix (5.0.4) puma (6.4.2) nio4r (~> 2.0) - racc (1.7.3) + racc (1.8.0) rack (2.2.9) rack-openid (1.4.2) rack (>= 1.1.0) @@ -475,20 +475,20 @@ GEM rack rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.1) - actioncable (= 7.0.8.1) - actionmailbox (= 7.0.8.1) - actionmailer (= 7.0.8.1) - actionpack (= 7.0.8.1) - actiontext (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activemodel (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + rails (7.0.8.4) + actioncable (= 7.0.8.4) + actionmailbox (= 7.0.8.4) + actionmailer (= 7.0.8.4) + actionpack (= 7.0.8.4) + actiontext (= 7.0.8.4) + actionview (= 7.0.8.4) + activejob (= 7.0.8.4) + activemodel (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) bundler (>= 1.15.0) - railties (= 7.0.8.1) + railties (= 7.0.8.4) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -503,9 +503,9 @@ GEM rails-i18n (7.0.7) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) + railties (7.0.8.4) + actionpack (= 7.0.8.4) + activesupport (= 7.0.8.4) method_source rake (>= 12.2) thor (~> 1.0) @@ -527,8 +527,8 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.7) - strscan (>= 3.0.9) + rexml (3.3.2) + strscan rolify (6.0.1) rqrcode (2.2.0) chunky_png (~> 1.0) diff --git a/app/assets/javascripts/osem-schedule.js b/app/assets/javascripts/osem-schedule.js index c233c877d..b38ae2cc8 100644 --- a/app/assets/javascripts/osem-schedule.js +++ b/app/assets/javascripts/osem-schedule.js @@ -15,10 +15,10 @@ var Schedule = { schedule_id = schedule_id_param; }, remove: function(element) { - var e = $("#" + element); - var event_schedule_id = e.attr("event_schedule_id"); - if(event_schedule_id != null){ - var my_url = url + '/' + event_schedule_id; + var e = $("#" + element); + var event_schedule_id = parseInt(e.attr("event_schedule_id")); + if(event_schedule_id > 0) { + var my_url = `${url}/${event_schedule_id}`; var success_callback = function(data) { e.attr("event_schedule_id", null); e.appendTo($(".unscheduled-events")); @@ -41,18 +41,18 @@ var Schedule = { }, add: function (previous_parent, new_parent, event) { event.appendTo(new_parent); - var event_schedule_id = event.attr("event_schedule_id"); + // Event Schedule Id could be an empty string. + var event_schedule_id = parseInt(event.attr("event_schedule_id")); var my_url = url; var type = 'POST'; var params = { event_schedule: { room_id: new_parent.attr("room_id"), start_time: (new_parent.attr("date") + ' ' + new_parent.attr("hour")) }}; - if(event_schedule_id != null){ + if (event_schedule_id > 0) { type = 'PUT'; - my_url += ('/' + event_schedule_id); - } - else{ + my_url += `/${event_schedule_id}`; + } else { params['event_schedule']['event_id'] = event.attr("event_id"); params['event_schedule']['schedule_id'] = schedule_id; } @@ -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) { - var eventTime = new Date(eventTimeStr); - var diff = Math.abs(eventTime - now); - - if (diff < smallestDiff) { - smallestDiff = diff; - closestEventId = $(this).attr('class').split(' ')[1]; - } - } + if (!eventTimeStr) { return; } + + 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/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index 093ea3914..0b7c8af3f 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -90,9 +90,7 @@ def aggregate_errors(errors) end def commercial_params - params.require(:commercial).permit(:title, :url).tap do |params| - params[:url] = Commercial.generate_snap_embed(params[:url]) if params[:url] - end + params.require(:commercial).permit(:title, :url) end end end diff --git a/app/controllers/admin/venue_commercials_controller.rb b/app/controllers/admin/venue_commercials_controller.rb index 11a87d199..753817fd0 100644 --- a/app/controllers/admin/venue_commercials_controller.rb +++ b/app/controllers/admin/venue_commercials_controller.rb @@ -38,7 +38,7 @@ def destroy end def render_commercial - result = Commercial.render_from_url(params[:url]) + result = Commercial.render_from_url(params[:url], params[:title]) if result[:error] render plain: result[:error], status: :bad_request else diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index e86f9ffb7..17a4b94b2 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -28,6 +28,9 @@ def new def create @payment = Payment.new payment_params + session[:selected_currency] = params[:currency] if params[:currency].present? + selected_currency = session[:selected_currency] || @conference.tickets.first.price_currency + from_currency = @conference.tickets.first.price_currency if @payment.purchase && @payment.save update_purchased_ticket_purchases @@ -47,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/models/commercial.rb b/app/models/commercial.rb index 5e1f8eb43..b01da1aff 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -28,48 +28,26 @@ class Commercial < ApplicationRecord validate :valid_url - def self.render_from_url(url) + def self.render_from_url(url, title = nil) register_provider - url = Commercial.generate_snap_embed(url) begin resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315) { html: resource.html.html_safe } rescue StandardError - { html: EmbeddableURL.new(url).render_embed.html_safe } + { html: EmbeddableURL.new(url, title).render_embed.html_safe } # { error: exception.message } end end - def self.generate_snap_embed(url) - return url unless url - - uri = URI.parse(url) - if uri.host == 'snap.berkeley.edu' && uri.path == '/project' - args = URI.decode_www_form(uri.query).to_h - else - return url - end - if args.key?('username') && args.key?('projectname') - new_query = URI.encode_www_form({ - 'projectname' => args['projectname'], - 'username' => args['username'], - 'showTitle' => 'true', - 'showAuthor' => 'true', - 'editButton' => 'true', - 'pauseButton' => 'true' - }) - new_uri = URI::HTTPS.build( - host: uri.host, - path: '/embed', - query: new_query - ) - return new_uri.to_s - end - url - end - - def self.iframe_fallback(url) - "".html_safe + # TODO: Is this necessary? + def self.iframe_fallback(url, title) + iframe = <<~HTML + + HTML + iframe.html_safe end def self.read_file(file) @@ -109,7 +87,7 @@ def self.read_file(file) def valid_url return unless url - result = Commercial.render_from_url(url) + result = Commercial.render_from_url(url, title) errors.add(:base, result[:error]) if result[:error] end diff --git a/app/services/embeddable_url.rb b/app/services/embeddable_url.rb index 6ca31369a..289a69208 100644 --- a/app/services/embeddable_url.rb +++ b/app/services/embeddable_url.rb @@ -1,7 +1,7 @@ # Transform a URL to a version that allows iframes class EmbeddableURL - attr_accessor :url + attr_accessor :url, :title DEFAULT_FRAME_ATTRS = 'width=560 height=315 frameborder=0 allowfullscreen'.freeze @@ -11,15 +11,19 @@ class EmbeddableURL /dropbox\.com/ => :dropbox }.freeze - def initialize(url) - self.url = url + def initialize(url, title) + # Do some normalizing so that URIs parse correctly. + if url + self.url = url.strip + end + self.title = title end def render_embed return render_dropbox if url.include?('dropbox.com') # TODO-A11Y: Set an iframe title - "" + "" end def iframe_url @@ -66,9 +70,30 @@ def dropbox(url) def snap(url) uri = URI.parse(url) - query = CGI.parse(uri.query) - username = query['username'][0] || query['user'][0] - project = query['projectname'][0] || query['project'][0] - "https://snap.berkeley.edu/embed?projectname=#{project}&username=#{username}&showTitle=true&showAuthor=true&editButton=true&pauseButton=true" + return url if uri.query.blank? + + args = URI.decode_www_form(uri.query).to_h + username = args['username'] || args['user'] + projectname = args['projectname'] || args['project'] + + return url if username.blank? || projectname.blank? + + query = URI.encode_www_form({ + 'projectname' => projectname, + 'username' => username, + 'showTitle' => 'true', + 'showAuthor' => 'true', + 'editButton' => 'true', + 'pauseButton' => 'true' + }) + URI::HTTPS.build(host: uri.host, path: '/embed', query: query).to_s + end + + def iframe_title + if title + "title='#{title} Embedded Media'" + else + 'title="Embedded Media for Presentation"' + end end end 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/app/views/shared/_media_item.html.haml b/app/views/shared/_media_item.html.haml index 367d04a2f..8e36eb4ad 100644 --- a/app/views/shared/_media_item.html.haml +++ b/app/views/shared/_media_item.html.haml @@ -15,7 +15,7 @@ - elsif commercial.commercial_type == 'YouTube' %iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://www.youtube.com/embed/#{commercial.commercial_id}?rel=0"} - elsif commercial.url - = Commercial.render_from_url(commercial.url)[:html] + = Commercial.render_from_url(commercial.url, commercial.title)[:html] - if commercial.url = link_to('Open in a new tab', commercial.url, target: '_blank', class: 'btn btn-info btn-xs') %br diff --git a/db/migrate/20230418211400_add_currency_to_payments.rb b/db/migrate/20230418211400_add_currency_to_payments.rb new file mode 100644 index 000000000..467a04f43 --- /dev/null +++ b/db/migrate/20230418211400_add_currency_to_payments.rb @@ -0,0 +1,5 @@ +class AddCurrencyToPayments < ActiveRecord::Migration[7.0] + def change + add_column :payments, :currency, :string + end +end diff --git a/db/migrate/20230418211410_add_currency_to_ticket_purchases.rb b/db/migrate/20230418211410_add_currency_to_ticket_purchases.rb new file mode 100644 index 000000000..70e4f9d96 --- /dev/null +++ b/db/migrate/20230418211410_add_currency_to_ticket_purchases.rb @@ -0,0 +1,5 @@ +class AddCurrencyToTicketPurchases < ActiveRecord::Migration[7.0] + def change + add_column :ticket_purchases, :currency, :string + end +end diff --git a/db/migrate/20230418211400_create_currency_conversions.rb b/db/migrate/20230418211420_create_currency_conversions.rb similarity index 79% rename from db/migrate/20230418211400_create_currency_conversions.rb rename to db/migrate/20230418211420_create_currency_conversions.rb index 9c5100085..3403e779c 100644 --- a/db/migrate/20230418211400_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 4807bc04c..b78dad252 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -329,9 +329,9 @@ t.integer "status", default: 0, null: false t.integer "user_id", null: false t.integer "conference_id", null: false - t.string "currency" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false + t.string "currency" end create_table "physical_tickets", 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/lib/tasks/migrate_currency.rake b/lib/tasks/migrate_currency.rake new file mode 100644 index 000000000..b05304131 --- /dev/null +++ b/lib/tasks/migrate_currency.rake @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +namespace :data do + namespace :migrate do + desc 'Update Currency of past ticket purchases' + task :update_ticket_purchase_currency do + TicketPurchase.where(currency: nil).update_all(currency: 'USD') + TicketPurchase.find_each do |purchase| + converted_amount = CurrencyConversion.convert_currency( + purchase.conference, + purchase.ticket.price_cents, + purchase.price_currency, + purchase.currency + ) + + purchase.update_column(:amount_paid_cents, converted_amount) + end + end + end +end 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/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 diff --git a/spec/models/commercial_spec.rb b/spec/models/commercial_spec.rb index 2adc17c97..a09077f8e 100644 --- a/spec/models/commercial_spec.rb +++ b/spec/models/commercial_spec.rb @@ -29,11 +29,4 @@ commercial = build(:conference_commercial) expect(commercial.valid?).to be true end - - it 'parses snap url' do - url = 'https://snap.berkeley.edu/project?username=avi_shor&projectname=stamps' - transformed_url = Commercial.generate_snap_embed(url) - expected_url = 'https://snap.berkeley.edu/embed?projectname=stamps&username=avi_shor&showTitle=true&showAuthor=true&editButton=true&pauseButton=true' - expect(transformed_url).to eq expected_url - end end diff --git a/spec/services/embeddable_url_spec.rb b/spec/services/embeddable_url_spec.rb index a8f506ec7..b88a94a37 100644 --- a/spec/services/embeddable_url_spec.rb +++ b/spec/services/embeddable_url_spec.rb @@ -6,24 +6,32 @@ describe '#iframe_url' do it 'returns the original url if no transformations apply' do url = 'https://example.com' - expect(EmbeddableURL.new(url).iframe_url).to eq url + expect(EmbeddableURL.new(url, 'title').iframe_url).to eq url end it 'transforms a Google Drive URL' do - url = EmbeddableURL.new('https://docs.google.com/presentation/d/1eGbEQtcOPW2N2P5rKfBVfSo2zn4C307Sh6C7vpJsruE/edit#slide=id.g1088c029399_0_47').iframe_url + url = EmbeddableURL.new('https://docs.google.com/presentation/d/1eGbEQtcOPW2N2P5rKfBVfSo2zn4C307Sh6C7vpJsruE/edit#slide=id.g1088c029399_0_47', 'title').iframe_url expect(url).to include '/embed' expect(url).not_to include('/edit') end it 'transforms a Dropbox URL' do - url = EmbeddableURL.new('https://www.dropbox.com/scl/fi/49gkp6ghfnxgqex64zvzd/Guzdial-SnapCon23.pdf?rlkey=ecwvmcmfscqtwfq21l3kzqcul&dl=1').iframe_url + url = EmbeddableURL.new('https://www.dropbox.com/scl/fi/49gkp6ghfnxgqex64zvzd/Guzdial-SnapCon23.pdf?rlkey=ecwvmcmfscqtwfq21l3kzqcul&dl=1', 'title').iframe_url expect(url).to include('dl=0') expect(url).not_to include('raw=') end it 'transforms a Snap! Project URL' do - url = EmbeddableURL.new('https://snap.berkeley.edu/project?username=jedi_force&projectname=Autograder%2dlite').iframe_url + url = EmbeddableURL.new('https://snap.berkeley.edu/project?username=jedi_force&projectname=Autograder%2dlite', 'title').iframe_url expect(url).to include('/embed') end end + + # it 'parses snap url' do + # url = 'https://snap.berkeley.edu/project?username=avi_shor&projectname=stamps' + # transformed_url = Commercial.generate_snap_embed(url) + # expected_url = 'https://snap.berkeley.edu/embed?projectname=stamps&username=avi_shor&showTitle=true&showAuthor=true&editButton=true&pauseButton=true' + # expect(transformed_url).to eq expected_url + # end + # TODO: Test ifram generation, snap-embedding end