diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,6 +23,10 @@ def authenticate unless session[:user_id] + flash[:notice] = 'You need to login' + if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] + flash[:notice] = 'You need to login but you cannot log in at this time' + end redirect_to :controller => 'main', :action => 'login' return false end diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -1,18 +1,14 @@ class ReportController < ApplicationController before_filter :admin_authorization, only: [:login_stat,:submission_stat] - before_filter(only: :problem_hof) { |c| - user = User.find(session[:user_id]) if session[:user_id] - if user==nil - flash[:notice] = 'You have to login first' - redirect_to :controller => 'main', :action => 'login' - return false + before_filter { |c| + return false unless authenticate + + if GraderConfiguration["system.hall_of_fame_available"] + return true; end - - unless GraderConfiguration["hall_of_fame_available"] - flash[:notice] = 'You are not authorized to view the page you requested' - redirect_to :controller => 'main', :action => 'login' unless GraderConfiguration[ "hall_of_fame_available" ] - end + + admin_authorization } def login_stat 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 @@ -30,6 +30,10 @@ append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' end + + if GraderConfiguration['system.hall_of_fame_available'] + append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' + end append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' if GraderConfiguration['system.user_setting_enabled'] diff --git a/config/locales/en.yml b/config/locales/en.yml --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,6 +20,7 @@ tasks: 'Tasks' submissions: 'Submissions' test: 'Test Interface' + hall_of_fame: 'Hall of Fame' help: 'Help' settings: 'Settings' log_out: 'Log out' diff --git a/config/locales/th.yml b/config/locales/th.yml --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -20,6 +20,7 @@ tasks: 'โจทย์' submissions: 'โปรแกรมที่ส่ง' test: 'ทดสอบโปรแกรม' + hall_of_fame: 'หอเกียรติยศ' help: 'ความช่วยเหลือ' settings: 'เปลี่ยนรหัสผ่าน' log_out: 'ออกจากระบบ' diff --git a/db/seeds.rb b/db/seeds.rb --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,60 +6,60 @@ :default_value => 'false', :description => 'Only admins can log in to the system when running under single user mode.' }, - + { :key => 'ui.front.title', :value_type => 'string', :default_value => 'Grader' }, - + { :key => 'ui.front.welcome_message', :value_type => 'string', :default_value => 'Welcome!' }, - + { :key => 'ui.show_score', :value_type => 'boolean', :default_value => 'true' }, - + { :key => 'contest.time_limit', :value_type => 'string', :default_value => 'unlimited', :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits. This config is CACHED. Restart the server before the change can take effect.' }, - + { :key => 'system.mode', :value_type => 'string', :default_value => 'standard', :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".' }, - + { :key => 'contest.name', :value_type => 'string', :default_value => 'Grader', :description => 'This name will be shown on the user header bar.' }, - + { :key => 'contest.multisites', :value_type => 'boolean', :default_value => 'false', :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.' }, - + { - :key => 'system.online_registration', + :key => 'system.hall_of_fame_available', :value_type => 'boolean', :default_value => 'false', - :description => 'This option enables online registration.' + :description => 'If true, any user can access hall of fame page.' }, - + # If Configuration['system.online_registration'] is true, the # system allows online registration, and will use these # information for sending confirmation emails. @@ -68,26 +68,33 @@ :value_type => 'string', :default_value => 'smtp.somehost.com' }, - + { :key => 'system.online_registration.from', :value_type => 'string', :default_value => 'your.email@address' }, - + { :key => 'system.admin_email', :value_type => 'string', :default_value => 'admin@admin.email' }, - + { :key => 'system.user_setting_enabled', :value_type => 'boolean', :default_value => 'true', :description => 'If this option is true, users can change their settings' }, - + + { + :key => 'system.user_setting_enabled', + :value_type => 'boolean', + :default_value => 'true', + :description => 'If this option is true, users can change their settings' + } + # If Configuration['contest.test_request.early_timeout'] is true # the user will not be able to use test request at 30 minutes # before the contest ends. @@ -115,7 +122,7 @@ :default_value => 'none', :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest." } - + ]