Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:stcorbett/funding
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Corbett committed Apr 3, 2010
2 parents c2a60ea + 5a0d7e6 commit 3304f19
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 9 deletions.
16 changes: 12 additions & 4 deletions app/controllers/trustees_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
class TrusteesController < ApplicationController

before_filter :require_no_user, :only => [:new, :create]

def index
@trustee = Trustee.new
@user = User.new
end

def create
@trustee = Trustee.create(params[:trustee])
flash[:notice] = "Thanks! We will send information about the upcomming grants in the next few weeks."
redirect_to :action => :index
@user = User.new(params[:user])

if @user.save
flash[:notice] = "Thanks! We will send information about the upcomming grants in the next few weeks."
redirect_back_or_default account_url
else
render :action => :index
end

end

def success
Expand Down
22 changes: 22 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class UsersController < ApplicationController
before_filter :require_user, :only => [:show, :edit, :update]

def show
@user = @current_user
end

def edit
@user = @current_user
end

def update
@user = @current_user # makes our views "cleaner" and more consistent
if @user.update_attributes(params[:user])
flash[:notice] = "Account updated!"
redirect_to account_url
else
render :action => :edit
end
end
end

9 changes: 9 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
class User < ActiveRecord::Base
acts_as_authentic

after_create :email_trustee_app

private

def email_trustee_app
TrusteeMailer.deliver_trustee_app(self)
end

end
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<% if !current_user %>
<%= link_to "Log In", new_user_session_path %> |
<% else %>
<%#= link_to "My Account", account_path %> |
<%= link_to "My Account", account_path %> |
<%= link_to "Logout", user_session_path, :method => :delete, :confirm => "Are you sure you want to logout?" %>
<% end %>
Expand Down
20 changes: 18 additions & 2 deletions app/views/trustees/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,35 @@ Trustees are invited to these events and encouraged to attend.
%p
Send us some links to your online identity and we will get in touch when the next grant is being organized.

- form_for @trustee do |f|
- form_for(@user, :url => trustees_path) do |f|

= f.error_messages

%p.left
= f.label :name, "Name"
%br
= f.text_field :name, :style => "width: 100px;"

%p.left.left_margin_15
= f.label :email, "Email"
%br
= f.text_field :email, :style => "width: 100px;"
= f.text_field :email, :style => "width: 200px;"

%p.left.left_margin_15
= f.label :password, "Password"
%br
= f.password_field :password, :style => "width: 100px;"

%p.left.left_margin_15
= f.label :password_confirmation, "Password Confirmation"
%br
= f.password_field :password_confirmation, :style => "width: 100px;"

%p.left.left_margin_15
= f.label :url, "Url"
%br
= f.text_field :url, :style => "width: 100px;"

%p.left.left_margin_15
= f.label :organization, "Organization"
%br
Expand Down
19 changes: 19 additions & 0 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1>Edit My Account</h1>

<% form_for @user, :url => account_path do |f| %>
<%= f.error_messages %>
<%= f.label :email %><br />
<%= f.text_field :email %><br />
<br />
<%= f.label :password, "Change password" %><br />
<%= f.password_field :password %><br />
<br />
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %><br />

<%= f.submit "Update" %>
<% end %>

<br /><%= link_to "My Profile", account_path %>

38 changes: 38 additions & 0 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<p>
<b>email:</b>
<%=h @user.email %>
</p>

<p>
<b>Login count:</b>
<%=h @user.login_count %>
</p>

<p>
<b>Last request at:</b>
<%=h @user.last_request_at %>
</p>

<p>
<b>Last login at:</b>
<%=h @user.last_login_at %>
</p>

<p>
<b>Current login at:</b>
<%=h @user.current_login_at %>
</p>

<p>
<b>Last login ip:</b>
<%=h @user.last_login_ip %>
</p>

<p>
<b>Current login ip:</b>
<%=h @user.current_login_ip %>
</p>


<%= link_to 'Edit', edit_account_path %>

4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

map.resource :dictionary

# User and Session stuff
map.resource :account, :controller => "users"
map.resources :users
map.resource :user_session


# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20100403225813_add_name_to_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddNameToUser < ActiveRecord::Migration
def self.up
add_column :users, :name, :string
end

def self.down
remove_column :users, :name
end
end
9 changes: 9 additions & 0 deletions db/migrate/20100403225832_add_url_to_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddUrlToUser < ActiveRecord::Migration
def self.up
add_column :users, :url, :string
end

def self.down
remove_column :users, :url
end
end
11 changes: 11 additions & 0 deletions db/migrate/20100403225857_add_organization_to_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddOrganizationToUser < ActiveRecord::Migration
def self.up
add_column :users, :organization, :string
add_column :users, :twitter, :string
end

def self.down
remove_column :users, :twitter
remove_column :users, :organization
end
end
6 changes: 5 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20100403221531) do
ActiveRecord::Schema.define(:version => 20100403225857) do

create_table "entries", :force => true do |t|
t.string "company_name"
Expand Down Expand Up @@ -59,6 +59,10 @@
t.string "last_login_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
t.string "url"
t.string "organization"
t.string "twitter"
end

end

0 comments on commit 3304f19

Please sign in to comment.