blob: e85fc47129cbd763cb452bb388fbbff747e30ddb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
require 'sinatra/base'
require 'sinatra/url_for'
require 'sinatra/config_file'
require 'tilt/erb'
require_relative 'lib/registration'
class RegistrationApp < Sinatra::Base
register Sinatra::ConfigFile
helpers Sinatra::UrlForHelper
include ERB::Util
set :logging, true
config_file File.join(settings.root, 'config.yml')
get '/' do
if !accept_registrations(settings)
return erb :registration_closed
end
@band = Band.new
3.times { @band.songs << Song.new }
erb :index
end
post '/submit' do
if request.form_data?
@band = Band.new(request['band'])
if @band.valid?
pdf_file = File.join("/uploads", create_pdf_file_name(@band))
generate_pdf_for(@band, File.join(settings.public_folder, pdf_file))
send_registration_emails_for(@band, url_for(pdf_file, :full))
end
if @band.valid?
erb :submitted
else
erb :index
end
end
end
run! if app_file == $0
end
|