Description:
hacked user creation to bypass member name validation, changed default config for test pair import
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r261:432c3e723bef - - 2 files changed: 2 inserted, 1 deleted
@@ -1,136 +1,137 | |||||
|
1 | class UserAdminController < ApplicationController |
|
1 | class UserAdminController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :admin_authorization |
|
3 | before_filter :admin_authorization |
|
4 |
|
4 | ||
|
5 | def index |
|
5 | def index |
|
6 | list |
|
6 | list |
|
7 | render :action => 'list' |
|
7 | render :action => 'list' |
|
8 | end |
|
8 | end |
|
9 |
|
9 | ||
|
10 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
10 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
11 | verify :method => :post, :only => [ :destroy, |
|
11 | verify :method => :post, :only => [ :destroy, |
|
12 | :create, :create_from_list, |
|
12 | :create, :create_from_list, |
|
13 | :update ], |
|
13 | :update ], |
|
14 | :redirect_to => { :action => :list } |
|
14 | :redirect_to => { :action => :list } |
|
15 |
|
15 | ||
|
16 | def list |
|
16 | def list |
|
17 | @users = User.find(:all) |
|
17 | @users = User.find(:all) |
|
18 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
18 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
19 | end |
|
19 | end |
|
20 |
|
20 | ||
|
21 | def active |
|
21 | def active |
|
22 | sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago]) |
|
22 | sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago]) |
|
23 | @users = [] |
|
23 | @users = [] |
|
24 | sessions.each do |session| |
|
24 | sessions.each do |session| |
|
25 | if session.data[:user_id] |
|
25 | if session.data[:user_id] |
|
26 | @users << User.find(session.data[:user_id]) |
|
26 | @users << User.find(session.data[:user_id]) |
|
27 | end |
|
27 | end |
|
28 | end |
|
28 | end |
|
29 | end |
|
29 | end |
|
30 |
|
30 | ||
|
31 | def show |
|
31 | def show |
|
32 | @user = User.find(params[:id]) |
|
32 | @user = User.find(params[:id]) |
|
33 | end |
|
33 | end |
|
34 |
|
34 | ||
|
35 | def new |
|
35 | def new |
|
36 | @user = User.new |
|
36 | @user = User.new |
|
37 | end |
|
37 | end |
|
38 |
|
38 | ||
|
39 | def create |
|
39 | def create |
|
40 | @user = User.new(params[:user]) |
|
40 | @user = User.new(params[:user]) |
|
|
41 | + @user.member1_full_name = @user.full_name | ||
|
41 | @user.activated = true |
|
42 | @user.activated = true |
|
42 | if @user.save |
|
43 | if @user.save |
|
43 | flash[:notice] = 'User was successfully created.' |
|
44 | flash[:notice] = 'User was successfully created.' |
|
44 | redirect_to :action => 'list' |
|
45 | redirect_to :action => 'list' |
|
45 | else |
|
46 | else |
|
46 | render :action => 'new' |
|
47 | render :action => 'new' |
|
47 | end |
|
48 | end |
|
48 | end |
|
49 | end |
|
49 |
|
50 | ||
|
50 | def create_from_list |
|
51 | def create_from_list |
|
51 | lines = params[:user_list] |
|
52 | lines = params[:user_list] |
|
52 |
|
53 | ||
|
53 | note = [] |
|
54 | note = [] |
|
54 |
|
55 | ||
|
55 | lines.split("\n").each do |line| |
|
56 | lines.split("\n").each do |line| |
|
56 | items = line.chomp.split(',') |
|
57 | items = line.chomp.split(',') |
|
57 | if items.length>=2 |
|
58 | if items.length>=2 |
|
58 | login = items[0] |
|
59 | login = items[0] |
|
59 | full_name = items[1] |
|
60 | full_name = items[1] |
|
60 |
|
61 | ||
|
61 | added_random_password = false |
|
62 | added_random_password = false |
|
62 | if items.length>=3 |
|
63 | if items.length>=3 |
|
63 | password = items[2] |
|
64 | password = items[2] |
|
64 | user_alias = (items.length>=4) ? items[3] : login |
|
65 | user_alias = (items.length>=4) ? items[3] : login |
|
65 | else |
|
66 | else |
|
66 | password = random_password |
|
67 | password = random_password |
|
67 | user_alias = (items.length>=4) ? items[3] : login |
|
68 | user_alias = (items.length>=4) ? items[3] : login |
|
68 | added_random_password = true |
|
69 | added_random_password = true |
|
69 | end |
|
70 | end |
|
70 |
|
71 | ||
|
71 | user = User.new({:login => login, |
|
72 | user = User.new({:login => login, |
|
72 | :full_name => full_name, |
|
73 | :full_name => full_name, |
|
73 | :password => password, |
|
74 | :password => password, |
|
74 | :password_confirmation => password, |
|
75 | :password_confirmation => password, |
|
75 | :alias => user_alias}) |
|
76 | :alias => user_alias}) |
|
76 | user.activated = true |
|
77 | user.activated = true |
|
77 | user.save |
|
78 | user.save |
|
78 |
|
79 | ||
|
79 | if added_random_password |
|
80 | if added_random_password |
|
80 | note << "'#{login}' (+)" |
|
81 | note << "'#{login}' (+)" |
|
81 | else |
|
82 | else |
|
82 | note << login |
|
83 | note << login |
|
83 | end |
|
84 | end |
|
84 | end |
|
85 | end |
|
85 | end |
|
86 | end |
|
86 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
87 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
87 | ' were successfully created. ' + |
|
88 | ' were successfully created. ' + |
|
88 | '( (+) - created with random passwords.)' |
|
89 | '( (+) - created with random passwords.)' |
|
89 | redirect_to :action => 'list' |
|
90 | redirect_to :action => 'list' |
|
90 | end |
|
91 | end |
|
91 |
|
92 | ||
|
92 | def edit |
|
93 | def edit |
|
93 | @user = User.find(params[:id]) |
|
94 | @user = User.find(params[:id]) |
|
94 | end |
|
95 | end |
|
95 |
|
96 | ||
|
96 | def update |
|
97 | def update |
|
97 | @user = User.find(params[:id]) |
|
98 | @user = User.find(params[:id]) |
|
98 | if @user.update_attributes(params[:user]) |
|
99 | if @user.update_attributes(params[:user]) |
|
99 | flash[:notice] = 'User was successfully updated.' |
|
100 | flash[:notice] = 'User was successfully updated.' |
|
100 | redirect_to :action => 'show', :id => @user |
|
101 | redirect_to :action => 'show', :id => @user |
|
101 | else |
|
102 | else |
|
102 | render :action => 'edit' |
|
103 | render :action => 'edit' |
|
103 | end |
|
104 | end |
|
104 | end |
|
105 | end |
|
105 |
|
106 | ||
|
106 | def destroy |
|
107 | def destroy |
|
107 | User.find(params[:id]).destroy |
|
108 | User.find(params[:id]).destroy |
|
108 | redirect_to :action => 'list' |
|
109 | redirect_to :action => 'list' |
|
109 | end |
|
110 | end |
|
110 |
|
111 | ||
|
111 | def user_stat |
|
112 | def user_stat |
|
112 | @problems = Problem.find_available_problems |
|
113 | @problems = Problem.find_available_problems |
|
113 | @users = User.find(:all) |
|
114 | @users = User.find(:all) |
|
114 | @scorearray = Array.new |
|
115 | @scorearray = Array.new |
|
115 | @users.each do |u| |
|
116 | @users.each do |u| |
|
116 | ustat = Array.new |
|
117 | ustat = Array.new |
|
117 | ustat[0] = u |
|
118 | ustat[0] = u |
|
118 | @problems.each do |p| |
|
119 | @problems.each do |p| |
|
119 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
120 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
120 | if (sub!=nil) and (sub.points!=nil) |
|
121 | if (sub!=nil) and (sub.points!=nil) |
|
121 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
122 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
122 | else |
|
123 | else |
|
123 | ustat << [0,false] |
|
124 | ustat << [0,false] |
|
124 | end |
|
125 | end |
|
125 | end |
|
126 | end |
|
126 | @scorearray << ustat |
|
127 | @scorearray << ustat |
|
127 | end |
|
128 | end |
|
128 | end |
|
129 | end |
|
129 |
|
130 | ||
|
130 | def import |
|
131 | def import |
|
131 | if params[:file]=='' |
|
132 | if params[:file]=='' |
|
132 | flash[:notice] = 'Error importing no file' |
|
133 | flash[:notice] = 'Error importing no file' |
|
133 | redirect_to :action => 'list' and return |
|
134 | redirect_to :action => 'list' and return |
|
134 | end |
|
135 | end |
|
135 | import_from_file(params[:file]) |
|
136 | import_from_file(params[:file]) |
|
136 | end |
|
137 | end |
@@ -1,112 +1,112 | |||||
|
1 | # Be sure to restart your web server when you modify this file. |
|
1 | # Be sure to restart your web server when you modify this file. |
|
2 |
|
2 | ||
|
3 | # Uncomment below to force Rails into production mode when |
|
3 | # Uncomment below to force Rails into production mode when |
|
4 | # you don't control web/app server and can't set it the proper way |
|
4 | # you don't control web/app server and can't set it the proper way |
|
5 | # ENV['RAILS_ENV'] ||= 'production' |
|
5 | # ENV['RAILS_ENV'] ||= 'production' |
|
6 |
|
6 | ||
|
7 | # Specifies gem version of Rails to use when vendor/rails is not present |
|
7 | # Specifies gem version of Rails to use when vendor/rails is not present |
|
8 | RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION |
|
8 | RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION |
|
9 |
|
9 | ||
|
10 | # Bootstrap the Rails environment, frameworks, and default configuration |
|
10 | # Bootstrap the Rails environment, frameworks, and default configuration |
|
11 | require File.join(File.dirname(__FILE__), 'boot') |
|
11 | require File.join(File.dirname(__FILE__), 'boot') |
|
12 |
|
12 | ||
|
13 | Rails::Initializer.run do |config| |
|
13 | Rails::Initializer.run do |config| |
|
14 | # Settings in config/environments/* take precedence over those specified here |
|
14 | # Settings in config/environments/* take precedence over those specified here |
|
15 |
|
15 | ||
|
16 | # Skip frameworks you're not going to use (only works if using vendor/rails) |
|
16 | # Skip frameworks you're not going to use (only works if using vendor/rails) |
|
17 | # config.frameworks -= [ :action_web_service, :action_mailer ] |
|
17 | # config.frameworks -= [ :action_web_service, :action_mailer ] |
|
18 |
|
18 | ||
|
19 | # Only load the plugins named here, by default all plugins in vendor/plugins are loaded |
|
19 | # Only load the plugins named here, by default all plugins in vendor/plugins are loaded |
|
20 | # config.plugins = %W( exception_notification ssl_requirement ) |
|
20 | # config.plugins = %W( exception_notification ssl_requirement ) |
|
21 |
|
21 | ||
|
22 | # Add additional load paths for your own custom dirs |
|
22 | # Add additional load paths for your own custom dirs |
|
23 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) |
|
23 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) |
|
24 |
|
24 | ||
|
25 | # Force all environments to use the same logger level |
|
25 | # Force all environments to use the same logger level |
|
26 | # (by default production uses :info, the others :debug) |
|
26 | # (by default production uses :info, the others :debug) |
|
27 | # config.log_level = :debug |
|
27 | # config.log_level = :debug |
|
28 |
|
28 | ||
|
29 | # Use the database for sessions instead of the file system |
|
29 | # Use the database for sessions instead of the file system |
|
30 | # (create the session table with 'rake db:sessions:create') |
|
30 | # (create the session table with 'rake db:sessions:create') |
|
31 | config.action_controller.session_store = :active_record_store |
|
31 | config.action_controller.session_store = :active_record_store |
|
32 |
|
32 | ||
|
33 | # Use SQL instead of Active Record's schema dumper when creating the test database. |
|
33 | # Use SQL instead of Active Record's schema dumper when creating the test database. |
|
34 | # This is necessary if your schema can't be completely dumped by the schema dumper, |
|
34 | # This is necessary if your schema can't be completely dumped by the schema dumper, |
|
35 | # like if you have constraints or database-specific column types |
|
35 | # like if you have constraints or database-specific column types |
|
36 | # config.active_record.schema_format = :sql |
|
36 | # config.active_record.schema_format = :sql |
|
37 |
|
37 | ||
|
38 | # Activate observers that should always be running |
|
38 | # Activate observers that should always be running |
|
39 | # config.active_record.observers = :cacher, :garbage_collector |
|
39 | # config.active_record.observers = :cacher, :garbage_collector |
|
40 |
|
40 | ||
|
41 | # Make Active Record use UTC-base instead of local time |
|
41 | # Make Active Record use UTC-base instead of local time |
|
42 | config.time_zone = 'UTC' |
|
42 | config.time_zone = 'UTC' |
|
43 |
|
43 | ||
|
44 | # Setting locales |
|
44 | # Setting locales |
|
45 | config.i18n.default_locale = 'en' |
|
45 | config.i18n.default_locale = 'en' |
|
46 |
|
46 | ||
|
47 | # See Rails::Configuration for more options |
|
47 | # See Rails::Configuration for more options |
|
48 |
|
48 | ||
|
49 | # ------------- |
|
49 | # ------------- |
|
50 | # Required gems |
|
50 | # Required gems |
|
51 | # ------------- |
|
51 | # ------------- |
|
52 | config.gem "haml" |
|
52 | config.gem "haml" |
|
53 | config.gem "tmail" |
|
53 | config.gem "tmail" |
|
54 | config.gem "rdiscount", :lib => "rdiscount" |
|
54 | config.gem "rdiscount", :lib => "rdiscount" |
|
55 |
|
55 | ||
|
56 | # NOTES on rspec: if you wan to test with rspec, you have to install |
|
56 | # NOTES on rspec: if you wan to test with rspec, you have to install |
|
57 | # rspec yourself, just call: [sudo] gem install rspec-rails |
|
57 | # rspec yourself, just call: [sudo] gem install rspec-rails |
|
58 |
|
58 | ||
|
59 | end |
|
59 | end |
|
60 |
|
60 | ||
|
61 | # Add new inflection rules using the following format |
|
61 | # Add new inflection rules using the following format |
|
62 | # (all these examples are active by default): |
|
62 | # (all these examples are active by default): |
|
63 | # Inflector.inflections do |inflect| |
|
63 | # Inflector.inflections do |inflect| |
|
64 | # inflect.plural /^(ox)$/i, '\1en' |
|
64 | # inflect.plural /^(ox)$/i, '\1en' |
|
65 | # inflect.singular /^(ox)en/i, '\1' |
|
65 | # inflect.singular /^(ox)en/i, '\1' |
|
66 | # inflect.irregular 'person', 'people' |
|
66 | # inflect.irregular 'person', 'people' |
|
67 | # inflect.uncountable %w( fish sheep ) |
|
67 | # inflect.uncountable %w( fish sheep ) |
|
68 | # end |
|
68 | # end |
|
69 |
|
69 | ||
|
70 | # Add new mime types for use in respond_to blocks: |
|
70 | # Add new mime types for use in respond_to blocks: |
|
71 | # Mime::Type.register "text/richtext", :rtf |
|
71 | # Mime::Type.register "text/richtext", :rtf |
|
72 | # Mime::Type.register "application/x-mobile", :mobile |
|
72 | # Mime::Type.register "application/x-mobile", :mobile |
|
73 |
|
73 | ||
|
74 | # Include your application configuration below |
|
74 | # Include your application configuration below |
|
75 |
|
75 | ||
|
76 | # If you want to manage graders through web interface, set the path to |
|
76 | # If you want to manage graders through web interface, set the path to |
|
77 | # the grader directory below. This dir is where raw, ev, ev-exam, |
|
77 | # the grader directory below. This dir is where raw, ev, ev-exam, |
|
78 | # scripts reside. All grader scripts will be in |
|
78 | # scripts reside. All grader scripts will be in |
|
79 | # #{GRADER_ROOT_DIR}/scripts. |
|
79 | # #{GRADER_ROOT_DIR}/scripts. |
|
80 | GRADER_ROOT_DIR = '' |
|
80 | GRADER_ROOT_DIR = '' |
|
81 |
|
81 | ||
|
82 | # These are where inputs and outputs of test requests are stored |
|
82 | # These are where inputs and outputs of test requests are stored |
|
83 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
83 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
84 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
84 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
85 |
|
85 | ||
|
86 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
86 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
87 | # and the directory of the grading result (usually in judge's dir). |
|
87 | # and the directory of the grading result (usually in judge's dir). |
|
88 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
88 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
89 |
|
89 | ||
|
90 | # TODO: change this to where results are kept. |
|
90 | # TODO: change this to where results are kept. |
|
91 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
91 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
92 |
|
92 | ||
|
93 | # Change this to allow importing testdata into database as test-pairs. |
|
93 | # Change this to allow importing testdata into database as test-pairs. |
|
94 | # This is mainly for Code Jom contest. |
|
94 | # This is mainly for Code Jom contest. |
|
95 |
- ALLOW_TEST_PAIR_IMPORT = |
|
95 | + ALLOW_TEST_PAIR_IMPORT = true |
|
96 |
|
96 | ||
|
97 | # Uncomment so that the system validates user e-mails |
|
97 | # Uncomment so that the system validates user e-mails |
|
98 | # VALIDATE_USER_EMAILS = true |
|
98 | # VALIDATE_USER_EMAILS = true |
|
99 |
|
99 | ||
|
100 | # Uncomment so that Apache X-Sendfile is used when delivering files |
|
100 | # Uncomment so that Apache X-Sendfile is used when delivering files |
|
101 | # (e.g., in /tasks/view). |
|
101 | # (e.g., in /tasks/view). |
|
102 | # USE_APACHE_XSENDFILE = true |
|
102 | # USE_APACHE_XSENDFILE = true |
|
103 |
|
103 | ||
|
104 | # Uncomment so that configuration is read only once when the server is loaded |
|
104 | # Uncomment so that configuration is read only once when the server is loaded |
|
105 | # Configuration.enable_caching |
|
105 | # Configuration.enable_caching |
|
106 |
|
106 | ||
|
107 | # OPTIONS FOR CODE JOM |
|
107 | # OPTIONS FOR CODE JOM |
|
108 | # -------------------- |
|
108 | # -------------------- |
|
109 | CODEJOM_MAX_ALIVE_LEVEL = 10 |
|
109 | CODEJOM_MAX_ALIVE_LEVEL = 10 |
|
110 | TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute |
|
110 | TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute |
|
111 | SHOW_CONTEST_STATUS = false |
|
111 | SHOW_CONTEST_STATUS = false |
|
112 | HIDE_PASSED_TASKS = true No newline at end of file |
|
112 | HIDE_PASSED_TASKS = true |
You need to be logged in to leave comments.
Login now