Show More
Commit Description:
MERGE changeset 306:307 from branch ytopc08-2 that fixes migration bug...
Commit Description:
MERGE changeset 306:307 from branch ytopc08-2 that fixes migration bug
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@308 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
app/controllers/site_controller.rb
| 40 lines
| 883 B
| text/x-ruby
| RubyLexer
|
|
r123 | 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 | ||||
|
r133 | def logout | ||
reset_session | ||||
redirect_to :controller => 'main', :action => 'login' | ||||
end | ||||
|
r123 | 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 | ||||