Changed all instances of @response, @request, @session etc. to the new forms or response, request, session etc.

Fixes #266



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@239 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2006-05-13 13:32:39 +00:00
parent ca8a386dd7
commit eefbb70660
23 changed files with 114 additions and 134 deletions

View file

@ -32,7 +32,7 @@ class ContextController < ApplicationController
#
def new_context
context = @user.contexts.build
context.attributes = @params['context']
context.attributes = params['context']
context.name = deurlize(context.name)
if context.save
@ -49,10 +49,10 @@ class ContextController < ApplicationController
def add_item
self.init
@item = @user.todos.build
@item.attributes = @params["todo"]
@item.attributes = params["todo"]
if @item.due?
@item.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
@ -140,7 +140,7 @@ class ContextController < ApplicationController
#
def update
check_user_set_context
@context.attributes = @params["context"]
@context.attributes = params["context"]
@context.name = deurlize(@context.name)
if @context.save
render_partial 'context_listing', @context
@ -166,7 +166,7 @@ class ContextController < ApplicationController
# Methods for changing the sort order of the contexts in the list
#
def order
@params["list-contexts"].each_with_index do |id, position|
params["list-contexts"].each_with_index do |id, position|
if check_user_matches_context_user(id)
Context.update(id, :position => position + 1)
end
@ -177,10 +177,10 @@ class ContextController < ApplicationController
protected
def check_user_set_context
if @params["name"]
@context = Context.find_by_name_and_user_id(deurlize(@params["name"]), @user.id)
elsif @params['id']
@context = Context.find_by_id_and_user_id(@params["id"], @user.id)
if params["name"]
@context = Context.find_by_name_and_user_id(deurlize(params["name"]), @user.id)
elsif params['id']
@context = Context.find_by_id_and_user_id(params["id"], @user.id)
else
redirect_to(:controller => "context", :action => "list" )
end
@ -205,7 +205,7 @@ class ContextController < ApplicationController
end
def check_user_return_item
item = Todo.find( @params['id'] )
item = Todo.find( params['id'] )
if @user == item.user
return item
else

View file

@ -14,7 +14,7 @@ class FeedController < ApplicationController
# Build an RSS feed
def rss
prepare_for_feed
@headers["Content-Type"] = "text/xml; charset=utf-8"
headers["Content-Type"] = "text/xml; charset=utf-8"
end
# Builds a plain text page listing uncompleted next actions,
@ -27,12 +27,12 @@ class FeedController < ApplicationController
#
def text
prepare_for_feed
if @params.key?('context')
@contexts = [ @user.contexts.find(@params['context']) ]
if params.key?('context')
@contexts = [ @user.contexts.find(params['context']) ]
else
@contexts = @user.contexts.find_all_by_hide(false, "position ASC")
end
@headers["Content-Type"] = "text/plain; charset=utf-8"
headers["Content-Type"] = "text/plain; charset=utf-8"
end
# Builds an iCal compatible export of uncompleted todos
@ -41,32 +41,32 @@ class FeedController < ApplicationController
#
def ical
prepare_for_feed
if @params.key?('context')
@contexts = [ @user.contexts.find(@params['context']) ]
if params.key?('context')
@contexts = [ @user.contexts.find(params['context']) ]
else
@contexts = @user.contexts.find_all_by_hide(false, "position ASC")
end
@headers["Content-Type"] = "text/plain; charset=utf-8"
headers["Content-Type"] = "text/plain; charset=utf-8"
end
def list_projects_only
@projects = @user.projects
@description = "Lists all the projects for #{@user.login}."
render :action => 'projects_' + @params['feedtype']
render :action => 'projects_' + params['feedtype']
end
def list_contexts_only
@contexts = @user.contexts
@description = "Lists all the contexts for #{@user.login}."
render :action => 'contexts_' + @params['feedtype']
render :action => 'contexts_' + params['feedtype']
end
protected
# Check whether the token in the URL matches the word in the User's table
def check_token_against_user_word
@user = User.find_by_login( @params['name'] )
unless ( @params['token'] == @user.word)
@user = User.find_by_login( params['name'] )
unless ( params['token'] == @user.word)
render :text => "Sorry, you don't have permission to view this page."
return false
end
@ -78,15 +78,15 @@ protected
condition_builder.add 'todos.done = ?', false
if @params.key?('limit')
options[:limit] = limit = @params['limit']
if params.key?('limit')
options[:limit] = limit = params['limit']
@description = limit ? "Lists the last #{limit} uncompleted next actions" : "Lists uncompleted next actions"
end
@title = "Tracks - Next Actions"
@description = "Filter: "
if @params.key?('due')
due_within = @params['due'].to_i
if params.key?('due')
due_within = params['due'].to_i
condition_builder.add('todos.due <= ?', due_within.days.from_now)
due_within_date_s = due_within.days.from_now.strftime("%Y-%m-%d")
@title << " due today" if (due_within == 0)
@ -94,15 +94,15 @@ protected
@description << " with a due date #{due_within_date_s} or earlier"
end
if @params.key?('context')
context = @user.contexts.find(@params['context'])
if params.key?('context')
context = @user.contexts.find(params['context'])
condition_builder.add('todos.context_id = ?', context.id)
@title << " in #{context.name}"
@description << " in context '#{context.name}'"
end
if @params.key?('project')
project = @user.projects.find(@params['project'])
if params.key?('project')
project = @user.projects.find(params['project'])
condition_builder.add('todos.project_id = ?', project.id)
@title << " for #{project.name}"
@description << " for project '#{project.name}'"
@ -119,16 +119,16 @@ protected
def initialize
@queries = Array.new
@params = Array.new
params = Array.new
end
def add(query, param)
@queries << query
@params << param
params << param
end
def to_conditions
[@queries.join(' AND ')] + @params
[@queries.join(' AND ')] + params
end
end

