diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb new file mode 100644 --- /dev/null +++ b/app/controllers/site_controller.rb @@ -0,0 +1,35 @@ +class SiteController < ApplicationController + + before_filter :site_admin_authorization + + def index + if @site.started + render :action => 'started', :layout => 'empty' + else + render :action => 'prompt', :layout => 'empty' + end + end + + def start + @site.started = true + @site.start_time = Time.new.gmtime + @site.save + redirect_to :action => 'index' + end + + protected + def site_admin_authorization + if session[:site_id]==nil + redirect_to :controller => 'main', :action => 'login' and return + end + begin + @site = Site.find(session[:site_id], :include => :country) + rescue ActiveRecord::RecordNotFound + @site = nil + end + if @site==nil + redirect_to :controller => 'main', :action => 'login' and return + end + end + +end