diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '3.2.19' +gem 'rails', '3.2.21' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' @@ -10,13 +10,13 @@ # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' + gem 'sass-rails', '~> 3.2.6' + gem 'coffee-rails', '~> 3.2.2' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby - gem 'uglifier', '>= 1.0.3' + gem 'uglifier' end gem 'prototype-rails' @@ -49,15 +49,15 @@ #syntax highlighter gem 'rouge' -gem "haml" -gem "mail" -gem "rdiscount" -gem "test-unit" -gem 'will_paginate', '~> 3.0.0' +gem 'haml' +gem 'mail' +gem 'rdiscount' +gem 'test-unit' +gem 'will_paginate', '~> 3.0.7' gem 'dynamic_form' gem 'in_place_editing' -gem 'verification', :git => 'git://github.com/sikachu/verification.git' +gem 'verification', :git => 'https://github.com/sikachu/verification.git' group :test, :development do - gem "rspec-rails", "~> 2.0" + gem 'rspec-rails', '~> 2.99.0' end diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GIT - remote: git://github.com/sikachu/verification.git + remote: https://github.com/sikachu/verification.git revision: 76eaf51b13276ecae54bd9cd115832595d2ff56d specs: verification (1.0.3) @@ -9,12 +9,12 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.19) - actionpack (= 3.2.19) + actionmailer (3.2.21) + actionpack (= 3.2.21) mail (~> 2.5.4) - actionpack (3.2.19) - activemodel (= 3.2.19) - activesupport (= 3.2.19) + actionpack (3.2.21) + activemodel (= 3.2.21) + activesupport (= 3.2.21) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) @@ -22,22 +22,22 @@ rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) - activemodel (3.2.19) - activesupport (= 3.2.19) + activemodel (3.2.21) + activesupport (= 3.2.21) builder (~> 3.0.0) - activerecord (3.2.19) - activemodel (= 3.2.19) - activesupport (= 3.2.19) + activerecord (3.2.21) + activemodel (= 3.2.21) + activesupport (= 3.2.21) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.19) - activemodel (= 3.2.19) - activesupport (= 3.2.19) - activesupport (3.2.19) + activeresource (3.2.21) + activemodel (= 3.2.21) + activesupport (= 3.2.21) + activesupport (3.2.21) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) arel (3.0.3) - best_in_place (3.0.2) + best_in_place (3.0.3) actionpack (>= 3.2) railties (>= 3.2) builder (3.0.4) @@ -47,21 +47,21 @@ coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.7.1) + coffee-script-source (1.9.0) diff-lcs (1.2.5) dynamic_form (1.1.4) erubis (2.7.0) - execjs (2.2.1) - haml (4.0.5) + execjs (2.3.0) + haml (4.0.6) tilt hike (1.2.3) - i18n (0.6.11) + i18n (0.7.0) in_place_editing (1.2.0) journey (1.0.4) - jquery-rails (3.1.1) + jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-tablesorter (1.12.7) + jquery-tablesorter (1.13.4) railties (>= 3.1, < 5) jquery-timepicker-addon-rails (1.4.1) railties (>= 3.1) @@ -72,15 +72,15 @@ jquery-rails jquery-ui-rails (= 4.0.3) railties (>= 3.1.0) - json (1.8.1) + json (1.8.2) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) multi_json (1.10.1) - mysql2 (0.3.16) + mysql2 (0.3.17) polyglot (0.3.5) - power_assert (0.1.3) + power_assert (0.2.2) prototype-rails (3.2.1) rails (~> 3.2) rack (1.4.5) @@ -88,34 +88,34 @@ rack (>= 0.4) rack-ssl (1.3.4) rack - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) - rails (3.2.19) - actionmailer (= 3.2.19) - actionpack (= 3.2.19) - activerecord (= 3.2.19) - activeresource (= 3.2.19) - activesupport (= 3.2.19) + rails (3.2.21) + actionmailer (= 3.2.21) + actionpack (= 3.2.21) + activerecord (= 3.2.21) + activeresource (= 3.2.21) + activesupport (= 3.2.21) bundler (~> 1.0) - railties (= 3.2.19) - railties (3.2.19) - actionpack (= 3.2.19) - activesupport (= 3.2.19) + railties (= 3.2.21) + railties (3.2.21) + actionpack (= 3.2.21) + activesupport (= 3.2.21) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (10.3.2) - rdiscount (2.1.7.1) + rake (10.4.2) + rdiscount (2.1.8) rdoc (3.12.2) json (~> 1.4) - rouge (1.6.2) - rspec-collection_matchers (1.0.0) + rouge (1.8.0) + rspec-collection_matchers (1.1.2) rspec-expectations (>= 2.99.0.beta1) rspec-core (2.99.2) rspec-expectations (2.99.2) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.2) + rspec-mocks (2.99.3) rspec-rails (2.99.0) actionpack (>= 3.0) activemodel (>= 3.0) @@ -125,25 +125,25 @@ rspec-core (~> 2.99.0) rspec-expectations (~> 2.99.0) rspec-mocks (~> 2.99.0) - sass (3.4.1) + sass (3.4.11) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - sprockets (2.2.2) + sprockets (2.2.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - test-unit (3.0.1) + test-unit (3.0.9) power_assert thor (0.19.1) tilt (1.4.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.41) - uglifier (2.5.3) + tzinfo (0.3.43) + uglifier (2.7.0) execjs (>= 0.3.0) json (>= 1.8.0) will_paginate (3.0.7) @@ -153,7 +153,7 @@ DEPENDENCIES best_in_place (~> 3.0.1) - coffee-rails (~> 3.2.1) + coffee-rails (~> 3.2.2) dynamic_form haml in_place_editing @@ -164,12 +164,12 @@ mail mysql2 prototype-rails - rails (= 3.2.19) + rails (= 3.2.21) rdiscount rouge - rspec-rails (~> 2.0) - sass-rails (~> 3.2.3) + rspec-rails (~> 2.99.0) + sass-rails (~> 3.2.6) test-unit - uglifier (>= 1.0.3) + uglifier verification! - will_paginate (~> 3.0.0) + will_paginate (~> 3.0.7) diff --git a/app/controllers/contest_management_controller.rb b/app/controllers/contest_management_controller.rb --- a/app/controllers/contest_management_controller.rb +++ b/app/controllers/contest_management_controller.rb @@ -37,7 +37,7 @@ end def change_contest_mode - if ['standard', 'contest', 'indv-contest'].include? params[:id] + if ['standard', 'contest', 'indv-contest', 'analysis'].include? params[:id] config = GraderConfiguration.find_by_key('system.mode') config.value = params[:id] config.save 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 @@ -71,7 +71,7 @@ @submission.ip_address = request.remote_ip if GraderConfiguration.time_limit_mode? and user.contest_finished? - @submission.errors.add_to_base "The contest is over." + @submission.errors.add(:base,"The contest is over.") prepare_list_information render :action => 'list' and return end @@ -194,7 +194,7 @@ def confirm_contest_start user = User.find(session[:user_id]) - if request.method == :post + if request.method == 'POST' user.update_start_time redirect_to :action => 'list' else diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -31,20 +31,21 @@ user = User.find(session[:user_id]) @message = Message.new(params[:message]) @message.sender = user - if !@message.save - render :action => 'list' and return + if @message.body == '' or !@message.save + flash[:notice] = 'An error occurred' else flash[:notice] = 'New message posted' - redirect_to :action => 'list' end + redirect_to :action => 'list' end def reply user = User.find(session[:user_id]) @message = Message.new(params[:r_message]) @message.sender = user - if !@message.save - render :action => 'show' and return + if @message.body == '' or !@message.save + flash[:notice] = 'An error occurred' + redirect_to :action => 'show', :id => @message.replying_message_id else flash[:notice] = 'Message replied' rep_msg = @message.replying_message @@ -58,7 +59,7 @@ message = Message.find(params[:id]) message.replied = true message.save - flash[:notice] = 'Message hided (just marked replied)' + flash[:notice] = 'Message hidden (just marked replied)' redirect_to :action => 'console' 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 @@ -26,7 +26,7 @@ if GraderConfiguration.time_limit_mode? if @user.contest_finished? - @submitted_test_request.errors.add_to_base('Contest is over.') + @submitted_test_request.errors.add(:base,'Contest is over.') prepare_index_information render :action => 'index' and return end 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 @@ -2,7 +2,6 @@ class UserAdminController < ApplicationController - include MailHelperMethods before_filter :admin_authorization @@ -151,13 +150,6 @@ end @scorearray << ustat end - - if params[:commit] == 'download csv' then - csv = gen_csv_from_scorearray(@scorearray,@problems) - send_data csv, filename: 'last_score.csv' - else - render template: 'user_admin/user_stat' - end end def user_stat_max 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 @@ -63,7 +63,7 @@ render :action => 'email_error', :layout => 'empty' end else - @user.errors.add_to_base("Email cannot be blank") if @user.email=='' + @user.errors.add(:base,"Email cannot be blank") if @user.email=='' render :action => 'new', :layout => 'empty' end end @@ -154,7 +154,7 @@ :login => user.login, :password => user.password, :activation_url => activation_url, - :admin_email => admin_email + :admin_email => GraderConfiguration['system.admin_email'] }) logger.info mail_body @@ -170,7 +170,7 @@ :contest_name => contest_name, :login => user.login, :password => user.password, - :admin_email => admin_email + :admin_email => GraderConfiguration['system.admin_email'] }) logger.info mail_body 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 @@ -118,7 +118,7 @@ #{user.full_name}
-#{t 'title_bar.current_time'} #{format_short_time(Time.new)} +#{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} #{time_left}
diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -45,7 +45,7 @@ import_params[:memory_limit], import_params[:checker_name], import_to_db) - problem.errors.add_to_base('Import error.') + problem.errors.add(:base,'Import error.') end return problem, importer.log_msg @@ -85,17 +85,17 @@ DEFAULT_MEMORY_LIMIT) if time_limit<=0 or time_limit >60 - problem.errors.add_to_base('Time limit out of range.') + problem.errors.add(:base,'Time limit out of range.') end if memory_limit==0 and params[:memory_limit]!='0' - problem.errors.add_to_base('Memory limit format errors.') + problem.errors.add(:base,'Memory limit format errors.') elsif memory_limit<=0 or memory_limit >512 - problem.errors.add_to_base('Memory limit out of range.') + problem.errors.add(:base,'Memory limit out of range.') end if params[:file]==nil or params[:file]=='' - problem.errors.add_to_base('No testdata file.') + problem.errors.add(:base,'No testdata file.') end checker_name = 'text' diff --git a/app/models/test_request.rb b/app/models/test_request.rb --- a/app/models/test_request.rb +++ b/app/models/test_request.rb @@ -70,12 +70,12 @@ # checks if the user submits any input file if params[:input_file]==nil or params[:input_file]=="" - test_request.errors.add_to_base("No input submitted.") + test_request.errors.add(:base,"No input submitted.") test_request.input_file_name = nil else test_request.input_file_name = save_input_file(params[:input_file], user, problem) if test_request.input_file_name == nil - test_request.errors.add_to_base("No input submitted.") + test_request.errors.adds(:base,"No input submitted.") end if params[:additional_file]!=nil and params[:additional_file]!="" save_additional_file(params[:additional_file], diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,11 +67,6 @@ user = find_by_login(login) if user return user if user.authenticated?(password) - if user.authenticated_by_cucas?(password) or user.authenticated_by_pop3?(password) - user.password = password - user.save - return user - end end end @@ -83,48 +78,6 @@ end end - def authenticated_by_pop3?(password) - Net::POP3.enable_ssl - pop = Net::POP3.new('pops.it.chula.ac.th') - authen = true - begin - pop.start(login, password) - pop.finish - return true - rescue - return false - end - end - - def authenticated_by_cucas?(password) - url = URI.parse('https://www.cas.chula.ac.th/cas/api/?q=studentAuthenticate') - appid = '41508763e340d5858c00f8c1a0f5a2bb' - appsecret ='d9cbb5863091dbe186fded85722a1e31' - post_args = { - 'appid' => appid, - 'appsecret' => appsecret, - 'username' => login, - 'password' => password - } - - #simple call - begin - http = Net::HTTP.new('www.cas.chula.ac.th', 443) - http.use_ssl = true - result = [ ] - http.start do |http| - req = Net::HTTP::Post.new('/cas/api/?q=studentAuthenticate') - param = "appid=#{appid}&appsecret=#{appsecret}&username=#{login}&password=#{password}" - resp = http.request(req,param) - result = JSON.parse resp.body - end - return true if result["type"] == "beanStudent" - rescue - return false - end - return false - end - def admin? self.roles.detect {|r| r.name == 'admin' } end @@ -351,7 +304,7 @@ def uniqueness_of_email_from_activated_users user = User.activated_users.find_by_email(self.email) if user and (user.login != self.login) - self.errors.add_to_base("Email has already been taken") + self.errors.add(:base,"Email has already been taken") end end @@ -362,7 +315,7 @@ :order => 'created_at DESC') if open_user and open_user.created_at and (open_user.created_at > Time.now.gmtime - 5.minutes) - self.errors.add_to_base("There are already unactivated registrations with this e-mail address (please wait for 5 minutes)") + self.errors.add(:base,"There are already unactivated registrations with this e-mail address (please wait for 5 minutes)") end end diff --git a/app/views/contest_management/index.html.haml b/app/views/contest_management/index.html.haml --- a/app/views/contest_management/index.html.haml +++ b/app/views/contest_management/index.html.haml @@ -11,18 +11,21 @@ .infobox %b Web interface mode: - - if (not GraderConfiguration.contest_mode?) and (not GraderConfiguration.indv_contest_mode?) - standard mode + - if GraderConfiguration.analysis_mode? + Analysis Mode + - elsif (not GraderConfiguration.contest_mode?) and (not GraderConfiguration.indv_contest_mode?) + Standard Mode - elsif GraderConfiguration.contest_mode? - normal contest mode. + Normal Contest Mode - else - individual contest mode. + Individual Contest Mode %br/ Change mode to: - =raw "[#{link_to 'standard', :action => 'change_contest_mode', :id => 'standard'}]" - =raw "[#{link_to 'contest', :action => 'change_contest_mode', :id => 'contest'}]" - =raw "[#{link_to 'individual contest', :action => 'change_contest_mode', :id => 'indv-contest'}]" + =raw "[#{link_to 'Standard', :action => 'change_contest_mode', :id => 'standard'}]" + =raw "[#{link_to 'Contest', :action => 'change_contest_mode', :id => 'contest'}]" + =raw "[#{link_to 'Individual Contest', :action => 'change_contest_mode', :id => 'indv-contest'}]" + =raw "[#{link_to 'Analysis', :action => 'change_contest_mode', :id => 'analysis'}]" - if GraderConfiguration.indv_contest_mode? = render :partial => 'indv_contest_mode_index' diff --git a/app/views/graders/test_request.html.haml b/app/views/graders/test_request.html.haml --- a/app/views/graders/test_request.html.haml +++ b/app/views/graders/test_request.html.haml @@ -25,7 +25,7 @@ - if @test_request.compiler_message!=nil and @test_request.compiler_message!='' %b Compiler Message %div{:style => "border: 1px solid black; background: lightgrey"} - = simple_format(truncate((@test_request.compiler_message or ''),200)) + = simple_format(truncate((@test_request.compiler_message or ''), :length => 200)) %b Input (first 2kb) %div{:style => "border: 1px solid black; background: lightgrey"} diff --git a/app/views/main/_compiler_message.html.erb b/app/views/main/_compiler_message.html.erb --- a/app/views/main/_compiler_message.html.erb +++ b/app/views/main/_compiler_message.html.erb @@ -1,5 +1,5 @@ -<% if compiler_message==nil or compiler_message=='' %> +<% if compiler_message == nil or compiler_message.chomp == '' %> No message <% else %>
'confirm_contest_start', :method => 'post' do + = form_tag :action => 'confirm_contest_start' do = submit_tag t('main.confirm_contest_start.start_button'), :confirm => t('main.confirm_contest_start.start_button_confirm') diff --git a/app/views/user_admin/_form.html.erb b/app/views/user_admin/_form.html.erb --- a/app/views/user_admin/_form.html.erb +++ b/app/views/user_admin/_form.html.erb @@ -14,7 +14,7 @@ <%= password_field 'user', 'password_confirmation' %>