View file

@ -5,13 +5,13 @@ class LoginController < ApplicationController
def login
@page_title = "TRACKS::Login"
case @request.method
case request.method
when :post
if @user = User.authenticate(@params['user_login'], @params['user_password'])
if @user = User.authenticate(params['user_login'], params['user_password'])
session['user_id'] = @user.id
# If checkbox on login page checked, we don't expire the session after 1 hour
# of inactivity
session['noexpiry']= @params['user_noexpiry']
session['noexpiry']= params['user_noexpiry']
if session['noexpiry'] == "on"
msg = "will not expire."
else
@ -20,7 +20,7 @@ class LoginController < ApplicationController
flash['notice'] = "Login successful: session #{msg}"
redirect_back_or_default :controller => "todo", :action => "list"
else
@login = @params['user_login']
@login = params['user_login']
flash['warning'] = "Login unsuccessful"
end
end
@ -56,7 +56,7 @@ class LoginController < ApplicationController
end
def create
user = User.new(@params['user'])
user = User.new(params['user'])
unless user.valid?
session['new_user'] = user
redirect_to :controller => 'login', :action => 'signup'
@ -65,7 +65,7 @@ class LoginController < ApplicationController
user.is_admin = true if User.find_all.empty?
if user.save
@user = User.authenticate(user.login, @params['user']['password'])
@user = User.authenticate(user.login, params['user']['password'])
@user.preferences = { "date_format" => "%d/%m/%Y", "week_starts" => "1", "no_completed" => "5", "staleness_starts" => "7", "due_style" => "1", "admin_email" => "butshesagirl@rousette.org.uk"}
@user.save
flash['notice'] = "Signup successful for user #{@user.login}."
@ -74,8 +74,8 @@ class LoginController < ApplicationController
end
def delete
if @params['id'] and ( @params['id'] = @user.id or @user.is_admin )
@user = User.find(@params['id'])
if params['id'] and ( params['id'] = @user.id or @user.is_admin )
@user = User.find(params['id'])
# TODO: Maybe it would be better to mark deleted. That way user deletes can be reversed.
@user.destroy
end

View file

@ -19,7 +19,7 @@ class NoteController < ApplicationController
#
def add
note = @user.notes.build
note.attributes = @params["new_note"]
note.attributes = params["new_note"]
if note.save
render_partial 'notes_summary', note
@ -40,7 +40,7 @@ class NoteController < ApplicationController
def update
note = check_user_return_note
note.attributes = @params["note"]
note.attributes = params["note"]
if note.save
render_partial 'notes', note
else
@ -52,7 +52,7 @@ class NoteController < ApplicationController
protected
def check_user_return_note
note = Note.find_by_id( @params['id'] )
note = Note.find_by_id( params['id'] )
if @user == note.user
return note
else

View file

