|
@@ -13,8 +13,13 @@ if ENV['RACK_ENV'] != "test"
|
|
DB = Sequel.connect(:adapter=>'postgres', :host=>ENV['SV_HOST'], :database=>ENV['SV_DB'], :user=>ENV['SV_USER'], :password=>ENV['SV_PASSWORD'], :sslmode => "require")
|
|
DB = Sequel.connect(:adapter=>'postgres', :host=>ENV['SV_HOST'], :database=>ENV['SV_DB'], :user=>ENV['SV_USER'], :password=>ENV['SV_PASSWORD'], :sslmode => "require")
|
|
end
|
|
end
|
|
|
|
|
|
-class Schueler < Sequel::Model(:schueler);end
|
|
|
|
-class Lehrer < Sequel::Model(:lehrer);end
|
|
|
|
|
|
+class Schueler < Sequel::Model(:schueler)
|
|
|
|
+ one_to_many :sprecher_stimmen, :key => :sprecher_id, :class => :Sprecher
|
|
|
|
+ one_to_many :schuko_stimmen, :key => :schuko_id, :class => :Schuko
|
|
|
|
+end
|
|
|
|
+class Lehrer < Sequel::Model(:lehrer)
|
|
|
|
+ one_to_many :lehrer_stimmen, :key => :lehrer_id, :class => :Verbindungslehrer
|
|
|
|
+end
|
|
class Info < Sequel::Model(:infos);end
|
|
class Info < Sequel::Model(:infos);end
|
|
class Sprecher < Sequel::Model(:sprecher);end
|
|
class Sprecher < Sequel::Model(:sprecher);end
|
|
class Schuko < Sequel::Model(:schuko);end
|
|
class Schuko < Sequel::Model(:schuko);end
|
|
@@ -54,6 +59,12 @@ class SV < Sinatra::Application
|
|
'Es ist ein Fehler aufgetreten. Sollte das nochmal passieren, schreiben Sie mir doch bitte eine eMail: bk@hmt.im'
|
|
'Es ist ein Fehler aufgetreten. Sollte das nochmal passieren, schreiben Sie mir doch bitte eine eMail: bk@hmt.im'
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+ before do
|
|
|
|
+ if session[:flash] && session[:flash][0] == 0
|
|
|
|
+ logger.info session[:flash][1]
|
|
|
|
+ end
|
|
|
|
+ end
|
|
|
|
+
|
|
get '/' do
|
|
get '/' do
|
|
infos = Info.all
|
|
infos = Info.all
|
|
slim :home, :locals => {:infos => infos}
|
|
slim :home, :locals => {:infos => infos}
|
|
@@ -99,6 +110,18 @@ class SV < Sinatra::Application
|
|
slim :info, :locals => {:infos => infos}
|
|
slim :info, :locals => {:infos => infos}
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+ get '/ergebnis' do
|
|
|
|
+ protected!
|
|
|
|
+ sprecher, schuko, lehrer, waehler = [], [], [], 0
|
|
|
|
+ DB.transaction do
|
|
|
|
+ sprecher = Schueler.where(:sprecher => true).all
|
|
|
|
+ schuko = Schueler.where(:schuko => true).all
|
|
|
|
+ lehrer = Lehrer.all
|
|
|
|
+ waehler = Schueler.where(:gewaehlt => true).count
|
|
|
|
+ end
|
|
|
|
+ slim :ergebnis, :locals => {:sprecher => sprecher, :schuko => schuko, :lehrer => lehrer, :waehler => waehler}
|
|
|
|
+ end
|
|
|
|
+
|
|
post "/hashid" do
|
|
post "/hashid" do
|
|
redirect to("/#{params[:hashid]}")
|
|
redirect to("/#{params[:hashid]}")
|
|
end
|
|
end
|