Description:
added 'user_setting_enabled' option
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@295 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r156:e751e4e9d100 - - 3 files changed: 16 inserted, 4 deleted
@@ -1,28 +1,29 | |||||
|
1 | class UsersController < ApplicationController |
|
1 | class UsersController < ApplicationController |
|
2 |
|
2 | ||
|
3 | - before_filter :authenticate |
|
3 | + before_filter :authenticate, :except => [:new, :register] |
|
4 |
|
4 | ||
|
5 | verify :method => :post, :only => [:chg_passwd], |
|
5 | verify :method => :post, :only => [:chg_passwd], |
|
6 | :redirect_to => { :action => :index } |
|
6 | :redirect_to => { :action => :index } |
|
7 |
|
7 | ||
|
8 | in_place_edit_for :user, :alias_for_editing |
|
8 | in_place_edit_for :user, :alias_for_editing |
|
9 | in_place_edit_for :user, :email_for_editing |
|
9 | in_place_edit_for :user, :email_for_editing |
|
10 |
|
10 | ||
|
11 | def index |
|
11 | def index |
|
12 | - # uncomment below to disable settings |
|
12 | + if !Configuration['system.user_setting_enabled'] |
|
13 |
- |
|
13 | + redirect_to :controller => 'main', :action => 'list' |
|
14 | - |
|
14 | + else |
|
15 | @user = User.find(session[:user_id]) |
|
15 | @user = User.find(session[:user_id]) |
|
16 | end |
|
16 | end |
|
|
17 | + end | ||
|
17 |
|
18 | ||
|
18 | def chg_passwd |
|
19 | def chg_passwd |
|
19 | user = User.find(session[:user_id]) |
|
20 | user = User.find(session[:user_id]) |
|
20 | user.password = params[:passwd] |
|
21 | user.password = params[:passwd] |
|
21 | user.password_confirmation = params[:passwd_verify] |
|
22 | user.password_confirmation = params[:passwd_verify] |
|
22 | if user.save |
|
23 | if user.save |
|
23 | flash[:notice] = 'password changed' |
|
24 | flash[:notice] = 'password changed' |
|
24 | else |
|
25 | else |
|
25 | flash[:notice] = 'Error: password changing failed' |
|
26 | flash[:notice] = 'Error: password changing failed' |
|
26 | end |
|
27 | end |
|
27 | redirect_to :action => 'index' |
|
28 | redirect_to :action => 'index' |
|
28 | end |
|
29 | end |
@@ -21,25 +21,28 | |||||
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | # main page |
|
23 | # main page |
|
24 | append_to menu_items, '[Main]', 'main', 'list' |
|
24 | append_to menu_items, '[Main]', 'main', 'list' |
|
25 | append_to menu_items, '[Messages]', 'messages', 'list' |
|
25 | append_to menu_items, '[Messages]', 'messages', 'list' |
|
26 |
|
26 | ||
|
27 | if (user!=nil) and (Configuration.show_tasks_to?(user)) |
|
27 | if (user!=nil) and (Configuration.show_tasks_to?(user)) |
|
28 | append_to menu_items, '[Tasks]', 'tasks', 'list' |
|
28 | append_to menu_items, '[Tasks]', 'tasks', 'list' |
|
29 | append_to menu_items, '[Submissions]', 'main', 'submission' |
|
29 | append_to menu_items, '[Submissions]', 'main', 'submission' |
|
30 | append_to menu_items, '[Test]', 'test', 'index' |
|
30 | append_to menu_items, '[Test]', 'test', 'index' |
|
31 | end |
|
31 | end |
|
32 | append_to menu_items, '[Help]', 'main', 'help' |
|
32 | append_to menu_items, '[Help]', 'main', 'help' |
|
|
33 | + | ||
|
|
34 | + if Configuration['system.user_setting_enabled'] | ||
|
33 | append_to menu_items, '[Settings]', 'users', 'index' |
|
35 | append_to menu_items, '[Settings]', 'users', 'index' |
|
|
36 | + end | ||
|
34 | append_to menu_items, '[Log out]', 'main', 'login' |
|
37 | append_to menu_items, '[Log out]', 'main', 'login' |
|
35 |
|
38 | ||
|
36 | menu_items |
|
39 | menu_items |
|
37 | end |
|
40 | end |
|
38 |
|
41 | ||
|
39 | def append_to(option,label, controller, action) |
|
42 | def append_to(option,label, controller, action) |
|
40 | option << ' ' if option!='' |
|
43 | option << ' ' if option!='' |
|
41 | option << link_to_unless_current(label, |
|
44 | option << link_to_unless_current(label, |
|
42 | :controller => controller, |
|
45 | :controller => controller, |
|
43 | :action => action) |
|
46 | :action => action) |
|
44 | end |
|
47 | end |
|
45 |
|
48 |
@@ -5,19 +5,27 | |||||
|
5 | # the menu for site administrator is shown. |
|
5 | # the menu for site administrator is shown. |
|
6 |
|
6 | ||
|
7 | Configuration.create(:key => 'contest.multisites', |
|
7 | Configuration.create(:key => 'contest.multisites', |
|
8 | :value_type => 'boolean', |
|
8 | :value_type => 'boolean', |
|
9 | :value => 'false') |
|
9 | :value => 'false') |
|
10 |
|
10 | ||
|
11 | # If Configuration['system.online_registration'] is true, |
|
11 | # If Configuration['system.online_registration'] is true, |
|
12 | # the registration menu would appear |
|
12 | # the registration menu would appear |
|
13 |
|
13 | ||
|
14 | Configuration.create(:key => 'system.online_registration', |
|
14 | Configuration.create(:key => 'system.online_registration', |
|
15 | :value_type => 'boolean', |
|
15 | :value_type => 'boolean', |
|
16 | :value => 'false') |
|
16 | :value => 'false') |
|
|
17 | + | ||
|
|
18 | + # If Configuration['system.user_setting_enabled'] is true, | ||
|
|
19 | + # users can change their settings | ||
|
|
20 | + | ||
|
|
21 | + Configuration.create(:key => 'system.user_setting_enabled', | ||
|
|
22 | + :value_type => 'boolean', | ||
|
|
23 | + :value => 'true') | ||
|
17 | end |
|
24 | end |
|
18 |
|
25 | ||
|
19 | def self.down |
|
26 | def self.down |
|
20 | Configuration.find_by_key('contest.multisites').destroy |
|
27 | Configuration.find_by_key('contest.multisites').destroy |
|
21 | Configuration.find_by_key('system.online_registration').destroy |
|
28 | Configuration.find_by_key('system.online_registration').destroy |
|
|
29 | + Configuration.find_by_key('system.user_setting_enabled').destroy | ||
|
22 | end |
|
30 | end |
|
23 | end |
|
31 | end |
You need to be logged in to leave comments.
Login now