diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2016-08-16 21:57:15 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2016-08-16 21:57:15 +0200 |
commit | ac3fe82eb741f9ea8ddc0c709d3c302492f3a402 (patch) | |
tree | 6aca86a769b87bc7d1d17086641a6897ef33d01b | |
parent | 9d3cee906330cbbe2dbd1bd4dcb88aa7c160baca (diff) | |
download | norsk-urskog-registrations-ac3fe82eb741f9ea8ddc0c709d3c302492f3a402.tar.gz norsk-urskog-registrations-ac3fe82eb741f9ea8ddc0c709d3c302492f3a402.tar.bz2 norsk-urskog-registrations-ac3fe82eb741f9ea8ddc0c709d3c302492f3a402.zip |
Move accept_registrations method to registration lib.
-rw-r--r-- | lib/registration.rb | 7 | ||||
-rw-r--r-- | registration.rb | 11 |
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/registration.rb b/lib/registration.rb index 6afe8b6..bebe326 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -1,5 +1,6 @@ require_relative 'band' require_relative 'pdf_form' +require 'date' require 'mail' def send_registration_emails_for(band, pdf_url) @@ -30,3 +31,9 @@ end def create_pdf_file_name(band) filename = "#{Date.today.iso8601}-#{sanitize(band.name)}-#{sanitize(band.city)}.pdf" end + +def accept_registrations(settings) + start_date = Date.parse(settings.accept_registrations[:start]) + end_date = Date.parse(settings.accept_registrations[:stop]) + start_date <= Date.today && end_date > Date.today +end diff --git a/registration.rb b/registration.rb index 8501a37..e85fc47 100644 --- a/registration.rb +++ b/registration.rb @@ -13,17 +13,8 @@ class RegistrationApp < Sinatra::Base config_file File.join(settings.root, 'config.yml') - - helpers do - def accept_registrations - start_date = Date.parse(settings.accept_registrations[:start]) - end_date = Date.parse(settings.accept_registrations[:stop]) - start_date <= Date.today && end_date > Date.today - end - end - get '/' do - if !accept_registrations + if !accept_registrations(settings) return erb :registration_closed end |