Merge branch 'master' of github.com:snap-cloud/snapcon

* 'master' of github.com:snap-cloud/snapcon:
  Fix registrations csv
  Tweak Materials to allow anything
  A bit of a hack to accept any webpage...
  Add the ability for Rooms to have a URL.
  Add import rake task
  config that works without docker
  Add some links to navbar
  More login info
  Custom login help info
  Run migration; add apple pay verification
  fix tickets bug with no description
This commit is contained in:
Michael Ball 2020-07-10 23:59:29 -07:00
commit 69b18a97e1
24 changed files with 134 additions and 56 deletions

View file

@ -115,6 +115,9 @@ $(document).ready( function() {
}); });
function eventClicked(e, element){ function eventClicked(e, element){
if (e.target.href) {
return;
}
var url = $(element).data('url'); var url = $(element).data('url');
if(e.ctrlKey) if(e.ctrlKey)
window.open(url,'_blank'); window.open(url,'_blank');

View file

@ -48,7 +48,7 @@ module Admin
private private
def room_params def room_params
params.require(:room).permit(:name, :size) params.require(:room).permit(:name, :size, :url)
end end
end end
end end

View file

@ -8,6 +8,7 @@ class ApplicationController < ActionController::Base
before_action :store_location before_action :store_location
# Ensure every controller authorizes resource or skips authorization (skip_authorization_check) # Ensure every controller authorizes resource or skips authorization (skip_authorization_check)
check_authorization unless: :devise_controller? check_authorization unless: :devise_controller?
skip_authorization_check if:
def store_location def store_location
# store last url - this is needed for post-login redirect to whatever the user last visited. # store last url - this is needed for post-login redirect to whatever the user last visited.
@ -65,4 +66,9 @@ class ApplicationController < ActionController::Base
def not_found def not_found
raise ActionController::RoutingError.new('Not Found') raise ActionController::RoutingError.new('Not Found')
end end
skip_authorization_check only: :apple_pay
def apple_pay
render plain: ENV['OSEM_APPLE_PAY_ID']
end
end end

View file

@ -21,4 +21,9 @@ module ConferenceHelper
'%20Sponsorship' '%20Sponsorship'
].join ].join
end end
def short_ticket_description(ticket)
return unless ticket.description
markdown(ticket.description&.split("\n").first&.strip)
end
end end

View file

@ -18,10 +18,16 @@ class Commercial < ApplicationRecord
resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315) resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315)
{ html: resource.html.html_safe } { html: resource.html.html_safe }
rescue StandardError => exception rescue StandardError => exception
{ error: exception.message } { html: iframe_fallback(url) }
# { error: exception.message }
end end
end end
def self.iframe_fallback(url)
# <br><a href='#{url}' target=_blank>Open in a new tab</a>
"<iframe src=\"#{url}\"></iframe>".html_safe
end
def self.read_file(file) def self.read_file(file)
errors = {} errors = {}
errors[:no_event] = [] errors[:no_event] = []
@ -67,11 +73,10 @@ class Commercial < ApplicationRecord
OEmbed::Providers::Instagram, OEmbed::Providers::Instagram,
speakerdeck speakerdeck
) )
# OEmbed::Providers.register_fallback(
OEmbed::Providers.register_fallback( # OEmbed::ProviderDiscovery,
OEmbed::ProviderDiscovery, # OEmbed::Providers::Noembed
OEmbed::Providers::Noembed # )
)
end end
def conference_id def conference_id

View file

@ -2,15 +2,11 @@
'Name', 'Name',
'Nickname', 'Nickname',
'Affilιation', 'Affilιation',
'Email', 'Email']
'Arrival',
'Departure']
= CSV.generate_line headers = CSV.generate_line headers
- @registrations.each do |registration| - @registrations.each do |registration|
= CSV.generate_line([registration.attended ? 'X' : '', = CSV.generate_line([registration.attended ? 'X' : '',
registration.name, registration.name,
registration.nickname, registration.nickname,
registration.affiliation, registration.affiliation,
registration.email, registration.email])
registration.arrival.to_s,
registration.departure.to_s])

View file