@ -55,7 +55,7 @@ class ProjectController < ApplicationController
def new_project
project = @user.projects.build
project.attributes = @params['project']
project.attributes = params['project']
project.name = deurlize(project.name)
if project.save
@ -72,10 +72,10 @@ class ProjectController < ApplicationController
def add_item
self.init
@item = @user.todos.build
@item.attributes = @params["todo"]
@item.attributes = params["todo"]
if @item.due?
@item.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
@ -165,7 +165,7 @@ class ProjectController < ApplicationController
#
def update
check_user_set_project
@project.attributes = @params["project"]
@project.attributes = params["project"]
@project.name = deurlize(@project.name)
if @project.save
render_partial 'project_listing', @project
@ -201,7 +201,7 @@ class ProjectController < ApplicationController
# Methods for changing the sort order of the projects in the list
#
def order
@params["list-projects"].each_with_index do |id, position|
params["list-projects"].each_with_index do |id, position|
if check_user_matches_project_user(id)
Project.update(id, :position => position + 1)
end
@ -212,10 +212,10 @@ class ProjectController < ApplicationController
protected
def check_user_set_project
if @params["name"]
@project = Project.find_by_name_and_user_id(deurlize(@params["name"]), @user.id)
elsif @params['id']
@project = Project.find_by_id_and_user_id(@params["id"], @user.id)
if params["name"]
@project = Project.find_by_name_and_user_id(deurlize(params["name"]), @user.id)
elsif params['id']
@project = Project.find_by_id_and_user_id(params["id"], @user.id)
else
redirect_to(:controller => "project", :action => "list" )
end
@ -240,7 +240,7 @@ class ProjectController < ApplicationController
end
def check_user_return_item
item = Todo.find( @params['id'] )
item = Todo.find( params['id'] )
if @user == item.user
return item
else

View file

@ -49,10 +49,10 @@ class TodoController < ApplicationController
def add_item
self.init
@item = @user.todos.build
@item.attributes = @params["todo"]
@item.attributes = params["todo"]
if @item.due?
@item.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
@item.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
@ -87,10 +87,10 @@ class TodoController < ApplicationController
#
def add_deferred_item
self.init
@tickle = Deferred.create(@params["todo"])
@tickle = Deferred.create(params["todo"])
if @tickle.due?
@tickle.due = Date.strptime(@params["todo"]["due"], @user.preferences["date_format"])
@tickle.due = Date.strptime(params["todo"]["due"], @user.preferences["date_format"])
else
@tickle.due = ""
end
@ -162,15 +162,15 @@ class TodoController < ApplicationController
#
def update_action
self.init
if @params["on_project_page"] == true
if params["on_project_page"] == true
@on_page = "project"
end
@item = check_user_return_item
@original_item_context_id = @item.context_id
@item.attributes = @params["item"]
@item.attributes = params["item"]
if @item.due?
@item.due = Date.strptime(@params["item"]["due"], @user.preferences["date_format"])
@item.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
else
@item.due = ""
end
@ -182,10 +182,10 @@ class TodoController < ApplicationController
#self.init
@tickle = check_user_return_item
@original_item_context_id = @tickle.context_id
@tickle.attributes = @params["item"]
@tickle.attributes = params["item"]
if @tickle.due?
@tickle.due = Date.strptime(@params["item"]["due"], @user.preferences["date_format"])
@tickle.due = Date.strptime(params["item"]["due"], @user.preferences["date_format"])
else
@tickle.due = ""
end
@ -280,7 +280,7 @@ class TodoController < ApplicationController
protected
def check_user_return_item
item = Todo.find( @params['id'] )
item = Todo.find( params['id'] )
if @user == item.user
return item
else

View file

