diff --git a/.gitignore b/.gitignore
new file mode 100644
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*~
+log
+config/environment.rb
+config/database.yml
diff --git a/Rakefile b/Rakefile
--- a/Rakefile
+++ b/Rakefile
@@ -8,3 +8,12 @@
require 'rake/rdoctask'
require 'tasks/rails'
+
+require 'spec/rake/spectask'
+
+desc "Run all examples with RCov"
+Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
+ t.spec_files = FileList['spec/*/*.rb']
+ t.rcov = true
+ #t.rcov_opts = ['--exclude', 'examples']
+end
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
deleted file mode 100644
--- a/app/controllers/application.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-class ApplicationController < ActionController::Base
- # Pick a unique cookie name to distinguish our session data from others'
- session :session_key => '_grader_session_id'
-
- SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
-
- def admin_authorization
- return false unless authenticate
- user = User.find(session[:user_id], :include => ['roles'])
- redirect_to :controller => 'main', :action => 'login' unless user.admin?
- end
-
- def authorization_by_roles(allowed_roles)
- return false unless authenticate
- user = User.find(session[:user_id])
- unless user.roles.detect { |role| allowed_roles.member?(role.name) }
- flash[:notice] = 'You are not authorized to view the page you requested'
- redirect_to :controller => 'main', :action => 'login'
- return false
- end
- end
-
- protected
-
- def authenticate
- unless session[:user_id]
- redirect_to :controller => 'main', :action => 'login'
- return false
- end
-
- #Configuration.reload
- # check if run in single user mode
- if (Configuration[SINGLE_USER_MODE_CONF_KEY])
- user = User.find(session[:user_id])
- if user==nil or user.login != 'root'
- redirect_to :controller => 'main', :action => 'login'
- return false
- end
- end
-
- return true
- end
-
- def authorization
- return false unless authenticate
- user = User.find(session[:user_id])
- unless user.roles.detect { |role|
- role.rights.detect{ |right|
- right.controller == self.class.controller_name and
- (right.action == 'all' or right.action == action_name)
- }
- }
- flash[:notice] = 'You are not authorized to view the page you requested'
- #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
- redirect_to :controller => 'main', :action => 'login'
- return false
- end
- end
-
- def verify_time_limit
- return true if session[:user_id]==nil
- user = User.find(session[:user_id], :include => :site)
- return true if user==nil or user.site == nil
- if user.site.finished?
- flash[:notice] = 'Error: the contest on your site is over.'
- redirect_to :back
- return false
- end
- return true
- end
-
-end
-
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,76 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ # Pick a unique cookie name to distinguish our session data from others'
+ session :session_key => '_grader_session_id'
+
+ SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
+
+ def admin_authorization
+ return false unless authenticate
+ user = User.find(session[:user_id], :include => ['roles'])
+ redirect_to :controller => 'main', :action => 'login' unless user.admin?
+ end
+
+ def authorization_by_roles(allowed_roles)
+ return false unless authenticate
+ user = User.find(session[:user_id])
+ unless user.roles.detect { |role| allowed_roles.member?(role.name) }
+ flash[:notice] = 'You are not authorized to view the page you requested'
+ redirect_to :controller => 'main', :action => 'login'
+ return false
+ end
+ end
+
+ protected
+
+ def authenticate
+ unless session[:user_id]
+ redirect_to :controller => 'main', :action => 'login'
+ return false
+ end
+
+ #Configuration.reload
+ # check if run in single user mode
+ if (Configuration[SINGLE_USER_MODE_CONF_KEY])
+ user = User.find(session[:user_id])
+ if user==nil or user.login != 'root'
+ redirect_to :controller => 'main', :action => 'login'
+ return false
+ end
+ end
+
+ return true
+ end
+
+ def authorization
+ return false unless authenticate
+ user = User.find(session[:user_id])
+ unless user.roles.detect { |role|
+ role.rights.detect{ |right|
+ right.controller == self.class.controller_name and
+ (right.action == 'all' or right.action == action_name)
+ }
+ }
+ flash[:notice] = 'You are not authorized to view the page you requested'
+ #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
+ redirect_to :controller => 'main', :action => 'login'
+ return false
+ end
+ end
+
+ def verify_time_limit
+ return true if session[:user_id]==nil
+ user = User.find(session[:user_id], :include => :site)
+ return true if user==nil or user.site == nil
+ if user.site.finished?
+ flash[:notice] = 'Error: the contest on your site is over.'
+ redirect_to :back
+ return false
+ end
+ return true
+ end
+
+end
+
diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb
--- a/app/controllers/login_controller.rb
+++ b/app/controllers/login_controller.rb
@@ -31,12 +31,12 @@
flash[:notice] = 'Wrong site'
redirect_to :controller => 'main', :action => 'login' and return
end
- if site.password == params[:login][:password]
+ if (site.password) and (site.password == params[:login][:password])
session[:site_id] = site.id
redirect_to :controller => 'site', :action => 'index'
else
flash[:notice] = 'Wrong site password'
- redirect_to :controller => 'main', :action => 'login'
+ redirect_to :controller => 'site', :action => 'login'
end
end
diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb
--- a/app/controllers/main_controller.rb
+++ b/app/controllers/main_controller.rb
@@ -35,22 +35,6 @@
# @hidelogin = true
# end
- # Site administrator login
- @countries = Country.find(:all, :include => :sites)
- @country_select = @countries.collect { |c| [c.name, c.id] }
-
- @country_select_with_all = [['Any',0]]
- @countries.each do |country|
- @country_select_with_all << [country.name, country.id]
- end
-
- @site_select = []
- @countries.each do |country|
- country.sites.each do |site|
- @site_select << ["#{site.name}, #{country.name}", site.id]
- end
- end
-
@announcements = Announcement.find_for_frontpage
render :action => 'login', :layout => 'empty'
end
@@ -197,7 +181,11 @@
@prob_submissions << { :count => 0, :submission => nil }
end
end
- @announcements = Announcement.find_published
+ if Configuration.show_tasks_to?(@user)
+ @announcements = Announcement.find_published(true)
+ else
+ @announcements = Announcement.find_published
+ end
end
def check_viewability
diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb
--- a/app/controllers/site_controller.rb
+++ b/app/controllers/site_controller.rb
@@ -1,6 +1,28 @@
class SiteController < ApplicationController
- before_filter :site_admin_authorization
+ before_filter :site_admin_authorization, :except => 'login'
+
+ def login
+ # Site administrator login
+ @countries = Country.find(:all, :include => :sites)
+ @country_select = @countries.collect { |c| [c.name, c.id] }
+
+ @country_select_with_all = [['Any',0]]
+ @countries.each do |country|
+ @country_select_with_all << [country.name, country.id]
+ end
+
+ @site_select = []
+ @countries.each do |country|
+ country.sites.each do |site|
+ @site_select << ["#{site.name}, #{country.name}", site.id]
+ end
+ end
+
+ @default_site = Site.first if !Configuration['contest.multisites']
+
+ render :action => 'login', :layout => 'empty'
+ end
def index
if @site.started
@@ -25,7 +47,7 @@
protected
def site_admin_authorization
if session[:site_id]==nil
- redirect_to :controller => 'main', :action => 'login' and return
+ redirect_to :controller => 'site', :action => 'login' and return
end
begin
@site = Site.find(session[:site_id], :include => :country)
@@ -33,7 +55,7 @@
@site = nil
end
if @site==nil
- redirect_to :controller => 'main', :action => 'login' and return
+ redirect_to :controller => 'site', :action => 'login' and return
end
end
diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb
--- a/app/controllers/test_controller.rb
+++ b/app/controllers/test_controller.rb
@@ -99,7 +99,12 @@
@problems << problem
end
end
- @test_requests = @user.test_requests
+ @test_requests = []
+ @user.test_requests.each do |ts|
+ if ts.problem.available
+ @test_requests << ts
+ end
+ end
end
def check_viewability
diff --git a/app/controllers/user_admin_controller.rb b/app/controllers/user_admin_controller.rb
--- a/app/controllers/user_admin_controller.rb
+++ b/app/controllers/user_admin_controller.rb
@@ -13,6 +13,7 @@
def list
@users = User.find(:all)
+ @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
end
def show
@@ -77,8 +78,7 @@
@scorearray = Array.new
@users.each do |u|
ustat = Array.new
- ustat[0] = u.login
- ustat[1] = u.full_name
+ ustat[0] = u
@problems.each do |p|
sub = Submission.find_last_by_user_and_problem(u.id,p.id)
if (sub!=nil) and (sub.points!=nil)
@@ -152,7 +152,12 @@
u.password = user[:password]
u.country = countries[user[:country_id]]
u.site = sites[user[:site_id]]
- u.save
+ u.activated = true
+ u.email = "empty-#{u.login}@none.com"
+ if not u.save
+ @import_log << "Errors\n"
+ u.errors.each { |attr,msg| @import_log << "#{attr} - #{msg}\n" }
+ end
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -5,11 +5,13 @@
before_filter :authenticate, :except => [:new, :register, :confirm]
+ before_filter :verify_online_registration, :only => [:new, :register]
+
verify :method => :post, :only => [:chg_passwd],
:redirect_to => { :action => :index }
- in_place_edit_for :user, :alias_for_editing
- in_place_edit_for :user, :email_for_editing
+ #in_place_edit_for :user, :alias_for_editing
+ #in_place_edit_for :user, :email_for_editing
def index
if !Configuration['system.user_setting_enabled']
@@ -37,6 +39,10 @@
end
def register
+ if(params[:cancel])
+ redirect_to :controller => 'main', :action => 'login'
+ return
+ end
@user = User.new(params[:user])
@user.password_confirmation = @user.password = User.random_password
@user.activated = false
@@ -44,6 +50,7 @@
if send_confirmation_email(@user)
render :action => 'new_splash', :layout => 'empty'
else
+ @admin_email = Configuration['system.admin_email']
render :action => 'email_error', :layout => 'empty'
end
else
@@ -72,8 +79,15 @@
protected
+ def verify_online_registration
+ if !Configuration['system.online_registration']
+ redirect_to :controller => 'main', :action => 'login'
+ end
+ end
+
def send_confirmation_email(user)
contest_name = Configuration['contest.name']
+ admin_email = Configuration['system.admin_email']
activation_url = url_for(:action => 'confirm',
:login => user.login,
:activation => user.activation_key)
@@ -82,22 +96,16 @@
mail.to = user.email
mail.from = Configuration['system.online_registration.from']
mail.subject = "[#{contest_name}] Confirmation"
- mail.body = <<-EOF
-Hello #{user.full_name},
-
-You have registered for #{contest_name} (#{home_url}).
-
-Your login is: #{user.login}
-Your password is: #{user.password}
+ mail.body = t('registration.email_body', {
+ :full_name => user.full_name,
+ :contest_name => contest_name,
+ :login => user.login,
+ :password => user.password,
+ :activation_url => activation_url,
+ :admin_email => admin_email
+ })
-Please follow the link:
-#{activation_url}
-to activate your user account.
-
-If you did not register, please ignore this e-mail.
-
-Thanks!
-EOF
+ logger.info mail.body
smtp_server = Configuration['system.online_registration.smtp']
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -14,27 +14,28 @@
append_to menu_items, '[Msg console]', 'messages', 'console'
append_to menu_items, '[Problem admin]', 'problems', 'index'
append_to menu_items, '[User admin]', 'user_admin', 'index'
- append_to menu_items, '[User stat]', 'user_admin', 'user_stat'
+ append_to menu_items, '[Results]', 'user_admin', 'user_stat'
append_to menu_items, '[Graders]', 'graders', 'list'
- append_to menu_items, '[Site config]', 'configurations', 'index'
+ append_to menu_items, '[Sites]', 'sites', 'index'
+ append_to menu_items, '[System config]', 'configurations', 'index'
menu_items << "
"
end
# main page
- append_to menu_items, '[Main]', 'main', 'list'
- append_to menu_items, '[Messages]', 'messages', 'list'
+ append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
+ append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
if (user!=nil) and (Configuration.show_tasks_to?(user))
- append_to menu_items, '[Tasks]', 'tasks', 'list'
- append_to menu_items, '[Submissions]', 'main', 'submission'
- append_to menu_items, '[Test]', 'test', 'index'
+ append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
+ append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
+ append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
end
- append_to menu_items, '[Help]', 'main', 'help'
+ append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
if Configuration['system.user_setting_enabled']
- append_to menu_items, '[Settings]', 'users', 'index'
+ append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
end
- append_to menu_items, '[Log out]', 'main', 'login'
+ append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
menu_items
end
@@ -78,8 +79,13 @@
CONTEST_OVER
end
- if user.site!=nil
- time_left = ". Time left: #{Time.at(user.site.time_left).gmtime.strftime("%X")}"
+ if !user.site.started
+ time_left = " " + (t 'title_bar.contest_not_started')
+ else
+ if user.site!=nil
+ time_left = " " + (t 'title_bar.remaining_time') +
+ " #{Time.at(user.site.time_left).gmtime.strftime("%X")}"
+ end
end
end
@@ -104,7 +110,7 @@
+ Show only in contest?
+ <%= f.check_box :contest_only %>
+
<%= f.submit "Update" %>
<% end %> diff --git a/app/views/announcements/index.html.erb b/app/views/announcements/index.html.erb --- a/app/views/announcements/index.html.erb +++ b/app/views/announcements/index.html.erb @@ -1,5 +1,4 @@ <% content_for :head do %> - <%= stylesheet_link_tag 'scaffold' %> <%= javascript_include_tag :defaults %> <% end %> diff --git a/app/views/announcements/new.html.erb b/app/views/announcements/new.html.erb --- a/app/views/announcements/new.html.erb +++ b/app/views/announcements/new.html.erb @@ -24,6 +24,11 @@
+ Show only in contest?
+ <%= f.check_box :contest_only %>
+
<%= f.submit "Create" %>
<% end %> diff --git a/app/views/announcements/show.html.erb b/app/views/announcements/show.html.erb --- a/app/views/announcements/show.html.erb +++ b/app/views/announcements/show.html.erb @@ -18,6 +18,10 @@ <%=h @announcement.frontpage %> ++ Show only in contest: + <%=h @announcement.contest_only %> +
<%= link_to 'Edit', edit_announcement_path(@announcement) %> | <%= link_to 'Back', announcements_path %> diff --git a/app/views/configurations/index.html.haml b/app/views/configurations/index.html.haml --- a/app/views/configurations/index.html.haml +++ b/app/views/configurations/index.html.haml @@ -1,7 +1,7 @@ - content_for :head do = javascript_include_tag :defaults -%h1 Grader configuration +%h1 System configuration %table.info %tr.info-head @@ -19,12 +19,13 @@ %td = in_place_editor_field :configuration, :value, {}, :rows=>1 -%br/ -Your config is saved, but it does not automatically take effect. -%br/ -If you have one mongrel process running, you can -= link_to '[click]', :action => 'reload' -here to reload. -%br/ -If you have more than one process running, you should restart -them manually. +- if Configuration.cache? + %br/ + Your config is saved, but it does not automatically take effect. + %br/ + If you have one mongrel process running, you can + = link_to '[click]', :action => 'reload' + here to reload. + %br/ + If you have more than one process running, you should restart + them manually. diff --git a/app/views/graders/list.html.haml b/app/views/graders/list.html.haml --- a/app/views/graders/list.html.haml +++ b/app/views/graders/list.html.haml @@ -2,18 +2,20 @@ = stylesheet_link_tag 'graders' -%h2 (Under Experiments) +%h1 Grader information - form_for :clear, nil, :url => {:action => 'clear_all'} do |f| = submit_tag 'Clear all data' -Last task: -= link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' +- if @last_task + Last task: + = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' -%br/ + %br/ -Last test_request: -= link_to "#{@last_test_request.id}", :action => 'view', :id => @last_test_request.id, :type => 'TestRequest' +- if @last_test_request + Last test_request: + = link_to "#{@last_test_request.id}", :action => 'view', :id => @last_test_request.id, :type => 'TestRequest' %h3 Current graders diff --git a/app/views/layouts/sites.html.erb b/app/views/layouts/sites.html.erb deleted file mode 100644 --- a/app/views/layouts/sites.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -<%= flash[:notice] %>
- -<%= yield %> - - - diff --git a/app/views/main/_announcement.html.haml b/app/views/main/_announcement.html.haml --- a/app/views/main/_announcement.html.haml +++ b/app/views/main/_announcement.html.haml @@ -1,4 +1,4 @@ .announcement = markdown(announcement.body) - .pub-info - %p= "#{announcement.author}, #{announcement.created_at}" + -#.pub-info + -# %p= "#{announcement.author}, #{announcement.created_at}" diff --git a/app/views/main/_problem.html.erb b/app/views/main/_problem.html.erb --- a/app/views/main/_problem.html.erb +++ b/app/views/main/_problem.html.erb @@ -4,7 +4,7 @@
+ Password
+ <%= f.text_field :password %>
+
Started
<%= f.check_box :started %>
Name | +Password | Started | Start time | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%=h site.name %> | +<%=h site.password %> | <%=h site.started %> | <%=h site.start_time %> | <%= link_to 'Show', site %> | diff --git a/app/views/sites/new.html.erb b/app/views/sites/new.html.erb --- a/app/views/sites/new.html.erb +++ b/app/views/sites/new.html.erb @@ -9,6 +9,11 @@|||||||||||
- Additional file*: - | -- <%= f.file_field :additional_file %> - | -
-
- * This option works only for task beads.
- You can use this to submit questions.txt. - The file shall be copied to the execution directory before your program runs. - - |
- |||||||||||||
<%= submit_tag 'submit' %> | diff --git a/app/views/test/result.html.haml b/app/views/test/result.html.haml --- a/app/views/test/result.html.haml +++ b/app/views/test/result.html.haml @@ -27,12 +27,14 @@ %div{:style => "border: 1px solid black; background: lightgrey"} - if @test_request.input_file_name!=nil %pre + = "" = h(read_textfile(@test_request.input_file_name,2048)) %b Output (first 2kb) %div{:style => "border: 1px solid black; background: lightgrey"} - if @test_request.output_file_name!=nil %pre + = "" = h(read_textfile(@test_request.output_file_name,2048)) - else (no output) diff --git a/app/views/user_admin/_form.rhtml b/app/views/user_admin/_form.rhtml --- a/app/views/user_admin/_form.rhtml +++ b/app/views/user_admin/_form.rhtml @@ -13,6 +13,9 @@|||||||||||||||
- | - | + | + | ||||||||||||
<%= text_field 'user', 'login', :size => 10 %> | <%= text_field 'user', 'full_name', :size => 30 %> | -<%= text_field 'user', 'alias', :size => 10 %> | <%= password_field 'user', 'password', :size => 10 %> | <%= password_field 'user', 'password_confirmation', :size => 10 %> | +<%= text_field 'user', 'email', :size => 15 %> | <%= submit_tag "Create" %> |
<%= column.human_name %> | + <% if !@hidden_columns.index(column.name) %> +<%= column.human_name %> | + <% end %> <% end %>|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%=h user.send(column.name) %> | + <% if !@hidden_columns.index(column.name) %> +<%=h user.send(column.name) %> | + <% end %> <% end %><%= link_to 'Show', :action => 'show', :id => user %> | <%= link_to 'Edit', :action => 'edit', :id => user %> | diff --git a/app/views/user_admin/user_stat.rhtml b/app/views/user_admin/user_stat.rhtml --- a/app/views/user_admin/user_stat.rhtml +++ b/app/views/user_admin/user_stat.rhtml @@ -1,7 +1,10 @@
User | Name | +|||||||
---|---|---|---|---|---|---|---|---|
User | +Name | +Activated? | <% @problems.each do |p| %><%= p.name %> | <% end %> @@ -14,8 +17,10 @@ <% total = 0 %> <% num_passed = 0 %> <% sc.each_index do |i| %> - <% if i<=1 %> -<%= sc[i] %> | + <% if i==0 %> +<%= sc[i].login %> | +<%= sc[i].full_name %> | +<%= sc[i].activated %> | <% else %><%= sc[i][0] %> | <% total += sc[i][0] %> diff --git a/app/views/users/confirm.html.haml b/app/views/users/confirm.html.haml --- a/app/views/users/confirm.html.haml +++ b/app/views/users/confirm.html.haml @@ -1,15 +1,17 @@ - if @result == :successful - %h1 User activated - Your account has been activated. + %h1 + =t 'registration.activation_sucessful_title' + =t 'registration.account_activated' %br/ - Please go ahead to - = link_to 'login.', :controller => 'main', :action => 'login' + =t 'go_ahead_to' + = link_to((t 'login_page'), {:controller => 'main', :action => 'login'}) - else - %h1 Activation failed + %h1 + =t 'registration.activation_failed_title' - if @result == :email_used - A user with this E-mail exists. + =t 'registration.errors.activation.email_exists' - else - Your activation code is invalid. Please check again. + =t 'registration.errors.activation.invalid' %br/ - Get back to - = link_to 'home.', :controller => 'main', :action => 'login' + =t 'go_back_to' + = link_to((t 'home_page'), {:controller => 'main', :action => 'login'}) diff --git a/app/views/users/email_error.html.haml b/app/views/users/email_error.html.haml --- a/app/views/users/email_error.html.haml +++ b/app/views/users/email_error.html.haml @@ -1,9 +1,8 @@ -%h1 Errors in sending registration confirmation +%h1 + =t 'registration.errors.email.title' .errorExplanation - %h2 - Your user account has been created, but the system cannot send you the - confirmation e-mail. + =t 'registration.errors.email.expl', :email => @admin_email - Maybe there's a problem in the configuration. Please report the - admin. Thank you! +=t 'go_back_to' +=link_to((t 'login_page'), {:controller => 'main', :action => 'login'}) diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -5,9 +5,8 @@ %h1 Your account settings -%p - You can edit your alias and e-mails. Just click on the text and edit it. - +-#%p + -#You can edit your alias and e-mails. Just click on the text and edit it. %table.uinfo %tr @@ -16,12 +15,12 @@ %tr %th.uinfo Full name %td.uinfo= @user.full_name - %tr - %th.uinfo Alias - %td.uinfo= in_place_editor_field :user, 'alias_for_editing', {}, :rows => 1 - %tr - %th.uinfo E-mail - %td.uinfo= in_place_editor_field :user, 'email_for_editing', {}, :rows => 1 + -#%tr + -#%th.uinfo Alias + -#%td.uinfo= in_place_editor_field :user, 'alias_for_editing', {}, :rows => 1 + -#%tr + -#%th.uinfo E-mail + -#%td.uinfo= in_place_editor_field :user, 'email_for_editing', {}, :rows => 1 %tr %th.uinfo Password %td.uinfo diff --git a/app/views/users/new.html.haml b/app/views/users/new.html.haml --- a/app/views/users/new.html.haml +++ b/app/views/users/new.html.haml @@ -1,29 +1,39 @@ -%h1 New user registration +.contest-title + %h1 + = "#{Configuration['contest.name']}: #{t 'registration.title'}" -= error_messages_for :user, :header_message => 'Errors occured during registration' +.registration-desc + =t 'registration.description' + += error_messages_for :user, :header_message => (t 'registration.errors.header') %table - form_for :user, @user, :url => { :action => 'register' } do |f| %tr - %td Login: + %td{:align => "right"} + = "#{t 'login_label'}:" %td= f.text_field :login %tr %td %td - %small Only a-z, A-Z, 0-9 and _ + %small + =t 'registration.login_guide' %tr - %td Full name: + %td{:align => "right"} + = "#{t 'full_name_label'}:" %td= f.text_field :full_name %tr - %td E-mail: + %td{:align => "right"} + = "#{t 'email_label'}:" %td= f.text_field :email %tr %td %td %small - Please make sure that your e-mail is correct. - %br/ - You'll need to verify your account by email. + =t 'registration.email_guide' %tr - %td{:colspan => 2}= submit_tag "Register" + %td/ + %td + = submit_tag((t 'registration.register'), :name => 'commit') + = submit_tag((t 'cancel'), :name => 'cancel') diff --git a/app/views/users/new_splash.html.haml b/app/views/users/new_splash.html.haml --- a/app/views/users/new_splash.html.haml +++ b/app/views/users/new_splash.html.haml @@ -1,11 +1,11 @@ -%h1 Registration successful +%h1 + =t 'registration.successful_title' -We have sent a confimation message to your e-mail. +=t 'registration.email_sent' %br/ -Please check at -= "#{@user.email}." +=t 'registration.email_verify_at', :email => @user.email %br/ %br/ -Go back to -= link_to 'login page.', :controller => 'main', :action => 'login' +=t 'go_back_to' +=link_to((t 'login_page'), {:controller => 'main', :action => 'login'}) diff --git a/config/environment.rb.SAMPLE b/config/environment.rb.SAMPLE --- a/config/environment.rb.SAMPLE +++ b/config/environment.rb.SAMPLE @@ -5,7 +5,7 @@ # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION +RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') @@ -39,19 +39,23 @@ # config.active_record.observers = :cacher, :garbage_collector # Make Active Record use UTC-base instead of local time - config.active_record.default_timezone = :utc + config.time_zone = 'UTC' + # Setting locales + config.i18n.default_locale = 'th' + # See Rails::Configuration for more options # ------------- # Required gems # ------------- - - # This is for rspec - config.gem "rspec-rails", :lib => "spec" config.gem "haml" config.gem "tmail" - #config.gem "BlueCloth", :lig => "bluecloth" + config.gem "BlueCloth", :lib => "bluecloth" + + # NOTES on rspec: if you wan to test with rspec, you have to install + # rspec yourself, just call: [sudo] gem install rspec-rails + end # Add new inflection rules using the following format @@ -73,5 +77,13 @@ TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' +# To use ANALYSIS MODE, provide the testcases/testruns breakdown, +# and the directory of the grading result (usually in judge's dir). +TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' +GRADING_RESULT_DIR = '/home/thailandoi/ytopc/judge/result' + # Uncomment so that configuration is read only once when the server is loaded # Configuration.enable_caching + +# Uncomment so that the system validates user e-mails +# VALIDATE_USER_EMAILS = true diff --git a/config/environments/development.rb b/config/environments/development.rb --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -14,7 +14,6 @@ # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false -config.action_view.cache_template_extensions = false config.action_view.debug_rjs = true # Don't care if the mailer can't send diff --git a/config/environments/test.rb b/config/environments/test.rb --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -16,4 +16,4 @@ # Tell ActionMailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test \ No newline at end of file +config.action_mailer.delivery_method = :test diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,118 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + cancel: 'Cancel' + + login_label: 'Login' + full_name_label: 'Full name' + email_label: 'E-mail' + password_label: 'Password' + + go_ahead_to: "Go ahead to" + go_back_to: "Go back to" + login_page: "login page" + home_page: "home page" + + menu: + main: 'Main' + messages: 'Messages' + tasks: 'Tasks' + submissions: 'Submissions' + test: 'Test Interface' + help: 'Help' + settings: 'Settings' + log_out: 'Log out' + + title_bar: + current_time: "Current time is" + remaining_time: "Time left: " + contest_not_started: "The contest has not started." + + login: + message: 'Please login to see the problem list' + login_submit: 'Login' + participation: 'Want to participate?' + please: 'Please' + register: 'register' + + main: + start_soon: "The contest at your site will start soon. Please wait." + specified_in_header: "Specified in header" + + problem_desc: "desc" + submitted_at: "Submitted at" + graded_at: "Graded at" + score: "score: " + cmp_msg: "compiler msg" + src_link: "src" + submissions_link: "submissions" + + test: + title: "Test Interface" + intro: "You can test your submission with your own test data on the grading environment using this test interface." + disabled_at_end_announcement: "Note: Test interface will be disabled in the last 30 minutes of the contest time on your site." + + registration: + title: "New user registration" + successful_title: "Registration successful" + + login_guide: "Only a-z, A-Z, 0-9 and _. Can be at most 20 characters long" + email_guide: "Please make sure that your e-mail is correct.