From cf3aeda1d2435067b5ca217cab28ab90932947c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Fri, 24 Nov 2017 21:41:08 +0100 Subject: [PATCH 01/16] Fixing admin user creation in docker Added db:seed in order to have the deleted user, and be able to have an admin user. --- docker/init.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/init.sh b/docker/init.sh index 3a2031f3..23188d98 100644 --- a/docker/init.sh +++ b/docker/init.sh @@ -42,6 +42,9 @@ fi echo ">>> Upgrading database..." bundle exec rake db:migrate +echo ">>> Seed database..." +bundle exec rake db:seed + rm .my.cnf echo ">>> Precompiling assets..." From e40cdeb94bdff796a59f0f275c844aa798237546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Tue, 28 Nov 2017 17:27:42 +0100 Subject: [PATCH 02/16] Update init.sh --- docker/init.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/init.sh b/docker/init.sh index 23188d98..6a29044f 100644 --- a/docker/init.sh +++ b/docker/init.sh @@ -37,14 +37,14 @@ dockerize -wait tcp://$DATABASE_HOST:$DATABASE_PORT -timeout 60s true if [ $(echo "show tables;" | mysql --host $DATABASE_HOST --port $DATABASE_PORT $MYSQL_DATABASE | wc -l) -le 1 ]; then echo ">>> Initializing database..." bundle exec rake db:schema:load + + echo ">>> Seed database..." + bundle exec rake db:seed fi echo ">>> Upgrading database..." bundle exec rake db:migrate -echo ">>> Seed database..." -bundle exec rake db:seed - rm .my.cnf echo ">>> Precompiling assets..." From 92f27561dff1d6a00768f5a0d81de39438838d8d Mon Sep 17 00:00:00 2001 From: Adriano Vieira Date: Thu, 30 Nov 2017 15:55:36 -0200 Subject: [PATCH 03/16] Update current directory for centos box --- bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap.sh b/bootstrap.sh index 06a642dd..65303e37 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -54,6 +54,7 @@ elif [[ "$ID" == "centos" || "$VERSION" == "7" ]]; then tar jxvf /tmp/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /tmp/ phantomjs-2.1.1-linux-x86_64/bin/phantomjs mv /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin + pushd /vagrant fi echo -e "\ninstalling your bundle...\n" From fe8483b92e75a30baa947f157de5d27bc311716c Mon Sep 17 00:00:00 2001 From: Adriano Vieira Date: Thu, 30 Nov 2017 17:23:51 -0200 Subject: [PATCH 04/16] Fix user to run rake task for dbsetup --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 65303e37..f23739ed 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -65,7 +65,7 @@ if [ ! -f /vagrant/config/database.yml ] && [ -f /vagrant/config/database.yml.ex echo -e "\nSetting up your database from config/database.yml...\n" cp config/database.yml.example config/database.yml if [ ! -f db/development.sqlite3 ] && [ ! -f db/test.sqlite3 ]; then - bundle exec rake db:setup + su - vagrant -c "cd /vagrant/; bundle exec rake db:setup" else echo -e "\n\nWARNING: You have already have a development/test database." echo -e "WARNING: Please make sure this database works in this vagrant box!\n\n" From e01d8493742728334e726b7dfdc7aa2599a08d4e Mon Sep 17 00:00:00 2001 From: James Mason Date: Thu, 30 Nov 2017 10:37:20 -0800 Subject: [PATCH 05/16] Add a picture format for conference tickets --- app/uploaders/picture_uploader.rb | 9 +++++++++ db/migrate/20171130172334_rebuild_conference_pictures.rb | 9 +++++++++ db/schema.rb | 2 +- spec/models/conference_spec.rb | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20171130172334_rebuild_conference_pictures.rb diff --git a/app/uploaders/picture_uploader.rb b/app/uploaders/picture_uploader.rb index b17f0d76..76cf0708 100644 --- a/app/uploaders/picture_uploader.rb +++ b/app/uploaders/picture_uploader.rb @@ -80,6 +80,11 @@ class PictureUploader < CarrierWave::Uploader::Base process resize_and_pad: [320, 120, 'white'] end + version :ticket, if: :conference? + version :ticket do + process resize_and_pad: [120, 70] + end + # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list @@ -95,4 +100,8 @@ class PictureUploader < CarrierWave::Uploader::Base def sponsor?(_picture) object_class_name == 'sponsors' end + + def conference?(_picture) + object_class_name == 'conferences' + end end diff --git a/db/migrate/20171130172334_rebuild_conference_pictures.rb b/db/migrate/20171130172334_rebuild_conference_pictures.rb new file mode 100644 index 00000000..a8d74bce --- /dev/null +++ b/db/migrate/20171130172334_rebuild_conference_pictures.rb @@ -0,0 +1,9 @@ +class RebuildConferencePictures < ActiveRecord::Migration + def up + Conference.all.each do |conference| + conference.picture.recreate_versions! + end + end + + def down; end +end diff --git a/db/schema.rb b/db/schema.rb index de53720a..6df61a48 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.define(version: 20171118113113) do +ActiveRecord::Schema.define(version: 20171130172334) do create_table "ahoy_events", force: :cascade do |t| t.integer "visit_id" diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 26070134..0af13eed 100755 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -1704,4 +1704,8 @@ describe Conference do it { is_expected.to eq [past_conference1, past_conference2] } end + + it 'should have a picture format for tickets' do + expect(create(:conference).picture.ticket.url) + end end From 710010cb7611466a51961ad9b746c5e94629b6f4 Mon Sep 17 00:00:00 2001 From: James Mason Date: Thu, 30 Nov 2017 10:40:02 -0800 Subject: [PATCH 06/16] Use a picture format for ticketing Instead of analyzing image size using the local file, rely on a processed image of the appropriate dimensions. Resolves #1828 --- app/pdfs/ticket_pdf.rb | 18 +++++++++++++----- app/uploaders/picture_uploader.rb | 4 ---- app/views/physical_tickets/show.html.haml | 7 +------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/pdfs/ticket_pdf.rb b/app/pdfs/ticket_pdf.rb index 9a09f9fe..d21a1e27 100644 --- a/app/pdfs/ticket_pdf.rb +++ b/app/pdfs/ticket_pdf.rb @@ -1,3 +1,5 @@ +require 'open-uri' + class TicketPdf < Prawn::Document def initialize(conference, user, physical_ticket, ticket_layout, file_name) super(page_layout: ticket_layout, page_size: 'A4', filename: file_name) @@ -43,11 +45,17 @@ class TicketPdf < Prawn::Document def draw_second_square move_up 150 if @conference.picture? - if 7 * @conference.picture.image[:width] > 12 * @conference.picture.image[:height] - image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], width: 120 - else - image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], height: 70 - end + conference_image = case @conference.picture.ticket.url[0, 4] + when 'http', 'ftp:' # CDNs + open(@conference.picture.ticket.url) + when '/sys' # local storage + open([ + Rails.root, + '/public', + @conference.picture.ticket.url + ].join) + end + image conference_image, at: [@mid_horizontal + 30, cursor] else image "#{Rails.root}/public/img/osem-logo.png", at: [@mid_horizontal + 30, cursor], height: 70 end diff --git a/app/uploaders/picture_uploader.rb b/app/uploaders/picture_uploader.rb index 76cf0708..41bcab7b 100644 --- a/app/uploaders/picture_uploader.rb +++ b/app/uploaders/picture_uploader.rb @@ -52,10 +52,6 @@ class PictureUploader < CarrierWave::Uploader::Base "system/#{object_class_name}/#{mounted_as}/#{model.id}" end - def image - @image ||= MiniMagick::Image.open(file.file) - end - # Create different versions of your uploaded files: version :large do process resize_to_fit: [300, 300] diff --git a/app/views/physical_tickets/show.html.haml b/app/views/physical_tickets/show.html.haml index 40513ae8..7dbc44da 100644 --- a/app/views/physical_tickets/show.html.haml +++ b/app/views/physical_tickets/show.html.haml @@ -31,12 +31,7 @@ = @user.email .col-md-5.col-md-offset-2.box.well - if @conference.picture? - - width = @conference.picture.image[:width] - - height = @conference.picture.image[:height] - - if 10 * width > 15 * height - = image_tag(@conference.picture_url, width: '150') - - else - = image_tag(@conference.picture_url, height: '100') + = image_tag(@conference.picture.ticket.url, class: 'img-responsive') - else = image_tag('/img/osem-logo.png', class: 'img-responsive') %p.text-left From 32fa0bde6ba6d0e878fd0e3d88befe81c42cfc19 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Wed, 11 Jan 2017 16:45:58 +0200 Subject: [PATCH 07/16] Add mass import of commercials Fix #1055 --- .../admin/commercials_controller.rb | 20 +++++ app/models/commercial.rb | 25 ++++++- app/views/admin/events/index.html.haml | 75 ++++++++++++------- config/routes.rb | 1 + spec/factories/commercials.rb | 2 +- spec/features/commercials_spec.rb | 3 +- 6 files changed, 97 insertions(+), 29 deletions(-) diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index f13b4322..3c694246 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -49,6 +49,26 @@ module Admin end end + ## + # Received a file from user + # Reads file and creates commercial for event + # File content example: + # EventID:MyURL + def mass_upload + errors = Commercial.read_file(params[:file]) if params[:file] + + if errors.all? { |_k, v| v.blank? } + flash[:notice] = 'Successfully added commercials.' + else + errors_text = '' + errors_text << 'Unable to find event with ID: ' + errors[:no_event].join(', ') + '. ' if errors[:no_event].any? + errors_text << 'There were some errors: ' + errors[:validation_errors].join('. ') if errors[:validation_errors].any? + + flash[:error] = errors_text + end + redirect_to :back + end + private def commercial_params diff --git a/app/models/commercial.rb b/app/models/commercial.rb index 0976fe44..ad9597e4 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -5,7 +5,7 @@ class Commercial < ApplicationRecord has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } - validates :url, presence: true + validates :url, presence: true, uniqueness: { scope: :commercialable } validates :url, format: URI::regexp(%w(http https)) validate :valid_url @@ -20,6 +20,29 @@ class Commercial < ApplicationRecord end end + def self.read_file(file) + errors = {} + errors[:no_event] = [] + errors[:validation_errors] = [] + + file.read.each_line do |line| + # Get the event id (text before :) + id = line.match(/:/).pre_match.to_i + # Get the commercial url (text after :) + url = line.match(/:/).post_match + event = Event.find_by(id: id) + + # Go to next event, if the event is not found + errors[:no_event] << id && next unless event + + commercial = event.commercials.new(url: url) + unless commercial.save + errors[:validation_errors] << "Could not create commercial for event with ID #{event.id} (" + commercial.errors.full_messages.to_sentence + ')' + end + end + errors + end + private def valid_url diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index f8b58b63..be7abe05 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -4,37 +4,60 @@ %h1 Events = "(#{@events.length})" if @events.any? - .pull-right + + .btn-group.pull-right + %button.btn.btn-primary{ 'data-toggle' => 'modal', 'data-target' => '#mass-commercials-modal', title: 'Mass import of commercials for events' } + Add Commercials + - if can? :create, Event - =link_to 'Add Event', new_admin_conference_program_event_path(@conference.short_title), class: 'button btn btn-default btn-info' + = link_to 'Add Event', new_admin_conference_program_event_path(@conference.short_title), class: 'button btn btn-default btn-info' + - if can? :read, Event .btn-group - .btn-group - %button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' } - Export PDF - %span.caret - %ul.dropdown-menu{ role: 'menu' } - %li= link_to 'All Events', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'all') - %li= link_to 'Confirmed Events', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'confirmed') - %li= link_to 'All Events with Comments', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'all_with_comments') - .btn-group - %button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' } - Export CSV - %span.caret - %ul.dropdown-menu{ role: 'menu' } - %li= link_to 'All', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'all') - %li= link_to 'Confirmed', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'confirmed') - %li= link_to 'All with Comments', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'all_with_comments') - .btn-group - %button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' } - Export XLS - %span.caret - %ul.dropdown-menu{ role: 'menu' } - %li= link_to 'All', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'all') - %li= link_to 'Confirmed', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'confirmed') - %li= link_to 'All with Comments', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'all_with_comments') + %button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' } + Export PDF + %span.caret + %ul.dropdown-menu{ role: 'menu' } + %li= link_to 'All Events', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'all') + %li= link_to 'Confirmed Events', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'confirmed') + %li= link_to 'All Events with Comments', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'all_with_comments') + .btn-group + %button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' } + Export CSV + %span.caret + %ul.dropdown-menu{ role: 'menu' } + %li= link_to 'All', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'all') + %li= link_to 'Confirmed', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'confirmed') + %li= link_to 'All with Comments', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'all_with_comments') + .btn-group + %button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' } + Export XLS + %span.caret + %ul.dropdown-menu{ role: 'menu' } + %li= link_to 'All', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'all') + %li= link_to 'Confirmed', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'confirmed') + %li= link_to 'All with Comments', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'all_with_comments') + %p.text-muted All the submissions of your speakers + +.modal#mass-commercials-modal + .modal-dialog + .modal-content + .modal-header + %h1 Add commercials to events + .text-muted + Upload your file with data in the following format: + %b Event_ID:Commercial_Link + , eg. + %br + %b 11:https://youtube.com/myvideo + + .modal-body + = semantic_form_for '', url: mass_upload_commercials_admin_conference_program_path(@conference.short_title), method: :post do |f| + = f.input 'file', as: :file + .modal-footer + = f.submit 'Add', class: 'btn btn-primary' .row .col-md-4 = render partial: 'admin/conferences/doughnut_chart', locals: { title: 'Events state', data: @event_distribution } diff --git a/config/routes.rb b/config/routes.rb index 33a92a48..4e2fca74 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,6 +98,7 @@ Osem::Application.routes.draw do end resources :event_types resources :difficulty_levels + post 'mass_upload_commercials' => 'commercials#mass_upload' resources :events do member do patch :toggle_attendance diff --git a/spec/factories/commercials.rb b/spec/factories/commercials.rb index 2578d1cd..cf865348 100644 --- a/spec/factories/commercials.rb +++ b/spec/factories/commercials.rb @@ -2,7 +2,7 @@ FactoryGirl.define do factory :commercial do - url 'https://www.youtube.com/watch?v=BTTygyxuGj8' + sequence(:url) { |n| "https://www.youtube.com/watch?v=BTTygyxuGj#{n}" } factory :conference_commercial do association :commercialable, factory: :conference diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index 65efa0b6..d460a725 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -98,7 +98,8 @@ feature Commercial do scenario 'does not update a commercial of an event with invalid data', feature: true, versioning: true, js: true do commercial = create(:commercial, commercialable_id: event.id, - commercialable_type: 'Event') + commercialable_type: 'Event', + url: 'https://www.youtube.com/watch?v=BTTygyxuGj8') visit edit_conference_program_proposal_path(conference.short_title, event.id) click_link 'Commercials' fill_in "commercial_url_#{commercial.id}", with: 'invalid_commercial_url' From 0bfb2130a940707a6274ca2a397c645e80b03307 Mon Sep 17 00:00:00 2001 From: Alexandros Pagonis Date: Thu, 9 Nov 2017 19:26:01 +0200 Subject: [PATCH 08/16] Ticket_button added --- app/views/conference_registrations/show.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index a50cf198..83efbd60 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -104,7 +104,9 @@ = humanized_money @total_price_per_ticket[ticket_id] %br - if @tickets.any? - = link_to 'Get more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default" + .btn-group + = link_to 'View all tickets', conference_physical_tickets_path(@conference.short_title), class: "btn btn-success" + = link_to 'Get more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default" - else You haven't bought any tickets. = link_to 'Please get some tickets to support us!', conference_tickets_path(@conference.short_title) From d813470995fc3dea8a4981827a398eb4dba7b65f Mon Sep 17 00:00:00 2001 From: Sidharth Date: Fri, 8 Dec 2017 15:03:30 +0530 Subject: [PATCH 09/16] Contribution.md broken url The link to capybara was broken in CONTRIBUTION.md file Fixes #1862 --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5193725d..aa8bdbb2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,7 +82,7 @@ You can read through current enabled rules in `.rubocop.yml` file. Explanations Additionally you can read through the [ruby style-guide](https://github.com/bbatsov/ruby-style-guide) to better understand core principles. ### Test Suite -We are using [rspec](http://rspec.info/)+[capybara](http://jnicklas.github.io/capybara/)+[factory girl](https://github.com/thoughtbot/factory_girl) as a test suite. You can run it locally +We are using [rspec](http://rspec.info/)+[capybara](http://www.rubydoc.info/github/jnicklas/capybara)+[factory girl](https://github.com/thoughtbot/factory_girl) as a test suite. You can run it locally ```shell vagrant exec bundle exec rspec From b93613fcc586f6ae61f352414f9b7796a87a84ae Mon Sep 17 00:00:00 2001 From: Sidharth Bansal Date: Tue, 12 Dec 2017 11:45:23 +0530 Subject: [PATCH 10/16] Updated link --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa8bdbb2..bef64aab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,7 +82,7 @@ You can read through current enabled rules in `.rubocop.yml` file. Explanations Additionally you can read through the [ruby style-guide](https://github.com/bbatsov/ruby-style-guide) to better understand core principles. ### Test Suite -We are using [rspec](http://rspec.info/)+[capybara](http://www.rubydoc.info/github/jnicklas/capybara)+[factory girl](https://github.com/thoughtbot/factory_girl) as a test suite. You can run it locally +We are using [rspec](http://rspec.info/)+[capybara](http://teamcapybara.github.io/capybara/)+[factory girl](https://github.com/thoughtbot/factory_girl) as a test suite. You can run it locally ```shell vagrant exec bundle exec rspec From 9608e2032a0a5ebb529fa74765322859683df3c4 Mon Sep 17 00:00:00 2001 From: Thaleia Tagaraki Date: Sat, 2 Dec 2017 16:23:56 +0200 Subject: [PATCH 11/16] Add autofocus in admin/tickets#new --- app/views/admin/tickets/_form.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/tickets/_form.html.haml b/app/views/admin/tickets/_form.html.haml index 319f7996..f66cea51 100644 --- a/app/views/admin/tickets/_form.html.haml +++ b/app/views/admin/tickets/_form.html.haml @@ -9,8 +9,8 @@ .row .col-md-8 = semantic_form_for(@ticket, url: (@ticket.new_record? ? admin_conference_tickets_path : admin_conference_ticket_path(@conference.short_title, @ticket))) do |f| - = f.input :title - = f.input :description, input_html: { rows: 5, data: { provide: "markdown-editable" } } + = f.input :title, input_html: { autofocus: true } + = f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } } = f.input :price = f.input :price_currency, as: :select, class: 'form-control', collection: ['USD', 'EUR', 'GBP', 'INR', 'CNY', 'CHF'], include_blank: false = f.input :registration_ticket, hint: 'A registration ticket is with which user register for the conference.' From 6d7e1f4865a93962009746cfca5bddf664f64abc Mon Sep 17 00:00:00 2001 From: Adriano Vieira Date: Sat, 9 Dec 2017 12:00:50 -0200 Subject: [PATCH 12/16] autofill CFP end date - automatically setting the end date to the start date when creating CFP for UX reasons (fix #1872) --- app/assets/javascripts/osem-datepickers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/javascripts/osem-datepickers.js b/app/assets/javascripts/osem-datepickers.js index 84533b49..6dc89f43 100644 --- a/app/assets/javascripts/osem-datepickers.js +++ b/app/assets/javascripts/osem-datepickers.js @@ -98,6 +98,9 @@ $(function () { $("#registration-period-start-datepicker").on("dp.change",function (e) { $('#registration-period-end-datepicker').data("DateTimePicker").setMinDate(e.date); + if (!$('#registration-period-end-datepicker').val()) { + $('#registration-period-end-datepicker').data("DateTimePicker").setDate(e.date); + } }); $("#registration-period-end-datepicker").on("dp.change",function (e) { $('#registration-period-start-datepicker').data("DateTimePicker").setMaxDate(e.date); From e5009f168c46155e7162d5c873f3cc691840f617 Mon Sep 17 00:00:00 2001 From: rishabhptr Date: Tue, 5 Dec 2017 17:03:44 +0530 Subject: [PATCH 13/16] Fixed email text overflow in proposal#show Email icon is used solve email text overflow. Fixes #1838 --- app/views/proposals/show.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/proposals/show.html.haml b/app/views/proposals/show.html.haml index 19f9371f..99f2d49e 100644 --- a/app/views/proposals/show.html.haml +++ b/app/views/proposals/show.html.haml @@ -36,8 +36,10 @@ .col-md-8 %h4 = link_to speaker.name, user_path(speaker.id) + %br - if speaker.email_public? - = "(#{speaker.email})" + = mail_to "#{ speaker.email }" do + %i.fa.fa-envelope-o.fa-2x - if speaker.affiliation? .text-muted from From ac8b187f1f855d339a62cd05e565bbd413a4d9cb Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Thu, 23 Nov 2017 01:19:26 +0530 Subject: [PATCH 14/16] Speaker is also able to see the proposal and able to modify it --- app/models/user.rb | 2 +- spec/models/user_spec.rb | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4510aece..9a44a6a6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -216,7 +216,7 @@ class User < ApplicationRecord end def proposals(conference) - events.where('program_id = ? AND event_users.event_role=?', conference.program.id, 'submitter') + events.where('program_id = ? AND (event_users.event_role=? OR event_users.event_role=?)', conference.program.id, 'submitter', 'speaker') end def proposal_count(conference) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e742b993..b5b63089 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -345,24 +345,34 @@ describe User do end describe 'proposals methods' do - let(:submitter) { create(:submitter, user: user) } + let(:submitter) { create(:user) } + let(:speaker) { create(:user) } let(:event1) { create(:event, program: conference.program) } let(:event2) { create(:event, program: conference.program) } before do - event1.event_users << create(:event_user, user: user, event_role: 'submitter') - event2.event_users << create(:event_user, user: user, event_role: 'submitter') + event1.event_users << create(:event_user, user: submitter, event_role: 'submitter') + event2.event_users << create(:event_user, user: submitter, event_role: 'submitter') + event1.event_users << create(:event_user, user: speaker, event_role: 'speaker') end describe '#proposals' do it 'returns events submitted by user' do - expect(user.proposals(conference)).to match [event1, event2] + expect(submitter.proposals(conference)).to match [event1, event2] + end + + it 'returns events in which user is a speaker' do + expect(speaker.proposals(conference)).to match [event1] end end describe '#proposal_count' do it 'returns number of events submitted by user' do - expect(user.proposal_count(conference)).to eq 2 + expect(submitter.proposal_count(conference)).to eq 2 + end + + it 'returns number of events in which the user is a speaker' do + expect(speaker.proposal_count(conference)).to eq 1 end end end From 4409610a89f4848bd1c74f58242d9b06f72089a5 Mon Sep 17 00:00:00 2001 From: rishabh92 Date: Sun, 10 Dec 2017 21:08:55 -0600 Subject: [PATCH 15/16] Add database config examples for all supported databases Example for MySQL and PostgreSQL added. Fixes #1676 Update comments based on code review --- config/database.yml.example | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/config/database.yml.example b/config/database.yml.example index 51a4dd45..f47361d5 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -9,6 +9,35 @@ development: pool: 5 timeout: 5000 +## PostgreSQL +## gem install pg +## +## Ensure the postgres gem is defined in your Gemfile +## gem 'pg' +## Update with your database name and login credentials +# development: +# adapter: postgresql +# encoding: unicode +# database: database_name +# pool: 5 +# username: username +# password: password + +## MySQL +## gem install mysql2 +## +## Ensure the mysql gem is defined in your Gemfile +## gem 'mysql2' +## Update with your database name and login credentials +# development: +# adapter: mysql2 +# encoding: utf8 +# database: database_name +# pool: 5 +# username: username +# password: password +# socket: /tmp/mysql.sock + # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. From 4289f699ac8a812699d7a39e72eb9e7e08b6fda1 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Sun, 12 Feb 2017 17:57:55 +0200 Subject: [PATCH 16/16] Add enabled to event_schedules To show scheduled events that have been cancelled/withdrawn as 'cancelled', and consequently also show when an event is their replacement. admin/schedules#show does not show events that were scheduled and then cancelled/withdrawn, however a record in event_schedules exists for those events, but event_schedule.enabled = false --- app/controllers/admin/events_controller.rb | 9 +++++++++ app/controllers/proposals_controller.rb | 9 +++++++++ app/models/event.rb | 8 ++++++++ app/models/event_schedule.rb | 3 ++- .../20170212145523_add_enabled_to_event_schedules.rb | 5 +++++ db/schema.rb | 3 ++- 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20170212145523_add_enabled_to_event_schedules.rb diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index accfb281..164e0407 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -124,6 +124,15 @@ module Admin def cancel update_state(:cancel, 'Event canceled!') + selected_schedule = @event.program.selected_schedule + event_schedule = EventSchedule.unscoped.where(event: @event).find_by(schedule: selected_schedule) if selected_schedule + Rails.logger.debug "schedule: #{selected_schedule.inspect} and event_schedule #{event_schedule.inspect}" + if selected_schedule && event_schedule + event_schedule.enabled = false + event_schedule.save + else + @event.event_schedules.destroy_all + end end def reject diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 66052310..7ea81dc0 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -91,6 +91,15 @@ class ProposalsController < ApplicationController begin @event.withdraw + selected_schedule = @event.program.selected_schedule + event_schedule = @event.event_schedules.find_by(schedule: selected_schedule) if selected_schedule + Rails.logger.debug "schedule: #{selected_schedule.inspect} and event_schedule #{event_schedule.inspect}" + if selected_schedule && event_schedule + event_schedule.enabled = false + event_schedule.save + else + @event.event_schedules.destroy_all + end rescue Transitions::InvalidTransition redirect_to :back, error: "Event can't be withdrawn" return diff --git a/app/models/event.rb b/app/models/event.rb index 34c217f3..943572eb 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -197,6 +197,14 @@ class Event < ApplicationRecord send(transition) end save + # If the event was previously scheduled, and then withdrawn or cancelled + # its event_schedule will have enabled set to false + # If the event is now confirmed again, we want it to be available for scheduling + Rails.logger.debug "transition is #{transition}" + if transition == :confirm + Rails.logger.debug "schedules #{EventSchedule.unscoped.where(event: self, enabled: false)}" + EventSchedule.unscoped.where(event: self, enabled: false).destroy_all + end rescue Transitions::InvalidTransition => e alert = "Update state failed. #{e.message}" end diff --git a/app/models/event_schedule.rb b/app/models/event_schedule.rb index cb5d1675..9d59713d 100644 --- a/app/models/event_schedule.rb +++ b/app/models/event_schedule.rb @@ -1,4 +1,5 @@ class EventSchedule < ApplicationRecord + default_scope { where(enabled: true) } belongs_to :schedule belongs_to :event belongs_to :room @@ -33,7 +34,7 @@ class EventSchedule < ApplicationRecord # Returns event schedules that are scheduled in the same room and start_time as event # def intersecting_event_schedules - room.event_schedules.where(start_time: start_time, schedule: schedule).where.not(id: id) + EventSchedule.unscoped.where(room: room, start_time: start_time, schedule: schedule).where.not(id: id) end def replacement? diff --git a/db/migrate/20170212145523_add_enabled_to_event_schedules.rb b/db/migrate/20170212145523_add_enabled_to_event_schedules.rb new file mode 100644 index 00000000..d89505fe --- /dev/null +++ b/db/migrate/20170212145523_add_enabled_to_event_schedules.rb @@ -0,0 +1,5 @@ +class AddEnabledToEventSchedules < ActiveRecord::Migration + def change + add_column :event_schedules, :enabled, :boolean, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 6df61a48..43602f9b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -217,6 +217,7 @@ ActiveRecord::Schema.define(version: 20171130172334) do t.datetime "start_time" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "enabled", default: true t.index ["event_id", "schedule_id"], name: "index_event_schedules_on_event_id_and_schedule_id", unique: true t.index ["event_id"], name: "index_event_schedules_on_event_id" t.index ["room_id"], name: "index_event_schedules_on_room_id" @@ -494,7 +495,7 @@ ActiveRecord::Schema.define(version: 20171130172334) do t.integer "user_id" t.integer "payment_id" t.integer "week" - t.float "amount_paid", default: 0.0 + t.float "amount_paid" end create_table "ticket_scannings", force: :cascade do |t|