@ -23,12 +23,12 @@ class UserController < ApplicationController
end
def update_preferences
@user.preferences = { "date_format" => "#{@params['prefs']['date_format']}",
"week_starts" => "#{@params['prefs']['week_starts']}",
"no_completed" => "#{@params['prefs']['no_completed']}",
"staleness_starts" => "#{@params['prefs']['staleness_starts']}",
"due_style" => "#{@params['prefs']['due_style']}",
"admin_email" => "#{@params['prefs']['admin_email']}"
@user.preferences = { "date_format" => "#{params['prefs']['date_format']}",
"week_starts" => "#{params['prefs']['week_starts']}",
"no_completed" => "#{params['prefs']['no_completed']}",
"staleness_starts" => "#{params['prefs']['staleness_starts']}",
"due_style" => "#{params['prefs']['due_style']}",
"admin_email" => "#{params['prefs']['admin_email']}"
}
if @user.save
redirect_to :action => 'preferences'

View file

@ -3,7 +3,7 @@ module LoginHelper
def render_errors(obj)
return "" unless obj
return "" unless @request.post?
return "" unless request.post?
tag = String.new
unless obj.valid?

View file

@ -38,11 +38,11 @@
<!--[eoform:context]-->
</div>
<% if @flash["confirmation"] %>
<div class="confirmation"><%= @flash["confirmation"] %></div>
<% if flash["confirmation"] %>
<div class="confirmation"><%= flash["confirmation"] %></div>
<% end %>
<% if @flash["warning"] %>
<div class="warning"><%= @flash["warning"] %></div>
<% if flash["warning"] %>
<div class="warning"><%= flash["warning"] %></div>
<% end %>
</div><!-- End of display_box -->

View file

@ -1,7 +1,7 @@
xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
xml.channel do
xml.title(@title)
xml.link("http://#{@request.host}:#{@request.port}/todo/list")
xml.link("http://#{request.host}:#{request.port}/todo/list")
xml.description(@description)
@todos.each { |i|
xml.item do

View file

@ -8,7 +8,7 @@
</head>
<body>
<%= @content_for_layout %>
<%= yield %>
<div id="footer">
<p>Send feedback: <a href="http://dev.rousette.org.uk/report/6">Trac</a> | <a href="http://www.rousette.org.uk/projects/wiki/">Wiki</a> | <a href="mailto:butshesagirl@rousette.org.uk?subject=Tracks feedback">Email</a> | <a href="http://www.rousette.org.uk/projects/">Website</a></p>

View file

@ -5,6 +5,6 @@
<%= stylesheet_link_tag "scaffold" %>
</head>
<body>
<%= @content_for_layout %>
<%= yield %>
</body>
</html>

View file

@ -36,11 +36,11 @@
<!--[eoform:project]-->
</div>
<% if @flash["confirmation"] %>
<div class="confirmation"><%= @flash["confirmation"] %></div>
<% if flash["confirmation"] %>
<div class="confirmation"><%= flash["confirmation"] %></div>
<% end %>
<% if @flash["warning"] %>
<div class="warning"><%= @flash["warning"] %></div>
<% if flash["warning"] %>
<div class="warning"><%= flash["warning"] %></div>
<% end %>
</div><!-- End of display_box -->

View file

@ -5,26 +5,26 @@
ActiveRecord::Schema.define(:version => 8) do
create_table "contexts", :force => true do |t|
t.column "name", :string, :null => false
t.column "position", :integer, :null => false
t.column "hide", :boolean, :default => false
t.column "name", :string, :default => "", :null => false
t.column "hide", :integer, :limit => 4, :default => 0, :null => false
t.column "position", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 1
end
create_table "notes", :force => true do |t|
t.column "user_id", :integer, :null => false
t.column "project_id", :integer, :null => false
t.column "user_id", :integer, :default => 0, :null => false
t.column "project_id", :integer, :default => 0, :null => false
t.column "body", :text
t.column "created_at", :datetime, :default => Sat Jan 01 00:00:00 GMT 2000
t.column "updated_at", :datetime, :default => Sat Jan 01 00:00:00 GMT 2000
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
create_table "projects", :force => true do |t|
t.column "name", :string, :null => false
t.column "position", :integer, :null => false
t.column "done", :boolean, :default => false
t.column "name", :string, :default => "", :null => false
t.column "position", :integer, :default => 0, :null => false
t.column "done", :integer, :limit => 4, :default => 0, :null => false
t.column "user_id", :integer, :default => 1
t.column "description", :text, :default => ""
t.column "description", :text
end
create_table "sessions", :force => true do |t|
@ -36,24 +36,24 @@ ActiveRecord::Schema.define(:version => 8) do
add_index "sessions", ["session_id"], :name => "sessions_session_id_index"
create_table "todos", :force => true do |t|
t.column "context_id", :integer, :null => false
t.column "project_id", :integer
t.column "description", :string, :null => false
t.column "context_id", :integer, :default => 0, :null => false
t.column "description", :string, :limit => 100, :default => "", :null => false
t.column "notes", :text
t.column "done", :boolean, :default => false, :null => false
t.column "created_at", :datetime, :default => Sat Jan 01 00:00:00 GMT 2000
t.column "done", :integer, :limit => 4, :default => 0, :null => false
t.column "created_at", :datetime
t.column "due", :date
t.column "completed", :datetime
t.column "project_id", :integer
t.column "user_id", :integer, :default => 1
t.column "type", :string, :default => "Immediate", :null => false
t.column "show_from", :date
end
create_table "users", :force => true do |t|
t.column "login", :string, :limit => 80, :null => false
t.column "password", :string, :limit => 40, :null => false
t.column "login", :string, :limit => 80
t.column "password", :string, :limit => 40
t.column "word", :string
t.column "is_admin", :boolean, :default => false, :null => false
t.column "is_admin", :integer, :limit => 4, :default => 0, :null => false
t.column "preferences", :text
end

View file

@ -46,7 +46,7 @@ module LoginSystem
return true
end
if @session['user_id'] and authorize?(User.find(@session['user_id']))
if session['user_id'] and authorize?(User.find(session['user_id']))
return true
end
@ -75,16 +75,16 @@ module LoginSystem
# store current uri in the session.
# we can return to this location by calling return_location
def store_location
@session['return-to'] = @request.request_uri
session['return-to'] = request.request_uri
end
# move to the last store_location call or to the passed default one
def redirect_back_or_default(default)
if @session['return-to'].nil?
if session['return-to'].nil?
redirect_to default
else
redirect_to_url @session['return-to']
@session['return-to'] = nil
redirect_to_url session['return-to']
session['return-to'] = nil
end
end

View file

@ -122,10 +122,10 @@ end
project_id: ~
description: Upgrade to Rails 0.9.1
notes: ~
done: <%= b_false %>
done: <%= b_true %>
created_at: <%= today %>
due: <%= today %>
completed: ~
completed: <%= today %>
user_id: 1
9:

View file

@ -7,7 +7,7 @@ class ContextController; def rescue_action(e) raise e end; end
class ContextControllerTest < Test::Unit::TestCase
def setup
@controller = ContextController.new
@request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
request, response = ActionController::TestRequest.new, ActionController::TestResponse.new
end
# Replace this with your real tests.

View file

@ -7,7 +7,7 @@ class FeedController; def rescue_action(e) raise e end; end
class FeedControllerTest < Test::Unit::TestCase
def setup
@controller = FeedController.new
@request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
request, response = ActionController::TestRequest.new, ActionController::TestResponse.new
end
# Replace this with your real tests.

View file

@ -7,8 +7,8 @@ class NoteController; def rescue_action(e) raise e end; end
class NoteControllerTest < Test::Unit::TestCase
def setup
@controller = NoteController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
request = ActionController::TestRequest.new
response = ActionController::TestResponse.new
end
# Replace this with your real tests.

View file

@ -7,7 +7,7 @@ class ProjectController; def rescue_action(e) raise e end; end
class ProjectControllerTest < Test::Unit::TestCase
def setup
@controller = ProjectController.new
@request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
request, response = ActionController::TestRequest.new, ActionController::TestResponse.new
end
# Replace this with your real tests.

View file

@ -1,10 +0,0 @@
require File.dirname(__FILE__) + '/../test_helper'
class DeferredTest < Test::Unit::TestCase
fixtures :deferreds
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -1,10 +0,0 @@
require File.dirname(__FILE__) + '/../test_helper'
class ImmediateTest < Test::Unit::TestCase
fixtures :immediates
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -19,8 +19,8 @@ class TodoTest < Test::Unit::TestCase
assert_equal "Call Bill Gates to find out how much he makes per day", @not_completed1.description
assert_nil @not_completed1.notes
assert_equal 0, @not_completed1.done
assert_equal "2004-11-28 16:01:00", @not_completed1.created_at.strftime("%Y-%m-%d %H:%M:%S")
assert_equal "2004-10-30", @not_completed1.due.strftime("%Y-%m-%d")
assert_equal 1.week.ago.to_s(:db), @not_completed1.created_at.strftime("%Y-%m-%d %H:%M:%S")
assert_equal 2.week.from_now.strftime("%Y-%m-%d"), @not_completed1.due.strftime("%Y-%m-%d")
assert_nil @not_completed1.completed
assert_equal 1, @not_completed1.user_id
end