Description:
better user import
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r798:46ce575fc051 - - 6 files changed: 28 inserted, 17 deleted
@@ -62,43 +62,53 | |||||
|
62 | note = [] |
|
62 | note = [] |
|
63 | error_note = [] |
|
63 | error_note = [] |
|
64 | error_msg = nil |
|
64 | error_msg = nil |
|
65 | ok_user = [] |
|
65 | ok_user = [] |
|
66 |
|
66 | ||
|
67 | lines.split("\n").each do |line| |
|
67 | lines.split("\n").each do |line| |
|
68 | - items = line.chomp.split(',') |
|
68 | + #split with large limit, this will cause consecutive ',' to be result in a blank |
|
|
69 | + items = line.chomp.split(',',1000) | ||
|
69 | if items.length>=2 |
|
70 | if items.length>=2 |
|
70 | login = items[0] |
|
71 | login = items[0] |
|
71 | full_name = items[1] |
|
72 | full_name = items[1] |
|
72 | remark ='' |
|
73 | remark ='' |
|
73 | user_alias = '' |
|
74 | user_alias = '' |
|
74 |
|
75 | ||
|
75 | added_random_password = false |
|
76 | added_random_password = false |
|
76 | - if items.length >= 3 and items[2].chomp(" ").length > 0; |
|
77 | + added_password = false |
|
|
78 | + if items.length >= 3 | ||
|
|
79 | + if items[2].chomp(" ").length > 0 | ||
|
77 | password = items[2].chomp(" ") |
|
80 | password = items[2].chomp(" ") |
|
|
81 | + added_password = true | ||
|
|
82 | + end | ||
|
78 | else |
|
83 | else |
|
79 | password = random_password |
|
84 | password = random_password |
|
80 | added_random_password=true; |
|
85 | added_random_password=true; |
|
81 | end |
|
86 | end |
|
82 |
|
87 | ||
|
83 | if items.length>= 4 and items[3].chomp(" ").length > 0; |
|
88 | if items.length>= 4 and items[3].chomp(" ").length > 0; |
|
84 | user_alias = items[3].chomp(" ") |
|
89 | user_alias = items[3].chomp(" ") |
|
85 | else |
|
90 | else |
|
86 | user_alias = login |
|
91 | user_alias = login |
|
87 | end |
|
92 | end |
|
88 |
|
93 | ||
|
|
94 | + | ||
|
|
95 | + has_remark = false | ||
|
89 | if items.length>=5 |
|
96 | if items.length>=5 |
|
90 | remark = items[4].strip; |
|
97 | remark = items[4].strip; |
|
|
98 | + has_remark = true | ||
|
91 | end |
|
99 | end |
|
92 |
|
100 | ||
|
93 | user = User.find_by_login(login) |
|
101 | user = User.find_by_login(login) |
|
94 | if (user) |
|
102 | if (user) |
|
95 | user.full_name = full_name |
|
103 | user.full_name = full_name |
|
96 | - user.password = password |
|
104 | + user.remark = remark if has_remark |
|
97 | - user.remark = remark |
|
105 | + user.password = password if added_password || added_random_password |
|
98 | else |
|
106 | else |
|
|
107 | + #create a random password if none are given | ||
|
|
108 | + password = random_password unless password | ||
|
99 | user = User.new({:login => login, |
|
109 | user = User.new({:login => login, |
|
100 | :full_name => full_name, |
|
110 | :full_name => full_name, |
|
101 | :password => password, |
|
111 | :password => password, |
|
102 | :password_confirmation => password, |
|
112 | :password_confirmation => password, |
|
103 | :alias => user_alias, |
|
113 | :alias => user_alias, |
|
104 | :remark => remark}) |
|
114 | :remark => remark}) |
@@ -179,15 +179,12 | |||||
|
179 | result = <<TITLEBAR |
|
179 | result = <<TITLEBAR |
|
180 | <div class="title"> |
|
180 | <div class="title"> |
|
181 | <table> |
|
181 | <table> |
|
182 | #{header} |
|
182 | #{header} |
|
183 | <tr> |
|
183 | <tr> |
|
184 | <td class="left-col"> |
|
184 | <td class="left-col"> |
|
185 | - #{user.full_name}<br/> |
|
||
|
186 | - #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} |
|
||
|
187 | - #{time_left} |
|
||
|
188 | <br/> |
|
185 | <br/> |
|
189 | </td> |
|
186 | </td> |
|
190 | <td class="right-col">#{contest_name}</td> |
|
187 | <td class="right-col">#{contest_name}</td> |
|
191 | </tr> |
|
188 | </tr> |
|
192 | </table> |
|
189 | </table> |
|
193 | </div> |
|
190 | </div> |
@@ -1,20 +1,14 | |||||
|
1 | module MainHelper |
|
1 | module MainHelper |
|
2 |
|
2 | ||
|
3 |
- def link_to_description_if_any(name, problem |
|
3 | + def link_to_description_if_any(name, problem) |
|
4 | if !problem.url.blank? |
|
4 | if !problem.url.blank? |
|
5 |
- return link_to name, problem.url |
|
5 | + return link_to name, problem.url |
|
6 | elsif !problem.description_filename.blank? |
|
6 | elsif !problem.description_filename.blank? |
|
7 | - #build a link to a problem (via task controller) |
|
||
|
8 | basename, ext = problem.description_filename.split('.') |
|
7 | basename, ext = problem.description_filename.split('.') |
|
9 | - options[:controller] = 'tasks' |
|
8 | + return link_to name, download_task_path(problem.id,basename,ext), target: '_blank' |
|
10 | - options[:action] = 'download' |
|
||
|
11 | - options[:id] = problem.id |
|
||
|
12 | - options[:file] = basename |
|
||
|
13 | - options[:ext] = ext |
|
||
|
14 | - return link_to name, options |
|
||
|
15 | else |
|
9 | else |
|
16 | return '' |
|
10 | return '' |
|
17 | end |
|
11 | end |
|
18 | end |
|
12 | end |
|
19 |
|
13 | ||
|
20 | end |
|
14 | end |
@@ -39,12 +39,13 | |||||
|
39 | %td.text-right |
|
39 | %td.text-right |
|
40 | %strong Task |
|
40 | %strong Task |
|
41 | %td |
|
41 | %td |
|
42 | - if @submission.problem!=nil |
|
42 | - if @submission.problem!=nil |
|
43 | = link_to "[#{@submission.problem.name}]", stat_problem_path(@submission.problem) |
|
43 | = link_to "[#{@submission.problem.name}]", stat_problem_path(@submission.problem) |
|
44 | = @submission.problem.full_name |
|
44 | = @submission.problem.full_name |
|
|
45 | + = link_to_description_if_any "[download] <span class='glyphicon glyphicon-file'></span>".html_safe, @submission.problem | ||
|
45 | - else |
|
46 | - else |
|
46 | = "(n/a)" |
|
47 | = "(n/a)" |
|
47 | %tr |
|
48 | %tr |
|
48 | %td.text-right |
|
49 | %td.text-right |
|
49 | %strong Tries |
|
50 | %strong Tries |
|
50 | %td= @submission.number |
|
51 | %td= @submission.number |
@@ -23,12 +23,21 | |||||
|
23 | %tt passwd |
|
23 | %tt passwd |
|
24 | or |
|
24 | or |
|
25 | %tt alias |
|
25 | %tt alias |
|
26 | is empty, the original value will be used instead. |
|
26 | is empty, the original value will be used instead. |
|
27 | %li |
|
27 | %li |
|
28 | If the users with the same user_id already exists, existing information will be overwritten. |
|
28 | If the users with the same user_id already exists, existing information will be overwritten. |
|
|
29 | + Example: | ||
|
|
30 | + %ol | ||
|
|
31 | + %li | ||
|
|
32 | + %pre user1,Somchai Jaidee | ||
|
|
33 | + will create (or update) a user with login "user1" and setting the fullname to "Somchai Jaidee", also setting a random password. | ||
|
|
34 | + %li | ||
|
|
35 | + %pre user1,Somchai Jaidee, | ||
|
|
36 | + will create (or update) a user with login "user1" and and setting the fullname "Somchai Jaidee". No change is made to the password unless this is a new user. If this is a new user, a random password will be generated. | ||
|
|
37 | + | ||
|
29 |
|
38 | ||
|
30 | .row |
|
39 | .row |
|
31 | .col-md-6 |
|
40 | .col-md-6 |
|
32 | = form_tag :action => 'create_from_list' do |
|
41 | = form_tag :action => 'create_from_list' do |
|
33 | .form-group |
|
42 | .form-group |
|
34 | = submit_tag 'Create following users',class: 'btn btn-success' |
|
43 | = submit_tag 'Create following users',class: 'btn btn-success' |
@@ -174,13 +174,13 | |||||
|
174 | #post 'main/submit', to: 'main#submit' |
|
174 | #post 'main/submit', to: 'main#submit' |
|
175 | #get 'main/announcements', to: 'main#announcements' |
|
175 | #get 'main/announcements', to: 'main#announcements' |
|
176 |
|
176 | ||
|
177 |
|
177 | ||
|
178 | # |
|
178 | # |
|
179 | get 'tasks/view/:file.:ext' => 'tasks#view' |
|
179 | get 'tasks/view/:file.:ext' => 'tasks#view' |
|
180 | - get 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
180 | + get 'tasks/download/:id/:file.:ext' => 'tasks#download', as: 'download_task' |
|
181 | get 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
181 | get 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
182 |
|
182 | ||
|
183 | #grader |
|
183 | #grader |
|
184 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
184 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
185 | namespace :graders do |
|
185 | namespace :graders do |
|
186 | get 'task/:id/:type', action: 'task', as: 'task' |
|
186 | get 'task/:id/:type', action: 'task', as: 'task' |
You need to be logged in to leave comments.
Login now