Commit c975ff41f41bebdec09901c364d2e9fe23193ba2
- Date: Wed Dec 12 23:28:38 +0000 2007
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: c975ff41f41bebdec09901c364d2e9fe23193ba2
- Tree SHA1: 80bb82e5a5c62982e15faa36b53cb034db76ca14
allow users to set their full/real name
Commit diff
| |   |
| 11 | 11 | def update |
| 12 | 12 | @user = current_user |
| 13 | 13 | current_user.email = params[:user][:email] if params[:user][:email] |
| 14 | current_user.fullname = params[:user][:fullname] if params[:user][:fullname] |
| 14 | 15 | current_user.password = params[:user][:password] if params[:user][:password] |
| 15 | 16 | if params[:user][:password_confirmation] |
| 16 | 17 | current_user.password_confirmation = params[:user][:password_confirmation] |
| toggle raw diff |
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -11,6 +11,7 @@ class AccountsController < ApplicationController
def update
@user = current_user
current_user.email = params[:user][:email] if params[:user][:email]
+ current_user.fullname = params[:user][:fullname] if params[:user][:fullname]
current_user.password = params[:user][:password] if params[:user][:password]
if params[:user][:password_confirmation]
current_user.password_confirmation = params[:user][:password_confirmation] |
| |   |
| 6 | 6 | <%= f.label :email -%><br /> |
| 7 | 7 | <%= f.text_field :email, :class => "text" -%> |
| 8 | 8 | </p> |
| 9 | <p> |
| 10 | <%= f.label :fullname, "Realname" -%><br /> |
| 11 | <%= f.text_field :fullname, :class => "text" -%> |
| 12 | </p> |
| 9 | 13 | <p> |
| 10 | 14 | <%= f.label :password -%><br /> |
| 11 | 15 | <%= f.password_field :password, :class => "text" -%> |
| toggle raw diff |
--- a/app/views/accounts/edit.html.erb
+++ b/app/views/accounts/edit.html.erb
@@ -6,6 +6,10 @@
<%= f.label :email -%><br />
<%= f.text_field :email, :class => "text" -%>
</p>
+ <p>
+ <%= f.label :fullname, "Realname" -%><br />
+ <%= f.text_field :fullname, :class => "text" -%>
+ </p>
<p>
<%= f.label :password -%><br />
<%= f.password_field :password, :class => "text" -%> |
| |   |
| 1 | 1 | <% @page_title = "Account" -%> |
| 2 | 2 | |
| 3 | | <h2>Account details</h2> |
| 4 | | <ul> |
| 5 | | <li>username: <%= current_user.login -%></li> |
| 6 | | <li>email: <%= current_user.email -%></li> |
| 3 | <h2>Account details <small><%= link_to "edit", edit_account_path -%></small></h2> |
| 4 | <ul class="infobox"> |
| 5 | <li><strong>Realname:</strong> |
| 6 | <%= current_user.fullname.blank? ? "N/A" : h(current_user.fullname) -%></li> |
| 7 | <li><strong>Username:</strong> <%= link_to h(current_user.login), user_path(current_user) -%></li> |
| 8 | <li><strong>Email:</strong> <%=h current_user.email -%></li> |
| 7 | 9 | </ul> |
| 8 | 10 | |
| 9 | 11 | <h3>Your SSH Keys:</h3> |
| … | … | |
| 19 | 19 | <% content_for :sidebar do -%> |
| 20 | 20 | <ul class="links"> |
| 21 | 21 | <li><%= link_to "+ Add SSH key", new_account_key_path -%></li> |
| 22 | | <li><%= link_to "+ Change email or password", edit_account_path -%></li> |
| 22 | <li><%= link_to "+ Edit details", edit_account_path -%></li> |
| 23 | 23 | </ul> |
| 24 | 24 | <% end -%> |
| toggle raw diff |
--- a/app/views/accounts/show.html.erb
+++ b/app/views/accounts/show.html.erb
@@ -1,9 +1,11 @@
<% @page_title = "Account" -%>
-<h2>Account details</h2>
-<ul>
- <li>username: <%= current_user.login -%></li>
- <li>email: <%= current_user.email -%></li>
+<h2>Account details <small><%= link_to "edit", edit_account_path -%></small></h2>
+<ul class="infobox">
+ <li><strong>Realname:</strong>
+ <%= current_user.fullname.blank? ? "N/A" : h(current_user.fullname) -%></li>
+ <li><strong>Username:</strong> <%= link_to h(current_user.login), user_path(current_user) -%></li>
+ <li><strong>Email:</strong> <%=h current_user.email -%></li>
</ul>
<h3>Your SSH Keys:</h3>
@@ -17,6 +19,6 @@
<% content_for :sidebar do -%>
<ul class="links">
<li><%= link_to "+ Add SSH key", new_account_key_path -%></li>
- <li><%= link_to "+ Change email or password", edit_account_path -%></li>
+ <li><%= link_to "+ Edit details", edit_account_path -%></li>
</ul>
<% end -%>
\ No newline at end of file |
| |   |
| 1 | 1 | <h1><%=h @user.login -%></h1> |
| 2 | 2 | |
| 3 | 3 | <ul class="infobox"> |
| 4 | <li><strong>Username:</strong> <%= h(@user.login) -%></li> |
| 5 | <li><strong>Realname:</strong> <%= @user.fullname.blank? ? "N/A" : h(@user.fullname) -%></li> |
| 4 | 6 | <li><strong>Email:</strong> <%= encoded_mail_to(@user.email) -%></li> |
| 5 | 7 | <li><strong>Member for</strong> <%= time_ago_in_words(@user.created_at) -%></li> |
| 6 | 8 | </ul> |
| toggle raw diff |
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -1,6 +1,8 @@
<h1><%=h @user.login -%></h1>
<ul class="infobox">
+ <li><strong>Username:</strong> <%= h(@user.login) -%></li>
+ <li><strong>Realname:</strong> <%= @user.fullname.blank? ? "N/A" : h(@user.fullname) -%></li>
<li><strong>Email:</strong> <%= encoded_mail_to(@user.email) -%></li>
<li><strong>Member for</strong> <%= time_ago_in_words(@user.created_at) -%></li>
</ul> |
| |   |
| 1 | class AddFullnameToUsers < ActiveRecord::Migration |
| 2 | def self.up |
| 3 | add_column :users, :fullname, :string |
| 4 | end |
| 5 | |
| 6 | def self.down |
| 7 | remove_column :users, :fullname |
| 8 | end |
| 9 | end |
| toggle raw diff |
--- /dev/null
+++ b/db/migrate/013_add_fullname_to_users.rb
@@ -0,0 +1,9 @@
+class AddFullnameToUsers < ActiveRecord::Migration
+ def self.up
+ add_column :users, :fullname, :string
+ end
+
+ def self.down
+ remove_column :users, :fullname
+ end
+end |
| |   |
| 9 | 9 | # |
| 10 | 10 | # It's strongly recommended to check this file into your version control system. |
| 11 | 11 | |
| 12 | | ActiveRecord::Schema.define(:version => 12) do |
| 12 | ActiveRecord::Schema.define(:version => 13) do |
| 13 | 13 | |
| 14 | 14 | create_table "permissions", :force => true do |t| |
| 15 | 15 | t.integer "user_id" |
| … | … | |
| 91 | 91 | t.string "activation_code", :limit => 40 |
| 92 | 92 | t.datetime "activated_at" |
| 93 | 93 | t.integer "ssh_key_id" |
| 94 | t.string "fullname" |
| 94 | 95 | end |
| 95 | 96 | |
| 96 | 97 | add_index "users", ["login"], :name => "index_users_on_login" |
| toggle raw diff |
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 12) do
+ActiveRecord::Schema.define(:version => 13) do
create_table "permissions", :force => true do |t|
t.integer "user_id"
@@ -91,6 +91,7 @@ ActiveRecord::Schema.define(:version => 12) do
t.string "activation_code", :limit => 40
t.datetime "activated_at"
t.integer "ssh_key_id"
+ t.string "fullname"
end
add_index "users", ["login"], :name => "index_users_on_login" |