Skip to content

Commit 6542539

Browse files
author
root
committedJan 15, 2010
tasklist version
1 parent c6ad019 commit 6542539

31 files changed

+3237
-3
lines changed
 
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
class TasklistsController < ApplicationController
2+
def index
3+
@tasklists = Tasklist.all
4+
end
5+
6+
def show
7+
@tasklist = Tasklist.find(params[:id])
8+
end
9+
10+
def new
11+
@tasklist = Tasklist.new
12+
end
13+
14+
def create
15+
@users = User.find(:all)
16+
@tasklist = Tasklist.new(params[:tasklist])
17+
if @tasklist.save
18+
flash[:notice] = "Successfully created tasklist."
19+
redirect_to @tasklist
20+
else
21+
render :action => 'new'
22+
end
23+
end
24+
25+
def edit
26+
@users = User.find(:all)
27+
@tasklist = Tasklist.find(params[:id])
28+
end
29+
30+
def update
31+
@users = User.find(:all)
32+
@tasklist = Tasklist.find(params[:id])
33+
if @tasklist.update_attributes(params[:tasklist])
34+
flash[:notice] = "Successfully updated tasklist."
35+
redirect_to @tasklist
36+
else
37+
render :action => 'edit'
38+
end
39+
end
40+
41+
def destroy
42+
@tasklist = Tasklist.find(params[:id])
43+
@tasklist.destroy
44+
flash[:notice] = "Successfully destroyed tasklist."
45+
redirect_to tasklists_url
46+
end
47+
end

‎app/controllers/users_controller.rb

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
class UsersController < ApplicationController
2+
def index
3+
@users = User.all
4+
end
5+
6+
def show
7+
@user = User.find(params[:id])
8+
end
9+
10+
def new
11+
@user = User.new
12+
end
13+
14+
def create
15+
@user = User.new(params[:user])
16+
if @user.save
17+
flash[:notice] = "Successfully created user."
18+
redirect_to @user
19+
else
20+
render :action => 'new'
21+
end
22+
end
23+
24+
def edit
25+
@user = User.find(params[:id])
26+
end
27+
28+
def update
29+
@user = User.find(params[:id])
30+
if @user.update_attributes(params[:user])
31+
flash[:notice] = "Successfully updated user."
32+
redirect_to @user
33+
else
34+
render :action => 'edit'
35+
end
36+
end
37+
38+
def destroy
39+
@user = User.find(params[:id])
40+
@user.destroy
41+
flash[:notice] = "Successfully destroyed user."
42+
redirect_to users_url
43+
end
44+
end

‎app/helpers/layout_helper.rb

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# These helper methods can be called in your template to set variables to be used in the layout
2+
# This module should be included in all views globally,
3+
# to do so you may need to add this line to your ApplicationController
4+
# helper :layout
5+
module LayoutHelper
6+
def title(page_title, show_title = true)
7+
@content_for_title = page_title.to_s
8+
@show_title = show_title
9+
end
10+
11+
def show_title?
12+
@show_title
13+
end
14+
15+
def stylesheet(*args)
16+
content_for(:head) { stylesheet_link_tag(*args) }
17+
end
18+
19+
def javascript(*args)
20+
content_for(:head) { javascript_include_tag(*args) }
21+
end
22+
end

‎app/helpers/tasklists_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module TasklistsHelper
2+
end

‎app/helpers/users_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module UsersHelper
2+
end

‎app/models/tasklist.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Tasklist < ActiveRecord::Base
2+
3+
belongs_to :user
4+
5+
attr_accessible :name, :scope, :genre, :project, :description, :user_id, :due_date, :status
6+
7+
validates_presence_of :name, :scope, :project, :due_date, :status
8+
9+
end