-<%= text_field 'user', 'email' %>

+<%= email_field 'user', 'email' %>


<%= text_field 'user', 'alias' %>

diff --git a/app/views/user_admin/list.html.erb b/app/views/user_admin/list.html.erb --- a/app/views/user_admin/list.html.erb +++ b/app/views/user_admin/list.html.erb @@ -16,7 +16,7 @@ <%= text_field 'user', 'full_name', :size => 30 %> <%= password_field 'user', 'password', :size => 10 %> <%= password_field 'user', 'password_confirmation', :size => 10 %> - <%= text_field 'user', 'email', :size => 15 %> + <%= email_field 'user', 'email', :size => 15 %> <%= submit_tag "Create" %> diff --git a/app/views/users/forget.html.haml b/app/views/users/forget.html.haml --- a/app/views/users/forget.html.haml +++ b/app/views/users/forget.html.haml @@ -11,7 +11,8 @@ = form_tag :action => 'retrieve_password' do =t 'registration.password_retrieval.instructions' - = text_field 'email', nil, :size => 20 + %br/ + = email_field 'email', nil, :size => 20 %br/ = submit_tag(t 'registration.password_retrieval.button_label') 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 @@ -25,12 +25,12 @@ %tr %td{:align => "right"} = "#{t 'email_label'}:" - %td= f.text_field :email + %td= f.email_field :email %tr %td %td %small - =t 'registration.email_guide' + =t('registration.email_guide').html_safe %tr %td/ %td diff --git a/config/environments/development.rb b/config/environments/development.rb --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -34,4 +34,7 @@ # Expands the lines which load the assets config.assets.debug = true + + # Prevents assets from rendering twice + config.serve_static_assets = false end diff --git a/config/locales/en.yml b/config/locales/en.yml --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -9,8 +9,8 @@ email_label: 'E-mail' password_label: 'Password' - go_ahead_to: "Go ahead to" - go_back_to: "Go back to" + go_ahead_to: "Go ahead to " + go_back_to: "Go back to " login_page: "login page" home_page: "home page" diff --git a/lib/mail_helper_methods.rb b/lib/mail_helper_methods.rb --- a/lib/mail_helper_methods.rb +++ b/lib/mail_helper_methods.rb @@ -22,7 +22,18 @@ body mail_body end - mail.delivery_settings = { :address => smtp_server } + mail_option = { + :address => smtp_server, +# :domain => nil, +# :port => 25, +# :user_name => nil, +# :password => nil, +# :authentication=>'plain', +# :enable_starttls_auto => true + } + + mail.delivery_method :smtp, mail_option + mail.deliver end