From 18ee10eef572b37b285e41a03d38674e2fc9d322 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 13 Jul 2020 00:48:45 -0700 Subject: [PATCH 1/4] tweak payment text --- app/models/payment.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/payment.rb b/app/models/payment.rb index e313f8dd..870e82cc 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -22,10 +22,15 @@ class Payment < ApplicationRecord Ticket.total_price(conference, user, paid: false).cents end + def stripe_description + #"ticket purchases(#{user.username})" + "Tickets for #{conference.title} #{user.name} #{user.email}" + end + def purchase gateway_response = Stripe::Charge.create source: stripe_customer_token, receipt_email: stripe_customer_email, - description: "ticket purchases(#{user.username})", + description: stripe_description, amount: amount_to_pay, currency: conference.tickets.first.price_currency From cd88882714216b3131cdf163aeabe2c967a1277b Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 13 Jul 2020 02:58:15 -0700 Subject: [PATCH 2/4] upgrade datatables gem --- Gemfile | 3 ++- Gemfile.lock | 8 ++------ app/assets/javascripts/application.js | 8 +++++++- app/assets/javascripts/osem-datatables.js | 2 ++ app/assets/stylesheets/application.css | 8 +++++++- app/controllers/admin/reports_controller.rb | 3 ++- app/views/admin/users/index.html.haml | 1 + 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 3d897cef..b2d02c2d 100644 --- a/Gemfile +++ b/Gemfile @@ -116,8 +116,9 @@ end gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47' # data tables +gem 'jquery-datatables' gem 'ajax-datatables-rails' -gem 'jquery-datatables-rails' +# gem 'jquery-datatables-rails' # for charts gem 'chartkick' diff --git a/Gemfile.lock b/Gemfile.lock index 0a549452..8fda9704 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -238,11 +238,7 @@ GEM io-like (0.3.0) iso-639 (0.2.8) jaro_winkler (1.5.3) - jquery-datatables-rails (3.4.0) - actionpack (>= 3.1) - jquery-rails - railties (>= 3.1) - sass-rails + jquery-datatables (1.10.20) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -650,7 +646,7 @@ DEPENDENCIES haml-rails haml_lint iso-639 - jquery-datatables-rails + jquery-datatables jquery-rails jquery-ui-rails (~> 4.2.1) json-schema diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index da958dc3..d57d7852 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,8 +16,14 @@ //= require jquery.ui.draggable //= require jquery.ui.droppable //= require waypoints/jquery.waypoints + //= require dataTables/jquery.dataTables -//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap +//= require dataTables/dataTables.bootstrap +//= require datatables/extensions/Buttons/dataTables.buttons +//= require datatables/extensions/Buttons/buttons.bootstrap +// = require datatables/extensions/Buttons/buttons.html5 +// = require datatables/extensions/Buttons/buttons.dataTables + //= require cocoon //= require bootstrap //= require Chart.bundle diff --git a/app/assets/javascripts/osem-datatables.js b/app/assets/javascripts/osem-datatables.js index f9bdb008..57a97754 100644 --- a/app/assets/javascripts/osem-datatables.js +++ b/app/assets/javascripts/osem-datatables.js @@ -1,5 +1,7 @@ $(function () { $.extend(true, $.fn.dataTable.defaults, { + "buttons": ["csv"], + "dom": "lBfrtip", "stateSave": true, "autoWidth": false, "pagingType": "full_numbers", diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 0b80bc19..d6b84f1d 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,7 +1,13 @@ /* + *= require dataTables/dataTables.bootstrap + *= require datatables/extensions/Responsive/responsive.dataTables + *= require dataTables/extensions/Responsive/responsive.bootstrap + *= require dataTables/extensions/Select/select.bootstrap + *= require dataTables/extensions/Buttons/buttons.dataTables + *= require dataTables/extensions/Buttons/buttons.bootstrap *= require strap-on *= require formtastic-bootstrap - *= require dataTables/bootstrap/3/jquery.dataTables.bootstrap + *= require selectize *= require selectize.bootstrap3 *= require bootstrap-select diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index 28f4f94f..5d9eabf4 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -8,7 +8,8 @@ module Admin # load_and_authorize_resource :event, through: :program def index - @events = Event.accessible_by(current_ability).where(program: @program) + @events = Event.accessible_by(current_ability).where(program: @program, + state: [:confirmed, :unconfirmed]) @events_commercials = Commercial.where(commercialable_type: 'Event', commercialable_id: @events.pluck(:id)) @events_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id)) @events_with_requirements = @events.where.not(description: ['', nil]) diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index e2b47504..91a751e5 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -24,6 +24,7 @@ :javascript $(function () { $('#users.datatable').DataTable({ + "buttons": { buttons: ["csv"] }, "processing": true, "serverSide": true, "ajax": $('#users.datatable').data('source'), From 0dffc20ad1c9d25c599cbab42a3236bd18d5effd Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 13 Jul 2020 03:27:44 -0700 Subject: [PATCH 3/4] Add rake tasks to help manage registrations --- lib/tasks/registrations.rake | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lib/tasks/registrations.rake diff --git a/lib/tasks/registrations.rake b/lib/tasks/registrations.rake new file mode 100644 index 00000000..39cb33c4 --- /dev/null +++ b/lib/tasks/registrations.rake @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +namespace :registrations do + desc "Create missing registrations for those how have a registration ticket." + task :create_missing, [:conference] => :environment do |t, args| + + fail 'Please supply a conference short name.' unless args.conference + + conf = Conference.find_by(short_title: args.conference) + # Check if a user is found based on the supplied email address + fail "Coud not find conference #{args.conference}" unless conf + + purchases = conf.ticket_purchases.where(ticket: conf.registration_tickets, paid: true) + unregistered = purchases.select { |tp| !conf.user_registered?(tp.user) } + puts "Found #{unregistered.count} unregistered users for #{purchases.count} ticket purchases." + puts "There are currently #{conf.participants.count} registered users." + + unregistered.each do |tp| + puts "Creating registration for #{tp.user.email}" + Registration.create(user: tp.user, conference: conf) + end + puts "Done." + end + + desc "Show User emails who have not paid, but did register" + task :list_unpaid, [:conference] => :environment do |t, args| + + fail 'Please supply a conference short name.' unless args.conference + + conf = Conference.find_by(short_title: args.conference) + # Check if a user is found based on the supplied email address + fail "Coud not find conference #{args.conference}" unless conf + + registered = conf.participants + unpaid = registered.select do |user| + TicketPurchase.where(conference: conf, paid: true, user: user).empty? + end + puts "Found #{registered.count} registered users and #{unpaid.count} unpaid attendees." + puts + + unpaid.each do |user| + puts "'#{user.name}',#{user.email}" + end + puts "" + end +end From 61ca626df14627b3818448e4771f99c25f2ae001 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 13 Jul 2020 04:21:31 -0700 Subject: [PATCH 4/4] Improve the physical_tickets page --- app/controllers/physical_tickets_controller.rb | 1 + app/views/physical_tickets/index.html.haml | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/physical_tickets_controller.rb b/app/controllers/physical_tickets_controller.rb index b4404aa7..96fffb09 100644 --- a/app/controllers/physical_tickets_controller.rb +++ b/app/controllers/physical_tickets_controller.rb @@ -8,6 +8,7 @@ class PhysicalTicketsController < ApplicationController def index @physical_tickets = current_user.physical_tickets.by_conference(@conference) + @has_registration_ticket = current_user.ticket_purchases.where(ticket: @conference.registration_tickets, paid: true).any? @unpaid_ticket_purchases = current_user.ticket_purchases.by_conference(@conference).unpaid @user = current_user end diff --git a/app/views/physical_tickets/index.html.haml b/app/views/physical_tickets/index.html.haml index cc7dbae2..f05215d7 100644 --- a/app/views/physical_tickets/index.html.haml +++ b/app/views/physical_tickets/index.html.haml @@ -9,14 +9,17 @@ .text-muted Your tickets for the conference - - if !@conference.user_registered?(@user) - .row - .col-md-12 + -# TODO: And if they have a registration ticket? + - if !@conference.user_registered?(@user) && @has_registration_ticket + .col-md-12 + .alert.alert-success{role: 'alert'} + = link_to 'Complete Registration', + new_conference_conference_registration_path(@conference), + class: 'btn btn-info pull-right btn-lg' + %h3 + 🎉 Thanks for getting a #{@conference.title} ticket! One last step... %strong You are not yet registered for the conference. - = link_to 'Complete Registration', - conference_conference_registration_path(@conference), - class: 'btn btn-success pull-right' .col-md-12 - if @physical_tickets.present?