@ -11,5 +11,8 @@
= semantic_form_for(@room, url: (@room.new_record? ? admin_conference_venue_rooms_path : admin_conference_venue_room_path(@conference.short_title, @room))) do |f| = semantic_form_for(@room, url: (@room.new_record? ? admin_conference_venue_rooms_path : admin_conference_venue_room_path(@conference.short_title, @room))) do |f|
= f.input :name, input_html: { autofocus: true } = f.input :name, input_html: { autofocus: true }
= f.input :size, label: 'Capacity', input_html: {size: 5} = f.input :size, label: 'Capacity', input_html: {size: 5}
= f.input :url, label: 'URL'
%p.small
The URL is only visible to registered attendees.
%p.text-right %p.text-right
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -12,6 +12,7 @@
%thead %thead
%th Name %th Name
%th Capacity %th Capacity
%th URL
%th Actions %th Actions
%tbody %tbody
- @rooms.each_with_index do |room, index| - @rooms.each_with_index do |room, index|
@ -21,11 +22,13 @@
%td %td
= room.size = room.size
%td %td
= link_to 'Edit', edit_admin_conference_venue_room_path(@conference.short_title, room.id), = room.url
method: :get, class: 'btn btn-primary' %td
= link_to 'Delete', admin_conference_venue_room_path(@conference.short_title, room.id), = link_to 'Edit', edit_admin_conference_venue_room_path(@conference.short_title, room.id), class: 'btn btn-primary'
method: :delete, class: 'btn btn-danger', = link_to('Delete',
data: { confirm: "Do you really want to delete #{room.name}? Attention: This room will be removed from all Events that have it set"} admin_conference_venue_room_path(@conference.short_title, room.id),
method: :delete, class: 'btn btn-danger',
data: { confirm: "Do you really want to delete #{room.name}? Attention: This room will be removed from all Events that have it set"})
.row .row
.col-md-12.text-right .col-md-12.text-right
= link_to 'Add Room', new_admin_conference_venue_room_path(@conference.short_title), class: 'btn btn-primary' = link_to 'Add Room', new_admin_conference_venue_room_path(@conference.short_title), class: 'btn btn-primary'

View file

@ -1,6 +1,8 @@
= content_for :splash_nav do = content_for :splash_nav do
%li %li
%a.smoothscroll{ href: '#program' } Program %a.smoothscroll{ href: '#program' } Program
%li
= link_to('Schedule', conference_schedule_path(@conference))
- cache [conference, highlights, tracks, booths, '#splash#program'] do - cache [conference, highlights, tracks, booths, '#splash#program'] do
%section#program %section#program

View file

@ -20,7 +20,7 @@
%h3.text-center.word_break %h3.text-center.word_break
= ticket.title = ticket.title
.word_break .word_break
= markdown(ticket.description.split("\n")&.first.strip) = short_ticket_description(ticket)
%button.btn-block.btn.btn-lg.btn-success %button.btn-block.btn.btn-lg.btn-success
%i.fa.fa-ticket.fa-fw{"aria-hidden": true} %i.fa.fa-ticket.fa-fw{"aria-hidden": true}
= humanized_money_with_symbol(ticket.price) = humanized_money_with_symbol(ticket.price)

View file

@ -1,5 +1,5 @@
%p.text-right %p.text-right
%a.small.btn.btn-default.btn-xs{"data-toggle" => "collapse", "data-target" => "#devise-help"} %a.small.btn.btn-default.btn-xs{"data-toggle" => "collapse", "data-target" => "#devise-help"}
Need Help? Can't login?
#devise-help.collapse #devise-help.collapse
= render 'devise/shared/links' = render 'devise/shared/links'

View file

@ -15,3 +15,9 @@
%span %span
Snap Snap
%em> ! %em> !
%br
.text-center
%em If you are not currently logged into Snap! or the Snap! Forums, you will need to log in to
Snap!Con twice when using your Snap! account. We're working on fixing this. Thanks!
%br

View file

