Description:
disable fullname editing
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@47 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
r23:6beb043d888f - - 3 files changed: 12 inserted, 8 deleted
@@ -2,13 +2,12 | |||||
|
2 |
|
2 | ||
|
3 | before_filter :authenticate |
|
3 | before_filter :authenticate |
|
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, :full_name |
|
||
|
9 | in_place_edit_for :user, :alias_for_editing |
|
8 | in_place_edit_for :user, :alias_for_editing |
|
10 | in_place_edit_for :user, :email_for_editing |
|
9 | in_place_edit_for :user, :email_for_editing |
|
11 |
|
10 | ||
|
12 | def index |
|
11 | def index |
|
13 | @user = User.find(session[:user_id]) |
|
12 | @user = User.find(session[:user_id]) |
|
14 | end |
|
13 | end |
@@ -3,12 +3,13 | |||||
|
3 | class User < ActiveRecord::Base |
|
3 | class User < ActiveRecord::Base |
|
4 |
|
4 | ||
|
5 | has_and_belongs_to_many :roles |
|
5 | has_and_belongs_to_many :roles |
|
6 |
|
6 | ||
|
7 | validates_presence_of :login |
|
7 | validates_presence_of :login |
|
8 | validates_presence_of :full_name |
|
8 | validates_presence_of :full_name |
|
|
9 | + validates_length_of :full_name, :minimum => 1 | ||
|
9 |
|
10 | ||
|
10 | validates_presence_of :password, :if => :password_required? |
|
11 | validates_presence_of :password, :if => :password_required? |
|
11 | validates_length_of :password, :within => 4..20, :if => :password_required? |
|
12 | validates_length_of :password, :within => 4..20, :if => :password_required? |
|
12 | validates_confirmation_of :password, :if => :password_required? |
|
13 | validates_confirmation_of :password, :if => :password_required? |
|
13 |
|
14 | ||
|
14 | attr_accessor :password |
|
15 | attr_accessor :password |
@@ -26,28 +27,32 | |||||
|
26 |
|
27 | ||
|
27 | def admin? |
|
28 | def admin? |
|
28 | self.roles.detect {|r| r.name == 'admin' } |
|
29 | self.roles.detect {|r| r.name == 'admin' } |
|
29 | end |
|
30 | end |
|
30 |
|
31 | ||
|
31 | def email_for_editing |
|
32 | def email_for_editing |
|
32 |
- if self.email |
|
33 | + if self.email==nil |
|
|
34 | + "(unknown)" | ||
|
|
35 | + elsif self.email=='' | ||
|
|
36 | + "(blank)" | ||
|
|
37 | + else | ||
|
33 | self.email |
|
38 | self.email |
|
34 | - else |
|
||
|
35 | - "unknown" |
|
||
|
36 | end |
|
39 | end |
|
37 | end |
|
40 | end |
|
38 |
|
41 | ||
|
39 | def email_for_editing=(e) |
|
42 | def email_for_editing=(e) |
|
40 | self.email=e |
|
43 | self.email=e |
|
41 | end |
|
44 | end |
|
42 |
|
45 | ||
|
43 | def alias_for_editing |
|
46 | def alias_for_editing |
|
44 |
- if self.alias |
|
47 | + if self.alias==nil |
|
|
48 | + "(unknown)" | ||
|
|
49 | + elsif self.alias=='' | ||
|
|
50 | + "(blank)" | ||
|
|
51 | + else | ||
|
45 | self.alias |
|
52 | self.alias |
|
46 | - else |
|
||
|
47 | - "unknown" |
|
||
|
48 | end |
|
53 | end |
|
49 | end |
|
54 | end |
|
50 |
|
55 | ||
|
51 | def alias_for_editing=(e) |
|
56 | def alias_for_editing=(e) |
|
52 | self.alias=e |
|
57 | self.alias=e |
|
53 | end |
|
58 | end |
@@ -8,13 +8,13 | |||||
|
8 | %table.uinfo |
|
8 | %table.uinfo |
|
9 | %tr |
|
9 | %tr |
|
10 | %th.uinfo Login |
|
10 | %th.uinfo Login |
|
11 | %td.uinfo= @user.login |
|
11 | %td.uinfo= @user.login |
|
12 | %tr |
|
12 | %tr |
|
13 | %th.uinfo Full name |
|
13 | %th.uinfo Full name |
|
14 | - %td.uinfo= in_place_editor_field :user, 'full_name', {}, :rows => 1 |
|
14 | + %td.uinfo= @user.full_name |
|
15 | %tr |
|
15 | %tr |
|
16 | %th.uinfo Alias |
|
16 | %th.uinfo Alias |
|
17 | %td.uinfo= in_place_editor_field :user, 'alias_for_editing', {}, :rows => 1 |
|
17 | %td.uinfo= in_place_editor_field :user, 'alias_for_editing', {}, :rows => 1 |
|
18 | %tr |
|
18 | %tr |
|
19 | %th.uinfo E-mail |
|
19 | %th.uinfo E-mail |
|
20 | %td.uinfo= in_place_editor_field :user, 'email_for_editing', {}, :rows => 1 |
|
20 | %td.uinfo= in_place_editor_field :user, 'email_for_editing', {}, :rows => 1 |
You need to be logged in to leave comments.
Login now