Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/controllers/application.rb | 31 +++++++++++-----------
app/controllers/items_controller.rb | 2 +
app/controllers/products_controller.rb | 7 +++++
app/controllers/projects_controller.rb | 6 ++++
app/controllers/report_controller.rb | 4 ++-
app/controllers/roles_controller.rb | 3 ++
app/controllers/sprints_controller.rb | 9 ++++++-
app/controllers/stories_controller.rb | 44 ++++++++++++++++++-------------
app/controllers/tasks_controller.rb | 5 +++
app/controllers/users_controller.rb | 10 ++++++-
app/views/layouts/default.html.erb | 2 +-
db/schema.rb | 20 +++++++++++++-
12 files changed, 103 insertions(+), 40 deletions(-)
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 4762bfa..dc59da1 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -1,18 +1,18 @@
# application.rb
# Copyright (C) 2008, Darryl L. Pierce <mcpierce(a)gmail.com>
#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <
http://www.gnu.org/licenses/>.
#
class ApplicationController < ActionController::Base
@@ -24,14 +24,14 @@ class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
- # See ActionController::RequestForgeryProtection for details
- # Uncomment the :secret if you're not using the cookie session store
+ # See ActionController::RequestForgeryProtection for details Uncomment the
+ # :secret if you're not using the cookie session store
protect_from_forgery # :secret => '9c89a76e3c2615afe424b5811fe319f7'
# Returns whether the current user has authenticated.
#
- # An authenticated user has their user id stored in the session with
- # the key :user_id.
+ # An authenticated user has their user id stored in the session with the key
+ # :user_id.
def authenticated
if @user == nil
session[:original_uri] = request.request_uri
@@ -53,7 +53,8 @@ class ApplicationController < ActionController::Base
rescue Exception => error
puts error.backtrace
erase_results
- flash[:error] = "ERROR: #{error.message}"
+ @title = "An Error Has Occurred."
+ flash[:error] = "The following error has occurred: #{error.message}"
redirect_to error_path
end
end
diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb
index 6efd27d..957b043 100644
--- a/app/controllers/items_controller.rb
+++ b/app/controllers/items_controller.rb
@@ -25,6 +25,7 @@ class ItemsController < ApplicationController
# GET /products/1/sprints/1/items
def index
+ @title = "Sprint Backlog For #{(a)sprint.title}"
@backlog_items = BacklogItem.paginate(
:conditions => ['sprint_id = ?', @sprint.id],
:page => params[:page],
@@ -37,6 +38,7 @@ class ItemsController < ApplicationController
# GET /products/1/sprints/1/items/1
def show
+ @title = "Backlog Item (#{(a)backlog_item.user_story.title})"
respond_to do |format|
format.html
end
diff --git a/app/controllers/products_controller.rb
b/app/controllers/products_controller.rb
index 1073ee1..07bccb3 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -28,12 +28,14 @@ class ProductsController < ApplicationController
@project = Project.find_by_id(params[:project])
if @project
+ @title = "Products For #{(a)project.name}"
@products = Product.paginate(
:page => params[:page],
:per_page => 10,
:conditions => ['project_id = ?', @project.id],
:order => 'name ASC')
else
+ @title = "All Products"
@products = Product.paginate(
:page => params[:page],
:per_page => 10,
@@ -47,6 +49,7 @@ class ProductsController < ApplicationController
# GET /products/1
def show
+ @title = "#{(a)product.name} (Product)"
@project = @product.project
@sprints = Sprint.find_all_by_product_id(@product)
@backlog = UserStory.find_all_by_product_id(@product)
@@ -59,6 +62,7 @@ class ProductsController < ApplicationController
# GET /products/new
def new
if @project.can_create_products?(@user)
+ @title = "New Product"
@product = Product.new(:project_id => @project.id, :owner_id => @user.id)
@users = User.find(:all, :order => 'display_name ASC')
else
@@ -70,6 +74,7 @@ class ProductsController < ApplicationController
# GET /products/1/edit
def edit
if @product.can_edit?(@user)
+ @title = "#{(a)product.name} (Edit)"
@users = User.find(:all, :order => 'display_name ASC')
else
flash[:error] = "You are not authorized to modify #{(a)product.name}."
@@ -89,6 +94,7 @@ class ProductsController < ApplicationController
flash[:message] = "Product created successfully."
format.html { redirect_to product_path(@product) }
else
+ @title = "New Product"
@users = User.find(:all, :order => 'display_name ASC')
@product.valid?
format.html { render :action => :new }
@@ -118,6 +124,7 @@ class ProductsController < ApplicationController
flash[:message] = "#{(a)product.name} successfully updated."
format.html { redirect_to product_path(@product) }
else
+ @title = "#{(a)product.name} (Edit)"
@users = User.find(:all, :order => 'display_name ASC')
@product.valid?
format.html { render :action => :edit }
diff --git a/app/controllers/projects_controller.rb
b/app/controllers/projects_controller.rb
index bfb5963..56b8e1f 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -25,6 +25,7 @@ class ProjectsController < ApplicationController
# GET /projects
def index
+ @title = "All Projects"
@projects = Project.paginate :page => params[:page], :per_page => 10
respond_to do |format|
@@ -34,6 +35,7 @@ class ProjectsController < ApplicationController
# GET /projects/1
def show
+ @title = "#{(a)project.name} (Project)"
@products = Product.paginate_by_project_id @project.id, :page => params[:page],
:per_page => 10
respond_to do |format|
@@ -44,6 +46,7 @@ class ProjectsController < ApplicationController
# GET /projects/new
def new
if @user.can_create_projects?
+ @title = "New Project"
@project = Project.new(:owner_id => @user.id)
else
flash[:error] = "You are not authorized to create projects."
@@ -54,6 +57,7 @@ class ProjectsController < ApplicationController
# GET /projects/1/edit
def edit
+ @title = "#{(a)project.name} (Edit)"
unless @project.can_edit?(@user)
flash[:message] = "You are not authorized to modify that project."
redirect_to project_path(@project)
@@ -72,6 +76,7 @@ class ProjectsController < ApplicationController
flash[:message] = "Project '#{(a)project.name}' created!"
format.html { redirect_to project_url(@project) }
else
+ @title = "New Project"
@project.valid?
format.html { render :action => "new" }
end
@@ -98,6 +103,7 @@ class ProjectsController < ApplicationController
flash[:message] = "Project was successfully updated."
format.html { redirect_to project_path(@project) }
else
+ @title = "#{(a)project.name} (Edit)"
@project.valid?
format.html { render :action => 'edit'}
end
diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb
index ff87d55..6993fd6 100644
--- a/app/controllers/report_controller.rb
+++ b/app/controllers/report_controller.rb
@@ -22,14 +22,16 @@ class ReportController < ApplicationController
before_filter :load_user, :only => [:effort]
def index
+ @title = "Reports"
@users = User.find(:all, :order => 'display_name ASC')
end
def burndown
-
+ @title = "Burndown Chart For Sprint #{(a)sprint.id}"
end
def effort
+ @title = "Effort Report For #{(a)this_user.display_name}"
@tasks = Task.find(
:all,
:conditions => ['(primary_id = ? or backup_id = ?) and
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb
index 748a2d4..a768094 100644
--- a/app/controllers/roles_controller.rb
+++ b/app/controllers/roles_controller.rb
@@ -25,6 +25,7 @@ class RolesController < ApplicationController
# GET /products/1/roles
def index
+ @title = "#{(a)product.name} Members"
if @product.can_approve_roles?(@user)
@product_roles = ProductRole.find_all_by_product_id(@product, :order =>
'role_id ASC')
else
@@ -47,6 +48,7 @@ class RolesController < ApplicationController
# GET /products/1/roles/new
def new
+ @title = "Request A Role For #{(a)product.name}"
@role = ProductRole.find_by_product_id_and_user_id((a)product.id, @user.id)
if @role
@@ -78,6 +80,7 @@ class RolesController < ApplicationController
flash[:message] = "Your request has been sent to
#{(a)product.owner.display_name}."
format.html { redirect_to product_path(@product) }
else
+ @title = "Request A Role For #{(a)product.name}"
@roles = Role.find(:all)
@role.valid?
format.html { render :action => :new }
diff --git a/app/controllers/sprints_controller.rb
b/app/controllers/sprints_controller.rb
index 06fc83e..80b893d 100644
--- a/app/controllers/sprints_controller.rb
+++ b/app/controllers/sprints_controller.rb
@@ -23,6 +23,7 @@ class SprintsController < ApplicationController
# GET /products/1/sprints
def index
+ @title = "All Sprints For #{(a)product.name}"
@sprints = Sprint.paginate(
:page => params[:page],
:per_page => 10,
@@ -36,12 +37,14 @@ class SprintsController < ApplicationController
# GET /products/1/sprints/1
def show
+ @title = "Sprint #{(a)sprint.id}"
@backlog_items = @sprint.backlog_items
end
# GET /products/1/sprints/new
def new
if @product.can_create_sprints?(@user)
+ @title = "New Sprint For #{(a)product.name}"
@sprint = Sprint.new(:product_id => @product.id)
else
flash[:error] = "You are not authorized to create sprints for
#{(a)product.name}."
@@ -52,7 +55,7 @@ class SprintsController < ApplicationController
# GET /products/1/sprints/1/edit
def edit
-
+ @title = "Sprint #{(a)sprint.id} (Edit)"
end
# POST /products/1/sprints
@@ -66,6 +69,7 @@ class SprintsController < ApplicationController
flash[:message] = "Sprint successfully created!"
format.html { redirect_to product_sprint_path(@product,@sprint) }
else
+ @title = "New Sprint For #{(a)product.name}"
@sprint.valid?
format.html { render :action => :edit }
end
@@ -86,6 +90,7 @@ class SprintsController < ApplicationController
flash[:message] = "Sprint updated successfully."
format.html { redirect_to product_sprints_path(@product) }
else
+ @title = "Sprint #{(a)sprint.id} (Edit)"
@sprint.valid?
format.html { render :action => :edit }
end
@@ -119,6 +124,7 @@ class SprintsController < ApplicationController
respond_to do |format|
if @sprint.pending?
if @sprint.can_populate?(@user)
+ @title = "Sprint #{(a)sprint.id} (Planning)"
@user_stories = UserStory.find_all_by_product_id((a)product.id)
@estimates = Hash.new
@@ -166,6 +172,7 @@ class SprintsController < ApplicationController
flash[:message] = "Sprint backlog has been updated with
#{(a)sprint.backlog_items.size} items."
format.html { redirect_to product_sprint_path(@product, @sprint) }
else
+ @title = "Sprint #{(a)sprint.id} (Planning)"
flash[:error] = "There was an error updating the sprint backlog."
@user_stories = UserStory.find_all_by_product_id((a)product.id)
format.html { render :action => :plan }
diff --git a/app/controllers/stories_controller.rb
b/app/controllers/stories_controller.rb
index 6036079..877d0bd 100644
--- a/app/controllers/stories_controller.rb
+++ b/app/controllers/stories_controller.rb
@@ -21,6 +21,7 @@ class StoriesController < ApplicationController
before_filter :load_user_story, :except => [:index, :new, :create]
def index
+ @title = "All User Stories for #{(a)product.name}"
@user_stories = UserStory.paginate(
:page => params[:page],
:per_page => 10,
@@ -34,6 +35,7 @@ class StoriesController < ApplicationController
# GET /products/1/stories/1
def show
+ @title = "User Story - #{(a)user_story.title}"
respond_to do |format|
format.html
end
@@ -42,6 +44,7 @@ class StoriesController < ApplicationController
# GET /products/1/stories/new
def new
if @product.can_create_user_stories?(@user)
+ @title = "User Story (New)"
@user_story = UserStory.new(:product_id => @product.id)
else
flash[:error] = "You are not allowed to write user stories for
#{(a)product.name}."
@@ -52,6 +55,7 @@ class StoriesController < ApplicationController
# GET /products/1/stories/1/edit
def edit
if @user_story.can_edit?(@user)
+ @title = "User Story - #{(a)user_story.title} (Edit)"
unless @product.id == @user_story.product_id
flash[:error] = "This user story does not belong to that product."
redirect_to product_stories_path(@product)
@@ -66,18 +70,19 @@ class StoriesController < ApplicationController
def create
respond_to do |format|
if @product.can_create_user_stories?(@user)
- UserStory.transaction do
- @user_story = UserStory.new(params[:user_story])
- @user_story.product = @product
-
- if @user_story.save
- flash[:message] = "The user story was successfully created."
- format.html { redirect_to product_stories_path(@product) }
- else
- @user_story.valid?
- format.html { render :action => :edit }
- end
+ UserStory.transaction do
+ @user_story = UserStory.new(params[:user_story])
+ @user_story.product = @product
+
+ if @user_story.save
+ flash[:message] = "The user story was successfully created."
+ format.html { redirect_to product_stories_path(@product) }
+ else
+ @title = "User Story (New)"
+ @user_story.valid?
+ format.html { render :action => :edit }
end
+ end
else
flash[:error] = "You are not allowed to write user stories for
#{(a)product.name}."
format.html { redirect_to product_stories_path(@product) }
@@ -88,17 +93,18 @@ class StoriesController < ApplicationController
def update
respond_to do |format|
if @user_story.can_edit?(@user)
- UserStory.transaction do
- @user_story.update_attributes(params[:user_story])
-
- if @user_story.save
- flash[:message] = "The user story was successfully updated."
- format.html { redirect_to product_stories_path(@product) }
- else
- @user_story.valid?
- format.html { render :action => :edit }
- end
+ UserStory.transaction do
+ @user_story.update_attributes(params[:user_story])
+
+ if @user_story.save
+ flash[:message] = "The user story was successfully updated."
+ format.html { redirect_to product_stories_path(@product) }
+ else
+ @title = "User Story - #{(a)user_story.title} (Edit)"
+ @user_story.valid?
+ format.html { render :action => :edit }
end
+ end
else
flash[:error] = "You are not authorized to edit user stories for
#{(a)product.name}."
format.html { redirect_to product_story_path(@product, @user_story) }
diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb
index b98d4c3..3c88a6e 100644
--- a/app/controllers/tasks_controller.rb
+++ b/app/controllers/tasks_controller.rb
@@ -39,6 +39,7 @@ class TasksController < ApplicationController
# GET /tasks/1
def show
+ @title = "Task For Backlog Item #{(a)task.backlog_item.id}"
respond_to do |format|
format.html
end
@@ -48,6 +49,7 @@ class TasksController < ApplicationController
def new
if @user.id == @this_user.id
if @backlog_item.can_add_tasks?(@user)
+ @title = "New Task For
\"#{(a)backlog_item.user_story.title}\""
@task = Task.new(:primary_id => @this_user.id, :backlog_item_id =>
@backlog_item.id)
@users = load_product_members
else
@@ -63,6 +65,7 @@ class TasksController < ApplicationController
# GET /tasks/1/edit
def edit
+ @title = "Task For Backlog Item #{(a)task.backlog_item.id} (Edit)"
@users = load_product_members
unless @task.can_edit?(@user)
flash[:error] = "You are not allowed to edit this task."
@@ -84,6 +87,7 @@ class TasksController < ApplicationController
flash[:message] = "Recorded #{(a)task.hours} against this backlog
item."
format.html { redirect_to product_sprint_item_path(@product, @sprint,
@backlog_item) }
else
+ @title = "New Task For
\"#{(a)backlog_item.user_story.title}\""
@task.valid?
@users = load_product_members
format.html { render :action => :new }
@@ -109,6 +113,7 @@ class TasksController < ApplicationController
if @task.save
else
+ @title = "Task For Backlog Item #{(a)task.backlog_item.id} (Edit)"
@users = load_product_members
@task.valid?
format.html { render :action => :edit }
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index d1ff88a..f91a6c6 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -21,6 +21,7 @@ class UsersController < ApplicationController
# GET /users
def index
+ @title = "All Users"
@users = User.paginate(
:order => 'display_name ASC',
:page => params[:page],
@@ -29,14 +30,14 @@ class UsersController < ApplicationController
# GET /users/1
def show
+ @title = "#{(a)this_user.display_name}"
end
# GET /users/new
def new
if (@user == nil) || (@user.create_users?)
@this_user = User.new
-
-
+ @title = "User Account (New)"
else
flash[:error] = "You cannot create a new user account."
redirect_to users_path
@@ -45,6 +46,7 @@ class UsersController < ApplicationController
# GET /users/1/edit
def edit
+ @title = "#{(a)this_user.display_name} (Edit)"
unless @this_user.can_edit?(@user)
flash[:error] = "You are not authorized to edit that account."
redirect_to users_path
@@ -67,6 +69,7 @@ class UsersController < ApplicationController
flash[:message] = "An email verification has been sent to
#{(a)this_user.email}."
format.html { redirect_to user_path(@this_user) }
else
+ @title = "User Account (New)"
@this_user.valid?
format.html { render :action => :edit }
end
@@ -87,6 +90,7 @@ class UsersController < ApplicationController
flash[:message] = "User has been updated."
format.html { redirect_to user_path }
else
+ @title = "#{(a)this_user.display_name} (Edit)"
@this_user.valid?
format.html { render :action => :edit }
end
@@ -99,6 +103,7 @@ class UsersController < ApplicationController
# GET /users/1/backlog
def backlog
+ @title = "Backlog For #{(a)this_user.display_name}"
@backlog_items = BacklogItem.paginate(
:conditions => ['owner_id = ?', @this_user.id],
:page => params[:page],
@@ -120,6 +125,7 @@ class UsersController < ApplicationController
format.html { redirect_to user_path(@user) }
end
else
+ @title = "Email Verification For #{(a)user.email}"
flash[:error] = "Missing or invalid verification token."
format.html
end
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 0babca4..94d0d0a 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -1,7 +1,7 @@
<html>
<head>
- <title>ProjXP</title>
+ <title>ProjXP<%= @title ? " - #{@title}" : ""
%></title>
<%= javascript_include_tag :defaults %>
diff --git a/db/schema.rb b/db/schema.rb
index 1d72930..c231a75 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version => 17) do
end
add_index "backlog_items", ["sprint_id",
"user_story_id"], :name =>
"index_backlog_items_on_sprint_id_and_user_story_id", :unique => true
+ add_index "backlog_items", ["user_story_id"], :name =>
"fk_backlog_items_user_story"
create_table "product_roles", :force => true do |t|
t.integer "user_id", :null => false
@@ -34,7 +35,9 @@ ActiveRecord::Schema.define(:version => 17) do
t.boolean "is_approved", :default => false
end
- add_index "product_roles", ["product_id", "user_id"],
:name => "index_product_roles_on_user_id_and_product_id", :unique => true
+ add_index "product_roles", ["user_id", "product_id"],
:name => "index_product_roles_on_user_id_and_product_id", :unique => true
+ add_index "product_roles", ["product_id"], :name =>
"fk_user_role_product"
+ add_index "product_roles", ["role_id"], :name =>
"fk_user_role_role"
create_table "products", :force => true do |t|
t.integer "project_id"
@@ -46,6 +49,7 @@ ActiveRecord::Schema.define(:version => 17) do
end
add_index "products", ["name"], :name =>
"index_products_on_name", :unique => true
+ add_index "products", ["project_id"], :name =>
"fk_products_project"
create_table "projects", :force => true do |t|
t.integer "owner_id", :null => false
@@ -57,6 +61,7 @@ ActiveRecord::Schema.define(:version => 17) do
end
add_index "projects", ["name"], :name =>
"index_projects_on_name", :unique => true
+ add_index "projects", ["owner_id"], :name =>
"fk_product_owner"
create_table "remaining_hours_estimates", :force => true do |t|
t.integer "backlog_item_id", :null =>
false
@@ -67,6 +72,9 @@ ActiveRecord::Schema.define(:version => 17) do
t.datetime "estimated_on", :null =>
false
end
+ add_index "remaining_hours_estimates", ["backlog_item_id"], :name
=> "fk_remaining_hours_item"
+ add_index "remaining_hours_estimates", ["user_id"], :name =>
"fk_remaining_hours_user"
+
create_table "roles", :force => true do |t|
t.string "name", :null =>
false
t.boolean "can_manage_backlog_items", :default => false, :null =>
false
@@ -98,6 +106,8 @@ ActiveRecord::Schema.define(:version => 17) do
t.integer "status", :default => 0, :null =>
false
end
+ add_index "sprints", ["product_id"], :name =>
"fk_sprint_product"
+
create_table "tasks", :force => true do |t|
t.integer "backlog_item_id",
:null => false
t.integer "primary_id",
:null => false
@@ -109,6 +119,10 @@ ActiveRecord::Schema.define(:version => 17) do
t.datetime "updated_at"
end
+ add_index "tasks", ["backlog_item_id"], :name =>
"fk_task_backlog_item"
+ add_index "tasks", ["primary_id"], :name =>
"fk_task_primary"
+ add_index "tasks", ["backup_id"], :name =>
"fk_task_backup"
+
create_table "user_privileges", :force => true do |t|
t.integer "user_id", :null => false
t.boolean "admin_projects", :default => false, :null => false
@@ -117,6 +131,8 @@ ActiveRecord::Schema.define(:version => 17) do
t.datetime "updated_at"
end
+ add_index "user_privileges", ["user_id"], :name =>
"fk_privilege_user"
+
create_table "user_stories", :force => true do |t|
t.integer "product_id"
t.integer "priority"
@@ -127,6 +143,8 @@ ActiveRecord::Schema.define(:version => 17) do
t.datetime "updated_at"
end
+ add_index "user_stories", ["product_id"], :name =>
"fk_user_story_product"
+
create_table "user_verifications", :force => true do |t|
t.integer "user_id", :null => false
t.string "token", :limit => 16, :null => false
--
1.6.0.2