Description:
MERGED change set 372:399 from ytopc08-2 branch git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@401 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r190:27e07d862fff - - 9 files changed: 181 inserted, 57 deleted

@@ -0,0 +1,19
1 + %h1 Active users
2 +
3 + %i
4 + I.e., those users that interacts with the system with in the last 60 minutes.
5 + %br/
6 +
7 + = link_to '[go back to index]', :action => 'index'
8 +
9 + %table
10 + %tr
11 + %th #
12 + %th login
13 + %th full name
14 + - counter = 0
15 + - for user in @users
16 + %tr
17 + %td= counter += 1
18 + %td= user.login
19 + %td= user.full_name
@@ -1,42 +1,52
1 1 class UserAdminController < ApplicationController
2 2
3 3 before_filter :admin_authorization
4 4
5 5 def index
6 6 list
7 7 render :action => 'list'
8 8 end
9 9
10 10 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
11 11 verify :method => :post, :only => [ :destroy, :create, :update ],
12 12 :redirect_to => { :action => :list }
13 13
14 14 def list
15 15 @users = User.find(:all)
16 16 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
17 17 end
18 18
19 + def active
20 + sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago])
21 + @users = []
22 + sessions.each do |session|
23 + if session.data[:user_id]
24 + @users << User.find(session.data[:user_id])
25 + end
26 + end
27 + end
28 +
19 29 def show
20 30 @user = User.find(params[:id])
21 31 end
22 32
23 33 def new
24 34 @user = User.new
25 35 end
26 36
27 37 def create
28 38 @user = User.new(params[:user])
29 39 @user.activated = true
30 40 if @user.save
31 41 flash[:notice] = 'User was successfully created.'
32 42 redirect_to :action => 'list'
33 43 else
34 44 render :action => 'new'
35 45 end
36 46 end
37 47
38 48 def create_from_list
39 49 lines = params[:user_list]
40 50 lines.split("\n").each do |line|
41 51 items = line.chomp.split(',')
42 52 if items.length==4
@@ -104,48 +104,51
104 104
105 105 def verify_activation_key(key)
106 106 key == activation_key
107 107 end
108 108
109 109 def self.random_password(length=5)
110 110 chars = 'abcdefghjkmnopqrstuvwxyz'
111 111 password = ''
112 112 length.times { password << chars[rand(chars.length - 1)] }
113 113 password
114 114 end
115 115
116 116 protected
117 117 def encrypt_new_password
118 118 return if password.blank?
119 119 self.salt = (10+rand(90)).to_s
120 120 self.hashed_password = User.encrypt(self.password,self.salt)
121 121 end
122 122
123 123 def assign_default_site
124 124 # have to catch error when migrating (because self.site is not available).
125 125 begin
126 126 if self.site==nil
127 127 self.site = Site.find_by_name('default')
128 + if self.site==nil
129 + self.site = Site.find(1) # when 'default has be renamed'
130 + end
128 131 end
129 132 rescue
130 133 end
131 134 end
132 135
133 136 def password_required?
134 137 self.hashed_password.blank? || !self.password.blank?
135 138 end
136 139
137 140 def self.encrypt(string,salt)
138 141 Digest::SHA1.hexdigest(salt + string)
139 142 end
140 143
141 144 def uniqueness_of_email_from_activated_users
142 145 user = User.activated_users.find_by_email(self.email)
143 146 if user and (user.login != self.login)
144 147 self.errors.add_to_base("Email has already been taken")
145 148 end
146 149 end
147 150
148 151 def enough_time_interval_between_same_email_registrations
149 152 return if !self.new_record?
150 153 return if self.activated
151 154 open_user = User.find_by_email(self.email,
@@ -1,42 +1,42
1 1 %h1= Configuration['ui.front.title']
2 2
3 3 - if @announcements.length!=0
4 4 .announcementbox
5 5 %span{:class => 'title'}
6 6 Announcements
7 7 = render :partial => 'announcement', :collection => @announcements
8 8
9 9 %b= Configuration['ui.front.welcome_message']
10 10 %br/
11 11
12 12 - if !@hidelogin
13 13 =t 'login.message'
14 14 %br/
15 15 %br/
16 16
17 17 - if flash[:notice]
18 18 %hr/
19 19 %b= flash[:notice]
20 20 %hr/
21 21
22 - %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"}
22 + %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"}
23 23 - form_tag :controller => 'login', :action => 'login' do
24 24 %table
25 25 %tr
26 26 %td{:align => "right"}
27 27 ="#{t 'login_label'}:"
28 28 %td= text_field_tag 'login'
29 29 %tr
30 30 %td{:align => "right"}
31 31 ="#{t 'password_label'}:"
32 32 %td= password_field_tag
33 33 = submit_tag t('login.login_submit')
34 34 %br/
35 35
36 36 - if Configuration['system.online_registration']
37 37 =t 'login.participation'
38 38 %b
39 39 = "#{t 'login.please'} "
40 40 = link_to "#{t 'login.register'}", :controller => :users, :action => :new
41 41 %br/
42 42 = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget
@@ -1,22 +1,25
1 1 %tr{:class => (test_request_counter%2==0) ? "info-even" : "info-odd"}
2 2 %td{:align => "center"}
3 3 = format_short_time(test_request.submitted_at)
4 4 %td
5 5 - if test_request.problem!=nil
6 6 = test_request.problem.full_name
7 7 - else
8 8 (n/a)
9 9 %td{:align => "center"}
10 - = test_request.submission.number
10 + - if test_request.submission
11 + = test_request.submission.number
12 + - else
13 + n/a
11 14 %td{:align => "center"}
12 15 = test_request.status_str
13 16 %td{:align => "center"}
14 17 - if test_request.output_file_name!=nil
15 18 = link_to '[download]', :action => 'read', :id => test_request.id
16 19 %td{:align => "center"}
17 20 - if test_request.compiler_message!=nil and test_request.compiler_message!=''
18 21 = "yes"
19 22 - else
20 23 = "no"
21 24 %td{:align => "center"}
22 25 = link_to '[view]', :action => 'result', :id => test_request.id
@@ -4,50 +4,56
4 4 <b>Quick add</b>
5 5 <% form_tag :action => 'create' do %>
6 6 <table border="0">
7 7 <tr>
8 8 <td><label for="user_login">Login</label></td>
9 9 <td><label for="user_full_name">Full name</label></td>
10 10 <td><label for="user_password">Password</label></td>
11 11 <td><label for="user_password_confirmation">Confirm</label></td>
12 12 <td><label for="user_email">Email</label></td>
13 13 </tr>
14 14 <tr>
15 15 <td><%= text_field 'user', 'login', :size => 10 %></td>
16 16 <td><%= text_field 'user', 'full_name', :size => 30 %></td>
17 17 <td><%= password_field 'user', 'password', :size => 10 %></td>
18 18 <td><%= password_field 'user', 'password_confirmation', :size => 10 %></td>
19 19 <td><%= text_field 'user', 'email', :size => 15 %></td>
20 20 <td><%= submit_tag "Create" %></td>
21 21 </tr></table>
22 22 <% end %>
23 23 <br/>
24 24 <b>Import from site management</b>
25 25 <% form_tag({:action => 'import'}, :multipart => true) do %>
26 26 File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %>
27 27 <% end %>
28 + <br/>
29 + <b>What else: </b>
30 + <%= link_to '[New user]', :action => 'new' %>
31 + <%= link_to '[New list of users]', :action => 'new_list' %>
32 + <%= link_to '[View active users]', :action => 'active' %>
28 33
29 34 </div>
35 +
30 36 <table>
31 37 <tr>
32 38 <% for column in User.content_columns %>
33 39 <% if !@hidden_columns.index(column.name) %>
34 40 <th><%= column.human_name %></th>
35 41 <% end %>
36 42 <% end %>
37 43 </tr>
38 44
39 45 <% for user in @users %>
40 46 <tr>
41 47 <% for column in User.content_columns %>
42 48 <% if !@hidden_columns.index(column.name) %>
43 49 <td><%=h user.send(column.name) %></td>
44 50 <% end %>
45 51 <% end %>
46 52 <td><%= link_to 'Show', :action => 'show', :id => user %></td>
47 53 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
48 54 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
49 55 </tr>
50 56 <% end %>
51 57 </table>
52 58
53 59
@@ -1,24 +1,28
1 + # Thai translation for Ruby on Rails
2 + # original by Prem Sichanugrist (s@sikachu.com/sikandsak@gmail.com)
3 + # activerecord keys fixed by Jittat Fakcharoenphol (jittat@gmail.com)
4 +
1 5 {
2 6 :'th' => {
3 7 :date => {
4 8 :formats => {
5 9 :default => lambda { |date| "%d-%m-#{date.year+543}" },
6 10 :short => "%e %b",
7 11 :long => lambda { |date| "%e %B #{date.year+543}" },
8 12 :long_ordinal => lambda { |date| "%e %B #{date.year+543}" },
9 13 :only_day => "%e"
10 14 },
11 15 :day_names => %w(อาทิตย์ จันทร์ อังคาร พุธ พฤหัสบดี ศุกร์ เสาร์),
12 16 :abbr_day_names => %w(อา จ อ พ พฤ ศ ส),
13 17 :month_names => [nil] + %w(มกราคม กุมภาพันธ์ มีนาคม เมษายน พฤษภาคม มิถุนายน กรกฎาคม สิงหาคม กันยายน ตุลาคม พฤศจิกายน ธันวาคม),
14 18 :abbr_month_names => [nil] + %w(ม.ค. ก.พ. มี.ค. เม.ย. พ.ค. มิ.ย. ก.ค. ส.ค. ก.ย. ต.ค. พ.ย. ธ.ค.),
15 19 :order => [:day, :month, :year]
16 20 },
17 21 :time => {
18 22 :formats => {
19 23 :default => lambda { |time| "%a %d %b #{time.year+543} %H:%M:%S %Z" },
20 24 :time => "%H:%M น.",
21 25 :short => "%d %b %H:%M น.",
22 26 :long => lambda { |time| "%d %B #{time.year+543} %H:%M น." },
23 27 :long_ordinal => lambda { |time| "%d %B #{time.year+543} %H:%M น." },
24 28 :only_second => "%S"
@@ -45,48 +49,64
45 49 :x_hours => '{{count}} ชั่วโมง',
46 50 :about_x_days => 'ประมาณ {{count}} วัน',
47 51 :x_days => '{{count}} วัน',
48 52 :about_x_months => 'ประมาณ {{count}} เดือน',
49 53 :x_months => '{{count}} เดือน',
50 54 :about_x_years => 'ประมาณ {{count}} ปี',
51 55 :over_x_years => 'เกิน {{count}} ปี'
52 56 }
53 57 },
54 58
55 59 # numbers
56 60 :number => {
57 61 :format => {
58 62 :precision => 3,
59 63 :separator => '.',
60 64 :delimiter => ','
61 65 },
62 66 :currency => {
63 67 :format => {
64 68 :unit => 'Baht',
65 69 :precision => 2,
66 70 :format => '%n %u'
67 71 }
68 72 },
73 + :human => {
74 + :format => {
75 + :precision => 1,
76 + :delimiter => ''
77 + },
78 + :storage_units => {
79 + :format => "%n %u",
80 + :units => {
81 + :byte => "B",
82 + :kb => "KB",
83 + :mb => "MB",
84 + :gb => "GB",
85 + :tb => "TB",
86 + }
87 + }
88 + },
69 89 },
70 90
71 91 # Active Record
72 92 :activerecord => {
73 93 :errors => {
74 94 :template => {
75 95 :header => {
76 96 :one => "ไม่สามารถบันทึก {{model}} ได้เนื่องจากเกิดข้อผิดพลาด",
77 97 :other => "ไม่สามารถบันทึก {{model}} ได้เนื่องจากเกิด {{count}} ข้อผิดพลาด"
78 98 },
79 99 :body => "โปรดตรวจสอบข้อมูลที่คุณกรอกในช่องต่อไปนี้:"
80 100 },
81 101 :messages => {
82 102 :inclusion => "ไม่ได้อยู่ในลิสต์",
83 103 :exclusion => "ถูกจองเอาไว้แล้ว",
84 104 :invalid => "ไม่ถูกต้อง",
85 105 :confirmation => "ไม่ตรงกับการยืนยัน",
86 106 :accepted => "ต้องอยู่ในรูปแบบที่ยอมรับ",
87 107 :empty => "ต้องไม้เว้นว่างเอาไว้",
88 108 :blank => "ต้องไม่เว้นว่างเอาไว้",
89 109 :too_long => "ยาวเกินไป (ต้องไม่เกิน {{count}} ตัวอักษร)",
90 110 :too_short => "สั้นเกินไป (ต้องยาวกว่า {{count}} ตัวอักษร)",
91 111 :wrong_length => "มีความยาวไม่ถูกต้อง (ต้องมีความยาว {{count}} ตัวอักษร)",
92 112 :taken => "ถูกใช้ไปแล้ว",
@@ -1,9 +1,9
1 1 class ChangeUserLoginStringLimit < ActiveRecord::Migration
2 2 def self.up
3 3 execute "ALTER TABLE `users` CHANGE `login` `login` VARCHAR( 50 )"
4 4 end
5 5
6 6 def self.down
7 - execute "ALTER TABLE `users` CHANGE `login` `login` VARCHAR( 10 )"
7 + # don't have to revert
8 8 end
9 9 end
@@ -1,260 +1,323
1 - /* Normal text */
1 + /* Main Default */
2 2 body {
3 + background: white url(../images/topbg.jpg) repeat-x top center;
3 4 font-size: 13px;
4 - font-family: "Sans Serif";
5 + font-family: Tahoma, "sans-serif";
6 + margin: 10px;
7 + padding: 10px;
8 + }
9 +
10 + /* Form Font */
11 + input {
12 + font-family: Tahoma, "sans-serif";
13 + }
14 +
15 + /* Heading 1/2 */
16 + h1 {
17 + font-size: 24px;
18 + color: #334488;
19 + line-height: 2em;
20 + }
21 +
22 + h2 {
23 + font-size: 18px;
24 + color: #5566bb;
25 + line-height: 1.5em;
26 + }
27 +
28 + /* Bar Line Color and Thickness */
29 + hr {
30 + border-top: 1px solid #dddddd;
31 + border-bottom: 1px solid #eeeeee;
32 + }
33 +
34 + /* Link + Anchor Color */
35 + a, a:link, a:visited {
36 + color: #6666cc;
37 + text-decoration: none;
38 + }
39 +
40 + a:hover, a:focus {
41 + color: #111166;
42 + text-decoration: none;
5 43 }
6 44
7 45 /* This is the main menu bad*/
8 46 div.userbar {
9 - border-top: thin solid grey;
10 - border-bottom: thin solid grey;
47 + line-height: 1.5em;
11 48 text-align: right;
12 49 font-size: 12px;
13 50 }
14 51
15 52 /* This is the top bar, displaying user's full name */
16 53 div.title {
17 - font-size: 12px;
18 - background: #ddffdd;
19 - border: 1px solid black;
20 - padding: 2px;
21 - margin-top: 3px;
22 - margin-bottom: 5px;
54 + // background: #ddddff;
55 + // border: 1px dashed blue;
56 + padding: 10px 0px;
57 + line-height: 1.5em;
58 + font-size: 13px;
23 59 }
24 60
25 61 div.title span.contest-over-msg {
26 62 font-size: 15px;
27 63 color: red;
28 - font-weight: bold;
29 64 }
30 65
31 66 div.title table {
32 67 width: 100%;
33 68 }
34 69
35 70 div.title td.left-col {
36 71 text-align: left;
37 72 vertical-align: top;
73 + color: #444444;
38 74 }
39 75
40 76 div.title td.right-col {
41 77 text-align: right;
42 78 vertical-align: top;
79 + font-size: 14px;
80 + font-weight: bold;
81 + color: #116699;
43 82 }
44 83
45 84 /* Standard table with header and rows with alternating background */
46 85 table.info {
47 - border: 1px solid black;
86 + margin: 10px 0;
87 + border: 1px solid #666666;
48 88 border-collapse: collapse;
49 89 font-size: 12px;
50 90 }
51 91
52 92 table.info th {
53 - border: 1px solid black;
93 + border: 1px solid #666666;
94 + line-height: 1.5em;
95 + padding: 0 0.5em;
54 96 }
55 97
56 98 table.info td {
57 - border-left: 1px solid black;
58 - border-right: 1px solid black;
99 + border-left: 1px solid #666666;
100 + border-right: 1px solid #666666;
101 + line-height: 1.5em;
102 + padding: 0 0.5em;
59 103 }
60 104
61 105 tr.info-head {
62 106 background: #777777;
63 107 color: white;
64 108 }
65 109
66 110 tr.info-odd {
67 - background: #dddddd;
111 + background: #eeeeee;
68 112 }
69 113
70 114 tr.info-even {
71 - background: #f0f0f0;
115 + background: #f9f9f9;
72 116 }
73 117
74 118 /*******************************
75 119 [Main]
76 120 ********************************/
77 121 div.submitbox {
78 - border: thin solid black;
122 + background: #eeeeff;
123 + border: 1px dotted #99aaee;
79 124 padding: 5px;
80 - color: white;
81 - background-color: #777777;
125 + margin: 10px 0px;
126 + color: black;
82 127 font-weight: bold;
83 128 font-size: 13px;
84 129 }
85 130
86 131 div.errorExplanation {
87 - border: 1px dashed black;
88 - color: black;
89 - padding: 5px;
132 + border: 1px dotted gray;
133 + color: #bb2222;
134 + padding: 5px 15px 5px 15px;
90 135 margin-bottom: 5px;
91 136 background-color: white;
92 137 }
93 138
94 139 /*******************************
95 140 [Settings]
96 141 ********************************/
97 142 table.uinfo {
98 143 border-collapse: collapse;
99 144 border: 1px solid black;
100 145 font-size: 13px;
101 146 }
102 147
103 148 td.uinfo {
104 149 vertical-align: top;
105 150 border: 1px solid black;
106 151 padding: 5px;
107 152 }
108 153
109 154 th.uinfo {
110 155 background: lightgreen;
111 156 vertical-align: top;
112 157 text-align: right;
113 158 border: 1px solid black;
114 159 padding: 5px;
115 160 }
116 161
117 162 /*******************************
118 163 [Submission]
119 164 ********************************/
120 165 div.compilermsgbody {
121 166 font-family: monospace;
122 167 }
123 168
124 169 div.task-menu {
125 170 text-align: center;
126 171 font-size: 13px;
172 + line-height: 1.75em;
127 173 font-weight: bold;
128 - border-top: 1px solid black;
129 - border-bottom: 1px solid black;
174 + border-top: 1px dashed gray;
175 + border-bottom: 1px dashed gray;
130 176 margin-top: 2px;
131 177 margin-bottom: 4px;
132 178 }
133 179
134 180 /*******************************
135 181 [Submission]
136 182 ********************************/
137 183 table.taskdesc {
138 - border: 1px solid black;
184 + border: 2px solid #dddddd;
139 185 border-collapse: collapse;
140 - width: 95%;
186 + margin: 10px auto;
187 + width: 90%;
141 188 font-size: 13px;
142 189 }
143 190
144 191 table.taskdesc p {
145 192 font-size: 13px;
146 193 }
147 194
148 195 table.taskdesc tr.name {
149 - border: 1px solid black;
150 - background: #aaaaaa;
151 - color: white;
196 + border: 2px solid #dddddd;
197 + background: #dddddd;
198 + color: #333333;
152 199 font-weight: bold;
153 200 font-size: 14px;
201 + line-height: 1.5em;
154 202 text-align: center;
155 203 }
156 204
157 205 table.taskdesc td.desc-odd {
158 206 padding: 5px;
159 207 padding-left: 20px;
160 208 background: #fefeee;
161 209 }
162 210
163 211 table.taskdesc td.desc-even {
164 212 padding: 5px;
165 213 padding-left: 20px;
166 214 background: #feeefe;
167 215 }
168 216
169 217 /**********************
170 - [Announcement]
218 + Announcement
171 219 ***********************/
172 220
173 221 div.announcementbox {
174 - margin-top: 10px;
175 - margin-bottom: 10px;
176 - background: green;
222 + margin: 10px 0px;
223 + background: #bbddee;
177 224 padding: 1px;
178 225 }
179 226
180 227 div.announcementbox span.title {
181 228 font-weight: bold;
182 - color: white;
229 + color: #224455;
183 230 padding-left: 10px;
231 + line-height: 1.6em;
184 232 }
185 233
186 234 div.announcement {
187 235 margin: 2px;
188 236 background: white;
189 237 padding: 1px;
190 238 padding-left: 10px;
191 239 padding-right: 10px;
192 240 }
193 241
194 242 div.announcement p {
195 243 font-size: 12px;
196 244 }
197 245
198 246 div.pub-info, div.pub-info p {
199 247 text-align: right;
200 248 font-style: italic;
201 249 font-size: 9px;
202 250 }
203 251
204 252 /******************
205 - [Messages
253 + Messages
206 254 ******************/
207 255
208 256 div.message {
209 - padding-top: 5px;
210 - padding-left: 10px;
257 + margin: 10px 0 0;
258 + }
259 +
260 + div.message div.message {
261 + margin: 0 0 0 30px;
211 262 }
212 263
213 264 div.message div.body {
214 - border: 1px solid green;
215 - background: #eeffee;
265 + border: 2px solid #dddddd;
266 + background: #fff8f8;
216 267 padding-left: 5px;
217 268 }
218 269
219 270 div.message div.reply-body {
220 - border: 1px solid black;
221 - background: #ffeeee;
271 + border: 2px solid #bbbbbb;
272 + background: #fffff8;
222 273 padding-left: 5px;
223 274 }
224 275
225 276 div.message div.stat {
226 277 font-size: 10px;
227 - color: white;
228 - background: green;
278 + line-height: 1.75em;
279 + padding: 0 5px;
280 + color: #333333;
281 + background: #dddddd;
282 + font-weight: bold;
283 + }
284 +
285 + div.message div.message div.stat {
286 + font-size: 10px;
287 + line-height: 1.75em;
288 + padding: 0 5px;
289 + color: #444444;
290 + background: #bbbbbb;
229 291 font-weight: bold;
230 292 }
231 293
232 294 /********************
233 295 Registration
234 296 ********************/
235 297 div.contest-title {
236 298 color: white;
237 - background: #007700;
238 299 text-align: center;
239 - padding: 5px;
300 + line-height: 2em;
240 301 }
241 302
242 303 div.registration-desc {
243 - margin-top: 5px;
244 - margin-bottom: 5px;
245 - border: solid 1px gray;
246 - padding: 10px;
247 - background: #f0f0f0;
304 + border: 1px dotted gray;
305 + background: #f5f5f5;
306 + padding: 5px;
307 + margin: 10px 0;
308 + font-size: 12px;
309 + line-height: 1.5em;
248 310 }
249 311
250 312 /********************
251 313 [Test Interface]
252 314 ********************/
253 315
254 316 div.test-desc {
255 - border: solid 1px gray;
256 - background: #f0f0f0;
317 + border: 1px dotted gray;
318 + background: #f5f5f5;
257 319 padding: 5px;
320 + margin: 10px 0;
258 321 font-size: 12px;
259 - margin-bottom: 5px;
322 + line-height: 1.5em;
260 323 }
You need to be logged in to leave comments. Login now