‎app/models/user.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class User < ActiveRecord::Base
2+
3+
attr_accessible :name, :shortname
4+
5+
has_many :tasklists, :dependent => :destroy
6+
7+
validates_presence_of :name, :shortname
8+
validates_associated :tasklists
9+
10+
end
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
<html>
4+
<head>
5+
<title><%= h(yield(:title) || "Untitled") %></title>
6+
<%= stylesheet_link_tag 'application' %>
7+
<%= yield(:head) %>
8+
</head>
9+
<body>
10+
<div id="container">
11+
<%- flash.each do |name, msg| -%>
12+
<%= content_tag :div, msg, :id => "flash_#{name}" %>
13+
<%- end -%>
14+
15+
<%- if show_title? -%>
16+
<h1><%=h yield(:title) %></h1>
17+
<%- end -%>
18+
19+
<%= yield %>
20+
</div>
21+
</body>
22+
</html>

‎app/views/tasklists/_form.html.erb

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<% form_for @tasklist do |f| %>
2+
<%= f.error_messages %>
3+
<p>
4+
<%= f.label :name %><br />
5+
<%= f.text_field :name %>
6+
</p>
7+
<p>
8+
<%= f.label :scope %><br />
9+
<%= f.text_field :scope %>
10+
</p>
11+
<p>
12+
<%= f.label :genre %><br />
13+
<%= f.text_field :genre %>
14+
</p>
15+
<p>
16+
<%= f.label :project %><br />
17+
<%= f.text_field :project %>
18+
</p>
19+
<p>
20+
<%= f.label :assigned_to %><br />
21+
<%= collection_select (:tasklist, :user_id, User.find(:all), :id, :shortname, {:prompt => true}) %>
22+
</p>
23+
<p>
24+
<%= f.label :description %><br />
25+
<%= f.text_area :description %>
26+
</p>
27+
<p>
28+
<%= f.label :due_date %><br />
29+
<%= f.date_select :due_date %>
30+
</p>
31+
<p>
32+
<%= f.label :status %><br />
33+
<%= f.text_field :status %>
34+
</p>
35+
<p><%= f.submit "Submit" %></p>
36+
<% end %>

‎app/views/tasklists/edit.html.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% title "Edit Tasklist" %>
2+
3+
<%= render :partial => 'form' %>
4+
5+
<p>
6+
<%= link_to "Show", @tasklist %> |
7+
<%= link_to "View All", tasklists_path %>
8+
</p>

‎app/views/tasklists/index.html.erb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<% title "Tasklists" %>
2+
3+
<table>
4+
<tr>
5+
<th>Name</th>
6+
<th>Scope</th>
7+
<th>Genre</th>
8+
<th>Project</th>
9+
<th>User</th>
10+
<th>Description</th>
11+
<th>Due Date</th>
12+
<th>Status</th>
13+
</tr>
14+
<% for tasklist in @tasklists %>
15+
<tr>
16+
<td><%=h tasklist.name %></td>
17+
<td><%=h tasklist.scope %></td>
18+
<td><%=h tasklist.genre %></td>
19+
<td><%=h tasklist.project %></td>
20+
<td><%=h tasklist.user.shortname %></td>
21+
<td><%=h tasklist.description %></td>
22+
<td><%=h tasklist.due_date %></td>
23+
<td><%=h tasklist.status %></td>
24+
<td><%= link_to "Show", tasklist %></td>
25+
<td><%= link_to "Edit", edit_tasklist_path(tasklist) %></td>
26+
<td><%= link_to "Destroy", tasklist, :confirm => 'Are you sure?', :method => :delete %></td>
27+
</tr>
28+
<% end %>
29+
</table>
30+
31+
<p><%= link_to "New Tasklist", new_tasklist_path %></p>

‎app/views/tasklists/new.html.erb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% title "New Tasklist" %>
2+
3+
<%= render :partial => 'form' %>
4+
5+
<p><%= link_to "Back to List", tasklists_path %></p>

