|
@@ -38,6 +38,7 @@ end
|
|
|
|
|
|
class SV < Sinatra::Application
|
|
|
configure do
|
|
|
+ STOP_ZEIT = 'Oct 3, 2017, 18:00'
|
|
|
enable :sessions
|
|
|
set :session_secret, (ENV['SV_SESSION_SECRET'] || 'your_secret')
|
|
|
Slim::Engine.set_options pretty: true
|
|
@@ -50,6 +51,10 @@ class SV < Sinatra::Application
|
|
|
end
|
|
|
|
|
|
helpers do
|
|
|
+ def ende
|
|
|
+ Time.now > time_for(STOP_ZEIT)
|
|
|
+ end
|
|
|
+
|
|
|
def protected!
|
|
|
return if authorized?
|
|
|
headers['WWW-Authenticate'] = 'Basic realm="Bitte anmelden"'
|
|
@@ -77,7 +82,7 @@ class SV < Sinatra::Application
|
|
|
end
|
|
|
|
|
|
get '/' do
|
|
|
- if Time.now > time_for('Oct 3, 2016, 18:00')
|
|
|
+ if ende
|
|
|
redirect to("/ergebnis")
|
|
|
end
|
|
|
infos = Info.all
|
|
@@ -89,7 +94,7 @@ class SV < Sinatra::Application
|
|
|
end
|
|
|
|
|
|
post "/wahl" do
|
|
|
- if Time.now > time_for('Sep 30, 2016, 18:00')
|
|
|
+ if ende
|
|
|
session[:flash] = [0, "Sie können sich nicht mehr aufstellen lassen, die Wahl hat bereits begonnen"]
|
|
|
redirect back
|
|
|
end
|
|
@@ -125,7 +130,7 @@ class SV < Sinatra::Application
|
|
|
end
|
|
|
|
|
|
get '/ergebnis' do
|
|
|
- protected! if Time.now < time_for('Oct 3, 2016, 18:00')
|
|
|
+ protected! if !ende
|
|
|
sprecher, schuko, lehrer, waehler = [], [], [], 0
|
|
|
DB.transaction do
|
|
|
sprecher = Schueler.where(:sprecher => true).all
|
|
@@ -159,10 +164,10 @@ class SV < Sinatra::Application
|
|
|
end
|
|
|
|
|
|
post "/:hashid" do
|
|
|
- if Time.now > time_for('Oct 3, 2016, 18:00')
|
|
|
+ if ende
|
|
|
session[:flash] = [0, "Der Wahlzeitraum ist seit 3. Oktober 18:00 Uhr abgelaufen."]
|
|
|
redirect back
|
|
|
- elsif Time.now < time_for('Sep 30, 2016, 18:00')
|
|
|
+ else
|
|
|
session[:flash] = [0, "Der Wahlzeitraum beginnt erst am 30. September um 18:00 Uhr."]
|
|
|
redirect back
|
|
|
end
|