@ -2,7 +2,10 @@
%p %p
%strong Create an account directly for Snap!Con, or sign in using Google. %strong Create an account directly for Snap!Con, or sign in using Google.
%p %p
Snap!Con uses a different account system, but please use the same username or email address if possible. (We're working on improving this!) You may sign in via Snap!, but the first time you try, you
%em might not
be redirected back to Snap!Con. If that happens, try a second time and the login will work.
We're trying to fix this issue. Thanks!
= semantic_fields_for @user do |u| = semantic_fields_for @user do |u|
= u.input :username, input_html: { required: 'required', autocomplete: 'off' } = u.input :username, input_html: { required: 'required', autocomplete: 'off' }
= u.input :email, input_html: { required: 'required', autocomplete: 'off' } = u.input :email, input_html: { required: 'required', autocomplete: 'off' }

View file

@ -19,6 +19,10 @@
- if content_for :splash_nav - if content_for :splash_nav
%ul.nav.navbar-nav#splash-nav %ul.nav.navbar-nav#splash-nav
= content_for :splash_nav = content_for :splash_nav
%li
= link_to 'https://snap.berkeley.edu', target: '_blank' do
Snap
%em !
-if user_signed_in? -if user_signed_in?
.btn-group.pull-right .btn-group.pull-right
%ul.nav.navbar-nav.navbar-right %ul.nav.navbar-nav.navbar-right

View file

@ -8,21 +8,25 @@
%meta{ property: "og:image:secure_url", content: @speakers_ordered.first.gravatar_url } %meta{ property: "og:image:secure_url", content: @speakers_ordered.first.gravatar_url }
.container .container
.row .row.page-header
.col-md-12.page-header .col-md-10
%h2 %h2
= @event.title = @event.title
- if @event.subtitle - if @event.subtitle
%br %br
%small %small
= @event.subtitle = @event.subtitle
.btn-group.pull-right - if @event.room&.url && @conference.user_registered?(current_user)
- if can? :update, @event %h3
= link_to 'Registrations', registrations_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-success' = link_to('Join Event', @event.room.url, target: '_blank')
- if can? :edit, @event .col-md-2
= link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary' %p{style: "margin-top: 20px"}
- if can? :schedule, @conference - if can?(:update, @event) && @event.require_registration?
= link_to "Schedule", conference_schedule_path(@conference.short_title), class: 'btn btn-success' = link_to 'Registrations', registrations_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-success'
- if can?(:edit, @event)
= link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary'
- if can? :schedule, @conference
= link_to "Schedule", conference_schedule_path(@conference.short_title), class: 'btn btn-success'
.row .row
.col-md-3 .col-md-3
@ -58,7 +62,7 @@
- if @event.commercials.empty? - if @event.commercials.empty?
%h5.text-warning %h5.text-warning
No video of the event yet, sorry! No materials for the event yet, sorry!
- unless @conference.commercials.empty? - unless @conference.commercials.empty?
Meanwhile... Meanwhile...
- unless @conference.commercials.empty? - unless @conference.commercials.empty?

View file

@ -17,6 +17,9 @@
%h4 %h4
- if(event.speakers.any?) - if(event.speakers.any?)
presented by #{event.speaker_names} presented by #{event.speaker_names}
- if event.room&.url && @conference.user_registered?(current_user)
%p
= link_to('Join Event', event.room.url, target: '_blank')
%p %p
= markdown(truncate(event.abstract, length: 400)) = markdown(truncate(event.abstract, length: 400))
= link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400 = link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400

View file

@ -1,5 +1,5 @@
.container .container
= render partial: 'schedule_tabs', locals: { active: 'schedule' } = render partial: 'schedule_tabs', locals: { active: 'schedule' }
#schedule-content #schedule-content
%h1.text-center %h1.text-center

View file

@ -1,15 +1,19 @@
- if commercial.url .flexvideo
= Commercial.render_from_url(commercial.url)[:html] - if commercial.url
- else = Commercial.render_from_url(commercial.url)[:html]
- if commercial.commercial_type == 'SlideShare'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://www.slideshare.net/slideshow/embed_code/#{commercial.commercial_id}"}
- elsif commercial.commercial_type == 'Flickr'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://flic.kr/p/#{commercial.commercial_id}/player/268a054da2"}
- elsif commercial.commercial_type == 'Vimeo'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "//player.vimeo.com/video/#{commercial.commercial_id}"}
- elsif commercial.commercial_type == 'Speakerdeck'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://speakerdeck.com/player/#{commercial.commercial_id}?"}
- elsif commercial.commercial_type == 'Instagram'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', scrolling: 'no', allowtransparency: 'true', src: "//instagram.com/p/#{commercial.commercial_id}/embed/"}
- else - else
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://www.youtube.com/embed/#{commercial.commercial_id}?rel=0"} - if commercial.commercial_type == 'SlideShare'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://www.slideshare.net/slideshow/embed_code/#{commercial.commercial_id}"}
- elsif commercial.commercial_type == 'Flickr'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://flic.kr/p/#{commercial.commercial_id}/player/268a054da2"}
- elsif commercial.commercial_type == 'Vimeo'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "//player.vimeo.com/video/#{commercial.commercial_id}"}
- elsif commercial.commercial_type == 'Speakerdeck'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://speakerdeck.com/player/#{commercial.commercial_id}?"}
- elsif commercial.commercial_type == 'Instagram'
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', scrolling: 'no', allowtransparency: 'true', src: "//instagram.com/p/#{commercial.commercial_id}/embed/"}
- else
%iframe{width: '560', height: '315', frameborder: '0', allowfullscreen: 'true', src: "https://www.youtube.com/embed/#{commercial.commercial_id}?rel=0"}
- if commercial.url
%br
= link_to('Open in a new tab', commercial.url, target: '_blank')

View file