‎app/views/tasklists/show.html.erb

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<% title "Tasklist" %>
2+
3+
<p>
4+
<strong>Name:</strong>
5+
<%=h @tasklist.name %>
6+
</p>
7+
<p>
8+
<strong>Scope:</strong>
9+
<%=h @tasklist.scope %>
10+
</p>
11+
<p>
12+
<strong>Type:</strong>
13+
<%=h @tasklist.genre %>
14+
</p>
15+
<p>
16+
<strong>Project:</strong>
17+
<%=h @tasklist.project %>
18+
</p>
19+
<p>
20+
<strong>Assigned To:</strong>
21+
<%=h @tasklist.user.shortname %>
22+
</p>
23+
<p>
24+
<strong>Description:</strong>
25+
<%=h @tasklist.description %>
26+
</p>
27+
<p>
28+
<strong>Due Date:</strong>
29+
<%=h @tasklist.due_date %>
30+
</p>
31+
<p>
32+
<strong>Status:</strong>
33+
<%=h @tasklist.status %>
34+
</p>
35+
36+
<p>
37+
<%= link_to "Edit", edit_tasklist_path(@tasklist) %> |
38+
<%= link_to "Destroy", @tasklist, :confirm => 'Are you sure?', :method => :delete %> |
39+
<%= link_to "View All", tasklists_path %>
40+
</p>

‎app/views/users/_form.html.erb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% form_for @user do |f| %>
2+
<%= f.error_messages %>
3+
<p>
4+
<%= f.label :name %><br />
5+
<%= f.text_field :name %>
6+
</p>
7+
<p>
8+
<%= f.label :shortname %><br />
9+
<%= f.text_field :shortname %>
10+
</p>
11+
<p><%= f.submit "Submit" %></p>
12+
<% end %>

‎app/views/users/edit.html.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% title "Edit User" %>
2+
3+
<%= render :partial => 'form' %>
4+
5+
<p>
6+
<%= link_to "Show", @user %> |
7+
<%= link_to "View All", users_path %>
8+
</p>

‎app/views/users/index.html.erb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<% title "Users" %>
2+
3+
<table>
4+
<tr>
5+
<th>Name</th>
6+
<th>Shortname</th>
7+
</tr>
8+
<% for user in @users %>
9+
<tr>
10+
<td><%=h user.name %></td>
11+
<td><%=h user.shortname %></td>
12+
<td><%= link_to "Show", user %></td>
13+
<td><%= link_to "Edit", edit_user_path(user) %></td>
14+
<td><%= link_to "Destroy", user, :confirm => 'Are you sure?', :method => :delete %></td>
15+
</tr>
16+
<% end %>
17+
</table>
18+
19+
<p><%= link_to "New User", new_user_path %></p>

‎app/views/users/new.html.erb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% title "New User" %>
2+
3+
<%= render :partial => 'form' %>
4+
5+
<p><%= link_to "Back to List", users_path %></p>

‎app/views/users/show.html.erb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<% title "User" %>
2+
3+
<p>
4+
<strong>Name:</strong>
5+
<%=h @user.name %>
6+
</p>
7+
<p>
8+
<strong>Shortname:</strong>
9+
<%=h @user.shortname %>
10+
</p>
11+
12+
<p>
13+
<%= link_to "Edit", edit_user_path(@user) %> |
14+
<%= link_to "Destroy", @user, :confirm => 'Are you sure?', :method => :delete %> |
15+
<%= link_to "View All", users_path %>
16+
</p>

‎config/database.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ development:
2121
database: tasklist_development
2222
pool: 5
2323
username: root
24-
password:
24+
password: sys64738
2525
socket: /var/run/mysqld/mysqld.sock
2626

2727
# Warning: The database defined as "test" will be erased and
@@ -34,7 +34,7 @@ test:
3434
database: tasklist_test
3535
pool: 5
3636
username: root
37-
password:
37+
password: sys64738
3838
socket: /var/run/mysqld/mysqld.sock
3939

4040
production:
@@ -44,5 +44,5 @@ production:
4444
database: tasklist_production
4545
pool: 5
4646
username: root
47-
password:
47+
password: sys64738
4848
socket: /var/run/mysqld/mysqld.sock

‎config/routes.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
ActionController::Routing::Routes.draw do |map|
2+
map.resources :users
3+
4+
map.resources :tasklists
5+
26
# The priority is based upon order of creation: first created -> highest priority.
37

48
# Sample of regular route:

0 commit comments

Comments
 (0)
Please sign in to comment.