Description:
add options to allow hall of fame viewing by any user add menu item for normal user
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r424:217b94aa4f76 - - 6 files changed: 25 inserted, 12 deleted

@@ -14,24 +14,28
14 14 user = User.find(session[:user_id])
15 15 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
16 16 flash[:notice] = 'You are not authorized to view the page you requested'
17 17 redirect_to :controller => 'main', :action => 'login'
18 18 return false
19 19 end
20 20 end
21 21
22 22 protected
23 23
24 24 def authenticate
25 25 unless session[:user_id]
26 + flash[:notice] = 'You need to login'
27 + if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
28 + flash[:notice] = 'You need to login but you cannot log in at this time'
29 + end
26 30 redirect_to :controller => 'main', :action => 'login'
27 31 return false
28 32 end
29 33
30 34 # check if run in single user mode
31 35 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
32 36 user = User.find(session[:user_id])
33 37 if user==nil or (not user.admin?)
34 38 flash[:notice] = 'You cannot log in at this time'
35 39 redirect_to :controller => 'main', :action => 'login'
36 40 return false
37 41 end
@@ -1,27 +1,23
1 1 class ReportController < ApplicationController
2 2
3 3 before_filter :admin_authorization, only: [:login_stat,:submission_stat]
4 - before_filter(only: :problem_hof) { |c|
5 - user = User.find(session[:user_id]) if session[:user_id]
6 - if user==nil
7 - flash[:notice] = 'You have to login first'
8 - redirect_to :controller => 'main', :action => 'login'
9 - return false
4 + before_filter { |c|
5 + return false unless authenticate
6 +
7 + if GraderConfiguration["system.hall_of_fame_available"]
8 + return true;
10 9 end
11 10
12 - unless GraderConfiguration["hall_of_fame_available"]
13 - flash[:notice] = 'You are not authorized to view the page you requested'
14 - redirect_to :controller => 'main', :action => 'login' unless GraderConfiguration[ "hall_of_fame_available" ]
15 - end
11 + admin_authorization
16 12 }
17 13
18 14 def login_stat
19 15 @logins = Array.new
20 16
21 17 date_and_time = '%Y-%m-%d %H:%M'
22 18 begin
23 19 @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
24 20 rescue
25 21 @since_time = DateTime.new(1000,1,1)
26 22 end
27 23 begin
@@ -21,24 +21,28
21 21 menu_items << "<br/>"
22 22 end
23 23
24 24 # main page
25 25 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
26 26 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
27 27
28 28 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
29 29 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
30 30 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
31 31 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
32 32 end
33 +
34 + if GraderConfiguration['system.hall_of_fame_available']
35 + append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
36 + end
33 37 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
34 38
35 39 if GraderConfiguration['system.user_setting_enabled']
36 40 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
37 41 end
38 42 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
39 43
40 44 menu_items.html_safe
41 45 end
42 46
43 47 def append_to(option,label, controller, action)
44 48 option << ' ' if option!=''
@@ -11,24 +11,25
11 11
12 12 go_ahead_to: "Go ahead to"
13 13 go_back_to: "Go back to"
14 14 login_page: "login page"
15 15 home_page: "home page"
16 16
17 17 menu:
18 18 main: 'Main'
19 19 messages: 'Messages'
20 20 tasks: 'Tasks'
21 21 submissions: 'Submissions'
22 22 test: 'Test Interface'
23 + hall_of_fame: 'Hall of Fame'
23 24 help: 'Help'
24 25 settings: 'Settings'
25 26 log_out: 'Log out'
26 27
27 28 title_bar:
28 29 current_time: "Current time is"
29 30 remaining_time: "Time left: "
30 31 contest_not_started: "The contest has not started."
31 32
32 33 login:
33 34 message: 'Please login to see the problem list'
34 35 login_submit: 'Login'
@@ -11,24 +11,25
11 11
12 12 go_ahead_to: "ΰΉ„ΰΈ›ΰΈ’ΰΈ±ΰΈ‡"
13 13 go_back_to: "กΰΈ₯ΰΈ±ΰΈšΰΉ„ΰΈ›ΰΈ’ΰΈ±ΰΈ‡"
14 14 login_page: "ΰΈ«ΰΈ™ΰΉ‰ΰΈ²ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš"
15 15 home_page: "หน้าแรก"
16 16
17 17 menu:
18 18 main: 'ΰΈ«ΰΈ™ΰΉ‰ΰΈ²ΰΈ«ΰΈ₯ัก'
19 19 messages: 'ΰΈ‚ΰΉ‰ΰΈ­ΰΈ„ΰΈ§ΰΈ²ΰΈ‘'
20 20 tasks: 'ΰΉ‚ΰΈˆΰΈ—ΰΈ’ΰΉŒ'
21 21 submissions: 'ΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘ΰΈ—ΰΈ΅ΰΉˆΰΈͺΰΉˆΰΈ‡'
22 22 test: 'ΰΈ—ΰΈ”ΰΈͺΰΈ­ΰΈšΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘'
23 + hall_of_fame: 'หอเกมฒรติฒศ'
23 24 help: 'ΰΈ„ΰΈ§ΰΈ²ΰΈ‘ΰΈŠΰΉˆΰΈ§ΰΈ’ΰΉ€ΰΈ«ΰΈ₯ΰΈ·ΰΈ­'
24 25 settings: 'ΰΉ€ΰΈ›ΰΈ₯ΰΈ΅ΰΉˆΰΈ’ΰΈ™ΰΈ£ΰΈ«ΰΈ±ΰΈͺΰΈœΰΉˆΰΈ²ΰΈ™'
25 26 log_out: 'ออกจากระบบ'
26 27
27 28 title_bar:
28 29 current_time: "ΰΉ€ΰΈ§ΰΈ₯ΰΈ²ΰΈ›ΰΈ±ΰΈˆΰΈˆΰΈΈΰΈšΰΈ±ΰΈ™ΰΈ„ΰΈ·ΰΈ­"
29 30 remaining_time: "ΰΉ€ΰΈ«ΰΈ₯ΰΈ·ΰΈ­ΰΉ€ΰΈ§ΰΈ₯าอมก"
30 31 contest_not_started: "ΰΈ’ΰΈ±ΰΈ‡ΰΉ„ΰΈ‘ΰΉˆΰΉ€ΰΈ£ΰΈ΄ΰΉˆΰΈ‘ΰΉΰΈ‚ΰΉˆΰΈ‡ΰΈ‚ΰΈ±ΰΈ™"
31 32
32 33 login:
33 34 message: 'กรุณา login ΰΉ€ΰΈžΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΈͺู่ระบบ'
34 35 login_submit: 'ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš'
@@ -45,28 +45,28
45 45 :default_value => 'Grader',
46 46 :description => 'This name will be shown on the user header bar.'
47 47 },
48 48
49 49 {
50 50 :key => 'contest.multisites',
51 51 :value_type => 'boolean',
52 52 :default_value => 'false',
53 53 :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.'
54 54 },
55 55
56 56 {
57 - :key => 'system.online_registration',
57 + :key => 'system.hall_of_fame_available',
58 58 :value_type => 'boolean',
59 59 :default_value => 'false',
60 - :description => 'This option enables online registration.'
60 + :description => 'If true, any user can access hall of fame page.'
61 61 },
62 62
63 63 # If Configuration['system.online_registration'] is true, the
64 64 # system allows online registration, and will use these
65 65 # information for sending confirmation emails.
66 66 {
67 67 :key => 'system.online_registration.smtp',
68 68 :value_type => 'string',
69 69 :default_value => 'smtp.somehost.com'
70 70 },
71 71
72 72 {
@@ -79,24 +79,31
79 79 :key => 'system.admin_email',
80 80 :value_type => 'string',
81 81 :default_value => 'admin@admin.email'
82 82 },
83 83
84 84 {
85 85 :key => 'system.user_setting_enabled',
86 86 :value_type => 'boolean',
87 87 :default_value => 'true',
88 88 :description => 'If this option is true, users can change their settings'
89 89 },
90 90
91 + {
92 + :key => 'system.user_setting_enabled',
93 + :value_type => 'boolean',
94 + :default_value => 'true',
95 + :description => 'If this option is true, users can change their settings'
96 + }
97 +
91 98 # If Configuration['contest.test_request.early_timeout'] is true
92 99 # the user will not be able to use test request at 30 minutes
93 100 # before the contest ends.
94 101 {
95 102 :key => 'contest.test_request.early_timeout',
96 103 :value_type => 'boolean',
97 104 :default_value => 'false'
98 105 },
99 106
100 107 {
101 108 :key => 'system.multicontests',
102 109 :value_type => 'boolean',
You need to be logged in to leave comments. Login now