summaryrefslogblamecommitdiffstats
path: root/registration.rb
blob: b8f2e83d51f7f92344db175f4cccd9e7945fedc4 (plain) (tree)
1
2
3
4
5
6
7
8
9
                      
                         
                  
                                   

                                     

                               
 

                  
            
                               


              



                                       




                                          

                                        
         


       

                        
require 'sinatra/base'
require 'sinatra/url_for'
require 'tilt/erb'
require_relative 'lib/registration'

class RegistrationApp < Sinatra::Base
  helpers Sinatra::UrlForHelper
  include ERB::Util

  enable :sessions

  get '/' do
    @errors = session['errors']
    erb :index
  end

  post '/submit' do
    if request.form_data?
      #p request['band']
      @band = Band.new(request['band'])
      if @band.valid?
        generate_pdf_for @band
        send_registration_emails_for @band
        erb :submitted
      else
        session['errors'] = @band.errors
        redirect to('/')
      end
    end
  end

  run! if app_file == $0
end