@ -1,7 +1,6 @@
- unless commercials.empty? - unless commercials.empty?
- if commercials.length == 1 - if commercials.length == 1
.flexvideo = render partial: 'shared/media_item', locals: { commercial: commercials.first }
= render partial: 'shared/media_item', locals: { commercial: commercials.first }
- else - else
%ul.nav.nav-tabs{ 'role'=>'tablist' } %ul.nav.nav-tabs{ 'role'=>'tablist' }
- commercials.each.with_index(1) do |commercial, index| - commercials.each.with_index(1) do |commercial, index|
@ -12,9 +11,7 @@
- commercials.each.with_index(1) do |commercial, index| - commercials.each.with_index(1) do |commercial, index|
- if index == 1 - if index == 1
.tab-pane.active{'id'=>"#{index}"} .tab-pane.active{'id'=>"#{index}"}
.flexvideo = render partial: 'shared/media_item', locals: { commercial: commercial }
= render partial: 'shared/media_item', locals: { commercial: commercial }
- else - else
.tab-pane{'id'=>"#{index}"} .tab-pane{'id'=>"#{index}"}
.flexvideo = render partial: 'shared/media_item', locals: { commercial: commercial }
= render partial: 'shared/media_item', locals: { commercial: commercial }

View file

@ -11,14 +11,15 @@ default: &default
encoding: <%= encoding %> encoding: <%= encoding %>
host: <%= ENV['OSEM_DB_HOST'] || 'database' %> host: <%= ENV['OSEM_DB_HOST'] || 'database' %>
port: <%= ENV['OSEM_DB_PORT'] || '5432' %> port: <%= ENV['OSEM_DB_PORT'] || '5432' %>
username: <%= ENV['OSEM_DB_USER'] || 'postgres' %> # username: <%= ENV['OSEM_DB_USER'] || 'postgres' %>
password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %> # password: <%= ENV['OSEM_DB_PASSWORD'] || 'mysecretpassword' %>
database: <%= ENV['OSEM_DB_NAME'] || 'postgres' %> database: <%= ENV['OSEM_DB_NAME'] || 'postgres' %>
pool: 5 pool: 5
timeout: 5000 timeout: 5000
development: development:
<<: *default <<: *default
host: localhost
database: osem_development database: osem_development
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
@ -26,6 +27,7 @@ development:
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
<<: *default <<: *default
host: localhost
database: osem_test database: osem_test
production: production:

View file

@ -230,4 +230,6 @@ Osem::Application.routes.draw do
else else
root to: 'conferences#index', via: [:get, :options] root to: 'conferences#index', via: [:get, :options]
end end
get '/.well-known/apple-developer-merchantid-domain-association', to: 'application#apple_pay'
end end

View file

@ -0,0 +1,5 @@
class AddUrlToRooms < ActiveRecord::Migration[5.2]
def change
add_column :rooms, :url, :string
end
end

View file

@ -10,7 +10,10 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_03_31_214534) do ActiveRecord::Schema.define(version: 2020_07_10_215300) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "answers", force: :cascade do |t| create_table "answers", force: :cascade do |t|
t.string "title" t.string "title"
@ -403,6 +406,7 @@ ActiveRecord::Schema.define(version: 2020_03_31_214534) do
t.string "name", null: false t.string "name", null: false
t.integer "size" t.integer "size"
t.integer "venue_id", null: false t.integer "venue_id", null: false
t.string "url"
end end
create_table "schedules", force: :cascade do |t| create_table "schedules", force: :cascade do |t|
@ -638,7 +642,7 @@ ActiveRecord::Schema.define(version: 2020_03_31_214534) do
t.text "object_changes" t.text "object_changes"
t.datetime "created_at" t.datetime "created_at"
t.integer "conference_id" t.integer "conference_id"
t.integer "organization_id" t.bigint "organization_id"
t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
t.index ["organization_id"], name: "index_versions_on_organization_id" t.index ["organization_id"], name: "index_versions_on_organization_id"
end end

View file

@ -12,4 +12,25 @@ namespace :db do
puts 'Database exists, skipping bootstrap...' puts 'Database exists, skipping bootstrap...'
end end
end end
desc "Import a given file into the database"
task :import, [:path] => :environment do |_t, args|
dump_path = args.path
connection_config = ActiveRecord::Base.connection_config
case connection_config[:adapter]
when "postgresql"
system("PGPASSWORD=#{connection_config[:password]} pg_restore " \
"--verbose --clean --no-acl --no-owner " \
"--username=#{connection_config[:username]} " \
"-d #{connection_config[:database]} #{dump_path}")
when "mysql", "mysql2"
system("mysql -u #{connection_config[:username]} " \
"-p#{connection_config[:password]} " \
"#{connection_config[:database]} < #{dump_path}")
else
raise NotImplementedError, "An importer hasn't been implemented for: " \
"#{connection_config[:adapter]}"
end
end
end end